Skip to content

🚀 Release Please #463

🚀 Release Please

🚀 Release Please #463

Workflow file for this run

name: "🚀 Release Please"
on:
push:
branches:
- main
workflow_dispatch:
# Ensure this workflow has the necessary permissions
permissions:
contents: write
pull-requests: write
id-token: write # needed for npm provenance
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
cli_released: ${{ steps.release.outputs.releases_created && contains(fromJson(steps.release.outputs.paths_released || '[]'), 'packages/gensx') }}
# Only run on pushes to the original repository and not on forks
if: |
github.repository == 'gensx-inc/gensx' &&
github.event.repository.fork == false &&
github.actor != 'dependabot[bot]'
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.PAT_GITHUB_TOKEN }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
# The following steps only run when merging a release PR
- name: Checkout 🛬
if: ${{ steps.release.outputs.releases_created }}
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Setup Node ⚙️
if: ${{ steps.release.outputs.releases_created }}
uses: ./.github/actions/setup-node
with:
npm_token: ${{ secrets.NPM_TOKEN }}
- name: Build Packages 🏗️
if: ${{ steps.release.outputs.releases_created }}
run: |
pnpm install --frozen-lockfile
pnpm build
- name: Publish to NPM 🚀
if: ${{ steps.release.outputs.releases_created }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: "true"
run: |
pnpm publish --no-git-checks --access public -r
build-cli-binary:
needs: release-please
if: needs.release-please.outputs.cli_released == 'true'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
strategy:
fail-fast: false
matrix:
target: [win, linux, macos-x64, macos-arm64]
steps:
- uses: actions/checkout@v4
- name: Setup Deno ⚙️
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Setup Node ⚙️
uses: ./.github/actions/setup-node
- name: Get Version
id: get-version
run: |
VERSION=$(node -p "require('./packages/gensx/package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build 📦
run: pnpm build
- name: Build Binary 🏗️
run: |
cd packages/gensx-cli
deno task compile:${{ matrix.target }}
- name: Prepare Archive (Unix)
if: ${{ !contains(matrix.target, 'win') }}
run: |
cd packages/gensx-cli
tar czf gensx-${{ matrix.target }}.tar.gz gensx-cli-${{ matrix.target }}
cp gensx-${{ matrix.target }}.tar.gz gensx_${{ steps.get-version.outputs.version }}_${{ matrix.target }}.tar.gz
- name: Prepare Archive (Windows)
if: matrix.target == 'win'
run: |
cd packages/gensx-cli
zip gensx-windows.zip gensx-cli-windows.exe
cp gensx-windows.zip gensx_${{ steps.get-version.outputs.version }}_windows.zip
- name: Upload Release Assets
uses: softprops/[email protected]
with:
tag_name: gensx-cli-binary-v${{ steps.get-version.outputs.version }}
token: ${{ secrets.PAT_GITHUB_TOKEN }}
files: |
packages/gensx-cli/gensx_${{ steps.get-version.outputs.version }}_${{ matrix.target }}.*
update-homebrew:
needs: [release-please, build-cli-binary]
if: needs.release-please.outputs.cli_released == 'true'
runs-on: ubuntu-latest
steps:
- name: Download macOS ARM64 Release
uses: dsaltares/[email protected]
with:
version: tags/gensx-cli-binary-v${{ needs.build-cli-binary.outputs.version }}
file: gensx_${{ needs.build-cli-binary.outputs.version }}_macos-arm64.tar.gz
token: ${{ secrets.PAT_GITHUB_TOKEN }}
- name: Download macOS x64 Release
uses: dsaltares/[email protected]
with:
version: tags/gensx-cli-binary-v${{ needs.build-cli-binary.outputs.version }}
file: gensx_${{ needs.build-cli-binary.outputs.version }}_macos-x64.tar.gz
token: ${{ secrets.PAT_GITHUB_TOKEN }}
- name: Calculate SHA256 Checksums
run: |
echo "ARM64_SHA256=$(sha256sum gensx_${{ needs.build-cli-binary.outputs.version }}_macos-arm64.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV
echo "X64_SHA256=$(sha256sum gensx_${{ needs.build-cli-binary.outputs.version }}_macos-x64.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Checkout homebrew-gensx repo
uses: actions/checkout@v4
with:
repository: gensx-inc/homebrew-gensx
token: ${{ secrets.PAT_GITHUB_TOKEN }}
path: homebrew-gensx
- name: Update Formula
run: |
cat > homebrew-gensx/Formula/gensx.rb << EOL
class Gensx < Formula
desc "GenSX CLI - The command-line interface for GenSX"
homepage "https://gensx.com"
version "${{ needs.build-cli-binary.outputs.version }}"
license "MIT"
on_macos do
on_arm do
url "https://github.com/gensx-inc/gensx/releases/download/gensx-cli-binary-v${{ needs.build-cli-binary.outputs.version }}/gensx_${{ needs.build-cli-binary.outputs.version }}_macos-arm64.tar.gz"
sha256 "${{ env.ARM64_SHA256 }}"
end
on_intel do
url "https://github.com/gensx-inc/gensx/releases/download/gensx-cli-binary-v${{ needs.build-cli-binary.outputs.version }}/gensx_${{ needs.build-cli-binary.outputs.version }}_macos-x64.tar.gz"
sha256 "${{ env.X64_SHA256 }}"
end
end
def install
binary_name = Hardware::CPU.arm? ? "gensx-cli-macos-arm64" : "gensx-cli-macos-x64"
bin.install binary_name => "gensx"
chmod 0755, bin/"gensx"
end
end
EOL
- name: Commit and Push Changes
run: |
cd homebrew-gensx
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
git add Formula/gensx.rb
git commit -m "Update formula to version ${{ needs.build-cli-binary.outputs.version }}"
git push