Merge pull request #57 from mrgoonie/dev #20
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: Production Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| outputs: | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for releasable commits | |
| id: check | |
| run: | | |
| $lastTag = git describe --tags --abbrev=0 2>$null | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "No tags found, checking all commits" | |
| # No tags yet, check all commits (include first-parent to see PR merges) | |
| $commits = git log --oneline --first-parent | |
| } else { | |
| Write-Host "Last tag: $lastTag" | |
| # Check commits since last tag (first-parent follows main branch history) | |
| $commits = git log "$lastTag..HEAD" --oneline --first-parent | |
| } | |
| Write-Host "Commits to check:" | |
| $commits | ForEach-Object { Write-Host " $_" } | |
| # Match conventional commits OR merge commits that mention feat/fix PRs | |
| $hasReleasable = $commits | Where-Object { | |
| $_ -match "^[a-f0-9]+ (feat|fix|perf|refactor)(\(.+\))?:" -or | |
| $_ -match "Merge pull request.*from.*" -or | |
| $_ -match "^[a-f0-9]+ Merge branch" | |
| } | |
| if ($hasReleasable) { | |
| Write-Host "Found releasable commits:" | |
| $hasReleasable | ForEach-Object { Write-Host " $_" } | |
| echo "should_release=true" >> $env:GITHUB_OUTPUT | |
| } else { | |
| Write-Host "No releasable commits found" | |
| echo "should_release=false" >> $env:GITHUB_OUTPUT | |
| } | |
| shell: pwsh | |
| - name: Setup Go | |
| if: steps.check.outputs.should_release == 'true' | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - name: Setup Node.js | |
| if: steps.check.outputs.should_release == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install Wails CLI | |
| if: steps.check.outputs.should_release == 'true' | |
| run: go install github.com/wailsapp/wails/v2/cmd/wails@latest | |
| - name: Clean and install frontend dependencies | |
| if: steps.check.outputs.should_release == 'true' | |
| run: | | |
| cd frontend | |
| if (Test-Path node_modules) { Remove-Item -Recurse -Force node_modules } | |
| npm install | |
| shell: pwsh | |
| - name: Build portable executable | |
| if: steps.check.outputs.should_release == 'true' | |
| run: wails build -clean -platform windows/amd64 | |
| - name: Build NSIS installer | |
| if: steps.check.outputs.should_release == 'true' | |
| run: wails build -platform windows/amd64 -nsis | |
| - name: Upload build artifacts | |
| if: steps.check.outputs.should_release == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: winshot-windows | |
| path: | | |
| build/bin/winshot.exe | |
| build/bin/winshot-amd64-installer.exe | |
| release: | |
| needs: build | |
| if: needs.build.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.PAT }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: winshot-windows | |
| path: build/bin | |
| - name: Semantic Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PAT }} | |
| run: npx semantic-release |