Harden release publish flow and bump to v0.1.7 #4
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build release (${{ matrix.target.name }}) | |
| runs-on: ${{ matrix.target.os }} | |
| timeout-minutes: 60 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - name: windows | |
| os: windows-latest | |
| script: npm run build:win -- --publish never | |
| platform: windows | |
| artifact: dram-win-release | |
| - name: linux | |
| os: ubuntu-latest | |
| script: npm run build:linux -- --publish never | |
| platform: linux | |
| artifact: dram-linux-release | |
| - name: macos | |
| os: macos-latest | |
| script: npm run build:mac -- --publish never | |
| platform: macos | |
| artifact: dram-macos-release | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build release artifact | |
| run: ${{ matrix.target.script }} | |
| - name: Verify installer artifacts | |
| run: npm run verify:installers -- --platform ${{ matrix.target.platform }} | |
| - name: Upload release artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.target.artifact }} | |
| path: dist/** | |
| if-no-files-found: error | |
| retention-days: 7 | |
| publish: | |
| name: Publish GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Download release artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: dram-*-release | |
| path: release-assets | |
| merge-multiple: true | |
| - name: Inspect existing release state | |
| id: release_state | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| tag="${GITHUB_REF_NAME}" | |
| if gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${tag}" > release.json 2>/dev/null; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| echo "immutable=$(jq -r '.immutable' release.json)" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| echo "immutable=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Skip immutable pre-created release | |
| if: steps.release_state.outputs.exists == 'true' && steps.release_state.outputs.immutable == 'true' | |
| run: | | |
| echo "::warning::Release for ${GITHUB_REF_NAME} already exists and is immutable. Skipping update to avoid failure." | |
| echo "::warning::Use a fresh tag (e.g. patch increment) so workflow can create/upload release assets." | |
| - name: Delete existing mutable release | |
| if: steps.release_state.outputs.exists == 'true' && steps.release_state.outputs.immutable != 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| tag="${GITHUB_REF_NAME}" | |
| echo "Deleting mutable existing release for ${tag} to avoid stale asset update conflicts." | |
| gh release delete "${tag}" --yes --cleanup-tag=false | |
| - name: Publish GitHub Release | |
| if: steps.release_state.outputs.exists != 'true' || steps.release_state.outputs.immutable != 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| fail_on_unmatched_files: true | |
| files: release-assets/** |