Repository navigation
chore: release v0.4.2 #18
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: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| - "v[0-9]+.[0-9]+.[0-9]+-b*" | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| jobs: | |
| verify: | |
| name: Typecheck & Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Install Dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Typecheck | |
| run: bun run typecheck | |
| - name: Unit Tests | |
| run: bun run test | |
| build-and-release: | |
| name: Build & Release | |
| runs-on: ubuntu-latest | |
| needs: verify | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Install Dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Read Version from Tag | |
| id: version | |
| run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - name: Check Version Bump Was Committed | |
| env: | |
| RELEASE_VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| PKG_VERSION="$(bun -e "console.log(require('./package.json').version)")" | |
| if [ "$PKG_VERSION" != "$RELEASE_VERSION" ]; then | |
| echo "::error::package.json is at $PKG_VERSION but the tag is v$RELEASE_VERSION. Run 'bun ./scripts/bump-version.ts v$RELEASE_VERSION', commit the version bump, push to main, then push the tag." | |
| exit 1 | |
| fi | |
| echo "Version bump for v$RELEASE_VERSION is committed." | |
| - name: Guard Against Already-Published Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RELEASE_TAG: ${{ github.ref_name }} | |
| run: | | |
| # Published releases are immutable: never touch an existing one. | |
| if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then | |
| IS_DRAFT="$(gh release view "$RELEASE_TAG" --json isDraft -q .isDraft)" | |
| if [ "$IS_DRAFT" != "true" ]; then | |
| echo "::error::Release $RELEASE_TAG is already published and immutable - refusing to modify it. Delete the tag and use a new version to re-release." | |
| exit 1 | |
| fi | |
| echo "A draft for $RELEASE_TAG already exists - it will be finalized." | |
| fi | |
| - name: Run Build | |
| run: bun run build:force | |
| - name: Package Assets | |
| run: | | |
| cd dist | |
| zip -r ../fxmanager-linux.zip fxmanager-linux assets/ | |
| zip -r ../fxmanager-windows.zip fxmanager-windows.exe assets/ | |
| zip -r ../fxmanager-resource.zip fxManager/ | |
| cd .. | |
| # Regenerates the release notes at the tagged commit (version input | |
| # keeps the name/tag/body consistent with the tag the maintainer | |
| # pushed) and retargets the rolling draft to it. publish stays false: | |
| # assets must be attached while the release is still a draft because | |
| # published releases are immutable. | |
| - name: Finalize Release Notes Draft | |
| id: drafter | |
| uses: release-drafter/release-drafter@v7 | |
| with: | |
| config-name: release-drafter.yml | |
| version: ${{ steps.version.outputs.version }} | |
| - name: Upload Assets | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RELEASE_TAG: ${{ github.ref_name }} | |
| run: | | |
| # --clobber makes re-runs (after a mid-workflow failure) idempotent. | |
| gh release upload "$RELEASE_TAG" \ | |
| fxmanager-linux.zip \ | |
| fxmanager-windows.zip \ | |
| fxmanager-resource.zip \ | |
| --clobber | |
| - name: Publish Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RELEASE_ID: ${{ steps.drafter.outputs.id }} | |
| IS_PRERELEASE: ${{ contains(github.ref_name, '-') }} | |
| run: | | |
| gh api --method PATCH "repos/${{ github.repository }}/releases/$RELEASE_ID" \ | |
| -F draft=false \ | |
| -F prerelease="$IS_PRERELEASE" | |
| echo "Published ${{ github.ref_name }}" |