docs: Updated blog styling (#373) #226
This file contains 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 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-cli') }} | |
cli_version: ${{ fromJson(steps.release.outputs.paths_released || '[]')['packages/gensx-cli'].version }} | |
# 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: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
# - node22-linux-arm64 | |
# - node22-linux-x64 | |
- node22-macos-arm64 | |
- node22-macos-x64 | |
# - node22-win-arm64 | |
# - node22-win-x64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node ⚙️ | |
uses: ./.github/actions/setup-node | |
with: | |
version: 20.x | |
- name: Build Packages 🏗️ | |
run: pnpm build | |
- name: Building... | |
run: TARGET=${{ matrix.target }} pnpm run package | |
working-directory: packages/gensx-cli | |
- name: Prepare content... | |
run: | | |
mv README.md dist/pkg | |
working-directory: packages/gensx-cli | |
- name: Setup environment (Unix) | |
if: contains(fromJSON('["node22-linux-arm64", "node22-linux-x64", "node22-macos-arm64", "node22-macos-x64"]'), matrix.target) | |
run: | | |
echo "_EXT=tar.gz" >> $GITHUB_ENV | |
- name: Setup environment (Windows) | |
if: contains(fromJSON('["node22-win-arm64", "node22-win-x64"]'), matrix.target) | |
run: | | |
echo "_EXT=zip" >> $GITHUB_ENV | |
- name: Change permissions (Unix) | |
if: contains(fromJSON('["node22-linux-arm64", "node22-linux-x64", "node22-macos-arm64", "node22-macos-x64"]'), matrix.target) | |
run: | | |
chmod -R 777 ./dist/pkg | |
working-directory: packages/gensx-cli | |
- name: Tar dist (Unix) | |
if: contains(fromJSON('["node22-linux-arm64", "node22-linux-x64", "node22-macos-arm64", "node22-macos-x64"]'), matrix.target) | |
run: | | |
tar czf ${{ matrix.target }}.${{ env._EXT }} -C ./dist/pkg . | |
cp ${{ matrix.target }}.${{ env._EXT }} gensx_${{ needs.release-please.outputs.cli_version }}_${{ matrix.target }}.${{ env._EXT }} | |
working-directory: packages/gensx-cli | |
- name: Zipping dist (Windows) | |
if: contains(fromJSON('["win-arm64", "win-x64"]'), matrix.target) | |
working-directory: packages/gensx-cli/dist/pkg | |
run: | | |
zip -r ${{ matrix.target }}.${{ env._EXT }} . | |
mv ${{ matrix.target }}.${{ env._EXT }} ../../ | |
cd ../.. | |
cp ${{ matrix.target }}.${{ env._EXT }} gensx_${{ needs.release-please.outputs.cli_version }}_${{ matrix.target }}.${{ env._EXT }} | |
- name: Upload Release Assets | |
uses: softprops/action-gh-release@v2.0.8 | |
with: | |
tag_name: gensx-cli-binary-v${{ needs.release-please.outputs.cli_version }} | |
token: ${{ secrets.PAT_GITHUB_TOKEN }} | |
files: packages/gensx-cli/gensx_${{ needs.release-please.outputs.cli_version }}_${{ matrix.target }}.${{ env._EXT }} | |
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/fetch-gh-release-asset@1.1.1 | |
with: | |
version: tags/gensx-cli-binary-v${{ needs.release-please.outputs.cli_version }} | |
file: gensx_${{ needs.release-please.outputs.cli_version }}_node22-macos-arm64.tar.gz | |
token: ${{ secrets.PAT_GITHUB_TOKEN }} | |
- name: Download macOS x64 Release | |
uses: dsaltares/fetch-gh-release-asset@1.1.1 | |
with: | |
version: tags/gensx-cli-binary-v${{ needs.release-please.outputs.cli_version }} | |
file: gensx_${{ needs.release-please.outputs.cli_version }}_node22-macos-x64.tar.gz | |
token: ${{ secrets.PAT_GITHUB_TOKEN }} | |
- name: Calculate SHA256 Checksums | |
run: | | |
echo "ARM64_SHA256=$(sha256sum gensx_${{ needs.release-please.outputs.cli_version }}_node22-macos-arm64.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV | |
echo "X64_SHA256=$(sha256sum gensx_${{ needs.release-please.outputs.cli_version }}_node22-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.release-please.outputs.cli_version }}" | |
license "MIT" | |
on_macos do | |
on_arm do | |
url "https://github.com/gensx-inc/gensx/releases/download/gensx-cli-binary-v${{ needs.release-please.outputs.cli_version }}/gensx_${{ needs.release-please.outputs.cli_version }}_node22-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.release-please.outputs.cli_version }}/gensx_${{ needs.release-please.outputs.cli_version }}_node22-macos-x64.tar.gz" | |
sha256 "${{ env.X64_SHA256 }}" | |
end | |
end | |
def install | |
# Extract the tar.gz file | |
system "tar", "xf", cached_download | |
# Install the 'run' file as 'gensx' in the bin directory | |
bin.install "run" => "gensx" | |
# Make the file executable | |
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 "actions@github.com" | |
git add Formula/gensx.rb | |
git commit -m "Update formula to version ${{ needs.release-please.outputs.cli_version }}" | |
git push |