From b04e330356373a6c24ef13b337ea3f2ee4736f54 Mon Sep 17 00:00:00 2001 From: Aditya Date: Sat, 20 Jun 2026 20:18:55 +0530 Subject: [PATCH] Refactor release.yml to use matrix strategy, sync version, and auto-update homebrew tap --- .github/workflows/release.yml | 75 ++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62eb92d..b46b22a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,32 +5,85 @@ on: permissions: contents: write jobs: - release: - runs-on: macos-latest + create-tag: + runs-on: ubuntu-latest + outputs: + new_tag: ${{ steps.tag_version.outputs.new_tag }} + new_version: ${{ steps.tag_version.outputs.new_version }} steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: '22' - - run: npm install - name: Bump version and push tag id: tag_version uses: mathieudutour/github-tag-action@v6.2 with: github_token: ${{ secrets.GITHUB_TOKEN }} + + build-and-release: + needs: create-tag + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + - run: npm install + + - name: Sync package.json version + run: npm --no-git-tag-version version ${{ needs.create-tag.outputs.new_version }} + - run: npm run build - - run: npm run package + + - name: Build Electron app + run: npx electron-builder env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create GitHub Release + + - name: Upload Release Assets uses: softprops/action-gh-release@v3 with: - tag_name: ${{ steps.tag_version.outputs.new_tag }} + tag_name: ${{ needs.create-tag.outputs.new_tag }} + fail_on_unmatched_files: false files: | release/*.zip release/*.dmg release/*.exe release/*.AppImage release/*.deb + + update-homebrew: + needs: [create-tag, build-and-release] + runs-on: macos-latest + steps: + - name: Checkout Homebrew Tap + uses: actions/checkout@v4 + with: + repository: VariableThe/homebrew-tap + token: ${{ secrets.HOMEBREW_TAP_TOKEN }} + path: homebrew-tap + + - name: Download macOS ZIP + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + VERSION=${{ needs.create-tag.outputs.new_version }} + gh release download v$VERSION --pattern "*.zip" --repo $GITHUB_REPOSITORY + + # Calculate SHA256 of the downloaded ZIP + ZIP_FILE=$(ls *.zip | head -n 1) + SHA256=$(shasum -a 256 "$ZIP_FILE" | awk '{ print $1 }') + + # Update the rb file + cd homebrew-tap + sed -i '' "s/version \".*\"/version \"$VERSION\"/" Casks/papercache.rb + sed -i '' "s/sha256 arm: * \".*\"/sha256 arm: \"$SHA256\"/" Casks/papercache.rb + sed -i '' "s/PaperCache-[0-9]*\.[0-9]*\.[0-9]*-/PaperCache-#{version}-/g" Casks/papercache.rb + + # Commit and Push + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add Casks/papercache.rb + git commit -m "Bump PaperCache to $VERSION" || echo "No changes to commit" + git push