Merge pull request #27 from VariableThe/VariableThe-patch-3 #37
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: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| create-tag: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new_tag: ${{ steps.get_version.outputs.new_tag }} | |
| new_version: ${{ steps.get_version.outputs.new_version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get version from package.json | |
| id: get_version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "new_version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "new_tag=v$VERSION" >> $GITHUB_OUTPUT | |
| - name: Create and push tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v${{ steps.get_version.outputs.new_version }}" -m "Release v${{ steps.get_version.outputs.new_version }}" || echo "Tag already exists" | |
| git push origin "v${{ steps.get_version.outputs.new_version }}" || echo "Tag already pushed" | |
| 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 ci | |
| - run: npm run build | |
| - name: Build Electron app | |
| run: npx electron-builder | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload Release Assets | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: ${{ needs.create-tag.outputs.new_tag }} | |
| fail_on_unmatched_files: false | |
| files: | | |
| release/*.zip | |
| release/*.dmg | |
| release/*.exe | |
| release/*.AppImage | |
| release/*.deb | |
| release/*.yml | |
| release/*.blockmap | |
| 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 |