Update CHANGELOG #31
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: | |
| create-release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| steps: | |
| - name: Create Release | |
| id: create_release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| CUSTOM_NOTES: | | |
| ## Installation | |
| ```bash | |
| brew install jackielii/tap/skhd-zig | |
| ``` | |
| or upgrade: | |
| ```bash | |
| brew upgrade jackielii/tap/skhd-zig | |
| ``` | |
| ## Documentation | |
| See [CHANGELOG.md](https://github.com/jackielii/skhd.zig/blob/main/CHANGELOG.md) for detailed changes. | |
| run: | | |
| # Create a draft release with auto-generated notes | |
| gh release create ${{ github.ref_name }} \ | |
| --repo ${{ github.repository }} \ | |
| --title "${{ github.ref_name }}" \ | |
| --generate-notes \ | |
| --draft | |
| # Get the auto-generated notes | |
| AUTO_NOTES=$(gh release view ${{ github.ref_name }} --repo ${{ github.repository }} --json body -q .body) | |
| # Combine auto-generated notes with custom notes | |
| FULL_NOTES="$AUTO_NOTES"$'\n\n'"$CUSTOM_NOTES" | |
| # Update the release with combined notes but keep it as draft | |
| gh release edit ${{ github.ref_name }} \ | |
| --repo ${{ github.repository }} \ | |
| --notes "$FULL_NOTES" | |
| build-release: | |
| needs: create-release | |
| strategy: | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| arch: arm64 | |
| - os: macos-13 | |
| arch: x86_64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.14.0 | |
| - name: Build Release | |
| run: | | |
| zig build -Doptimize=ReleaseFast | |
| mv zig-out/bin/skhd skhd-${{ matrix.arch }}-macos | |
| - name: Create tarball | |
| run: | | |
| tar -czf skhd-${{ matrix.arch }}-macos.tar.gz skhd-${{ matrix.arch }}-macos | |
| - name: Upload Release Asset | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload ${{ github.ref_name }} \ | |
| ./skhd-${{ matrix.arch }}-macos.tar.gz \ | |
| --repo ${{ github.repository }} \ | |
| --clobber | |
| publish-release: | |
| needs: build-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Publish Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release edit ${{ github.ref_name }} \ | |
| --repo ${{ github.repository }} \ | |
| --draft=false | |
| update-homebrew: | |
| needs: publish-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout homebrew-tap | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: jackielii/homebrew-tap | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN || secrets.GITHUB_TOKEN }} | |
| path: homebrew-tap | |
| - name: Get release info | |
| id: release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ github.ref_name }}" | |
| echo "version=${VERSION#v}" >> $GITHUB_OUTPUT | |
| # Download release assets to calculate SHA256 | |
| cd ${{ github.workspace }} | |
| gh release download ${VERSION} --repo jackielii/skhd.zig --pattern "*.tar.gz" | |
| # Calculate SHA256 for both architectures | |
| ARM64_SHA=$(shasum -a 256 skhd-arm64-macos.tar.gz | awk '{print $1}') | |
| X86_64_SHA=$(shasum -a 256 skhd-x86_64-macos.tar.gz | awk '{print $1}') | |
| echo "arm64_sha=${ARM64_SHA}" >> $GITHUB_OUTPUT | |
| echo "x86_64_sha=${X86_64_SHA}" >> $GITHUB_OUTPUT | |
| - name: Update Formula | |
| run: | | |
| cd homebrew-tap | |
| # Update version | |
| sed -i "s/version \".*\"/version \"${{ steps.release.outputs.version }}\"/" Formula/skhd-zig.rb | |
| # Update URLs | |
| sed -i "s|download/v[0-9.]\+/skhd-x86_64|download/v${{ steps.release.outputs.version }}/skhd-x86_64|" Formula/skhd-zig.rb | |
| sed -i "s|download/v[0-9.]\+/skhd-arm64|download/v${{ steps.release.outputs.version }}/skhd-arm64|" Formula/skhd-zig.rb | |
| # Update SHA256 | |
| sed -i "/x86_64-macos.tar.gz/,/sha256/ s/sha256 \".*\"/sha256 \"${{ steps.release.outputs.x86_64_sha }}\"/" Formula/skhd-zig.rb | |
| sed -i "/arm64-macos.tar.gz/,/sha256/ s/sha256 \".*\"/sha256 \"${{ steps.release.outputs.arm64_sha }}\"/" Formula/skhd-zig.rb | |
| - name: Commit and push | |
| run: | | |
| cd homebrew-tap | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git add Formula/skhd-zig.rb | |
| git commit -m "Update skhd-zig to v${{ steps.release.outputs.version }}" | |
| git push | |