Release #30
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: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Release version (e.g. 0.2.0)" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| ci: | |
| uses: ./.github/workflows/ci.yml | |
| release: | |
| needs: ci | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.RELEASE_PAT }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Set version | |
| id: version | |
| run: | | |
| npm version ${{ github.event.inputs.version }} --no-git-tag-version --allow-same-version | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| # A version with a pre-release identifier (e.g. 2.1.0-beta.1) should be | |
| # published as a GitHub pre-release so electron-updater skips it for | |
| # stable users (allowPrerelease defaults to false). | |
| if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "release_type=release" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "release_type=prerelease" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit version bump | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add package.json package-lock.json | |
| git diff --cached --quiet || git commit -m "Bump version to ${{ steps.version.outputs.version }}" | |
| git push | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Setup Python for node-gyp | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install setuptools for node-gyp | |
| run: python -m pip install setuptools | |
| - name: Build | |
| run: npm run build | |
| - name: Package and publish | |
| env: | |
| CSC_LINK: ${{ secrets.CSC_LINK }} | |
| CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npx electron-builder --mac --arm64 --publish always --config.publish.releaseType=${{ steps.version.outputs.release_type }} | |
| - name: Add release notes | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="v${{ steps.version.outputs.version }}" | |
| NOTES=$(gh api repos/${{ github.repository }}/releases/generate-notes \ | |
| -f tag_name="$TAG" \ | |
| --jq '.body') | |
| gh release edit "$TAG" --notes "$NOTES" |