diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5eb29d9..3cf4a48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,25 +1,26 @@ +# .github/workflows/ci.yml name: CI on: push: - branches: [ main, develop ] + branches: [main, develop] pull_request: - branches: [ main, develop ] + branches: [main, develop] + workflow_call: {} # <-- makes this workflow reusable jobs: test: name: Test runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v4 - + - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.21' - + go-version: "1.21" + - name: Install dependencies run: | sudo apt-get update @@ -32,20 +33,20 @@ jobs: pipewire-bin \ wl-clipboard \ wtype - + - name: Download dependencies run: go mod download - + - name: Run tests run: go test -v ./... -short - + - name: Build binary env: CGO_ENABLED: 1 run: go build -o hyprvoice ./cmd/hyprvoice - + - name: Test binary help run: ./hyprvoice --help - + - name: Test configure command run: ./hyprvoice configure --help diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 27e13e2..ed4a26f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,27 +1,34 @@ +# .github/workflows/release.yml name: Release on: push: tags: - - 'v*' + - "v*" permissions: contents: write jobs: + ci: + # Run your CI first and fail fast if tests fail + uses: ./.github/workflows/ci.yml + secrets: inherit + build: name: Build and Release + needs: ci runs-on: ubuntu-latest - + steps: - name: Checkout code uses: actions/checkout@v4 - + - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.21' - + go-version: "1.21" + - name: Install dependencies run: | sudo apt-get update @@ -34,11 +41,11 @@ jobs: pipewire-bin \ wl-clipboard \ wtype - - - name: Extract version from tag + + - name: Extract version from tag (drop the "v") id: version - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT - + run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + - name: Build binary env: CGO_ENABLED: 1 @@ -48,10 +55,7 @@ jobs: go mod download go build -ldflags="-s -w" -o hyprvoice-linux-x86_64 ./cmd/hyprvoice chmod +x hyprvoice-linux-x86_64 - - - name: Run tests - run: go test ./... - + - name: Generate checksums run: | sha256sum hyprvoice-linux-x86_64 > hyprvoice-linux-x86_64.sha256 @@ -61,7 +65,8 @@ jobs: - name: Create release uses: softprops/action-gh-release@v1 with: - tag_name: ${{ steps.version.outputs.VERSION }} + # Use the exact tag that triggered this run + tag_name: ${{ github.ref_name }} # e.g., v1.2.3 name: Release ${{ steps.version.outputs.VERSION }} body: | ## Hyprvoice v${{ steps.version.outputs.VERSION }} @@ -77,7 +82,7 @@ jobs: **Manual installation:** ```bash - wget https://github.com/leonardotrapani/hyprvoice/releases/download/v${{ steps.version.outputs.VERSION }}/hyprvoice-linux-x86_64 + wget https://github.com/leonardotrapani/hyprvoice/releases/download/${{ github.ref_name }}/hyprvoice-linux-x86_64 chmod +x hyprvoice-linux-x86_64 mv hyprvoice-linux-x86_64 ~/.local/bin/hyprvoice ``` @@ -90,7 +95,7 @@ jobs: - PipeWire audio system - OpenAI API key for transcription - **Full Changelog**: https://github.com/leonardotrapani/hyprvoice/commits/v${{ steps.version.outputs.VERSION }} + **Full Changelog**: https://github.com/leonardotrapani/hyprvoice/commits/${{ github.ref_name }} files: | ./hyprvoice-linux-x86_64 ./hyprvoice-linux-x86_64.sha256