Merge branch 'main' of https://github.com/0xarchit/Focusd #16
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Build | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| - name: Validate tag format | |
| shell: bash | |
| run: | | |
| TAG="${GITHUB_REF_NAME}" | |
| if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "ERROR: Tag '$TAG' does not match expected format vX.Y.Z" | |
| exit 1 | |
| fi | |
| - name: Set Version | |
| id: set_version | |
| shell: bash | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "Detected version from tag: $VERSION" | |
| - name: Extract Release Notes | |
| id: get_notes | |
| shell: powershell | |
| run: | | |
| $version = "${{ env.VERSION }}" | |
| if (Test-Path release_change.json) { | |
| $json = Get-Content release_change.json | ConvertFrom-Json | |
| $notes = $json.$version | |
| } | |
| if (-not $notes) { | |
| $formattedNotes = "Automated release for version $version" | |
| } else { | |
| $formattedNotes = $notes -join "`n- " | |
| $formattedNotes = "- " + $formattedNotes | |
| } | |
| "RELEASE_NOTES<<EOF" >> $env:GITHUB_ENV | |
| $formattedNotes >> $env:GITHUB_ENV | |
| "EOF" >> $env:GITHUB_ENV | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: "1.26" | |
| cache: false | |
| - name: Install NSIS | |
| run: | | |
| choco install nsis -y | |
| echo "C:\Program Files (x86)\NSIS" >> $env:GITHUB_PATH | |
| - name: Build | |
| env: | |
| CGO_ENABLED: 0 | |
| run: | | |
| go build -ldflags="-s -w -X 'focusd/system.Version=${{ env.VERSION }}'" -trimpath -o focusd.exe ./cmd/focusd | |
| go build -ldflags="-s -w -H=windowsgui -X 'focusd/system.Version=${{ env.VERSION }}'" -trimpath -o focusd_daemon.exe ./cmd/focusd_daemon | |
| - name: Build NSIS Installer | |
| run: | | |
| makensis /DVERSION=${{ env.VERSION }} installer.nsi | |
| - name: Generate Checksum | |
| shell: powershell | |
| run: | | |
| $hashSetup = (Get-FileHash -Path focusd_setup.exe -Algorithm SHA256).Hash.ToLower() | |
| "$hashSetup focusd_setup.exe" | Out-File -FilePath checksums.txt -Encoding ASCII | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| name: focusd v${{ env.VERSION }} | |
| body: ${{ env.RELEASE_NOTES }} | |
| files: | | |
| focusd_setup.exe | |
| checksums.txt | |
| token: ${{ secrets.GIT_TOKEN }} |