Skip to content

Release

Release #1

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get version from package.json
id: version
run: |
VERSION=$(jq -r .version package.json)
echo "current=${VERSION}" >> $GITHUB_OUTPUT
# Calculate next patch version
IFS='.' read -r major minor patch <<< "$VERSION"
NEXT="${major}.${minor}.$((patch + 1))"
echo "next=${NEXT}" >> $GITHUB_OUTPUT
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Run tests
run: bun test
- name: Build tarball
run: bun run pack
- name: Compute SHA256
id: checksum
run: |
VERSION="${{ steps.version.outputs.current }}"
TARBALL="build/planet57-commando-${VERSION}.tgz"
SHA256=$(shasum -a 256 "$TARBALL" | awk '{print $1}')
echo "sha256=${SHA256}" >> $GITHUB_OUTPUT
echo "tarball=${TARBALL}" >> $GITHUB_OUTPUT
- name: Prepare Homebrew formula
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
if [ -z "$HOMEBREW_TAP_TOKEN" ]; then
echo "::warning::HOMEBREW_TAP_TOKEN not set - will skip Homebrew update"
exit 0
fi
VERSION="${{ steps.version.outputs.current }}"
SHA256="${{ steps.checksum.outputs.sha256 }}"
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/jdillon/homebrew-planet57.git" tap
mkdir -p tap/Formula
# Copy template and replace placeholders
cp .github/formula-template.rb tap/Formula/commando.rb
sed -i "s/__VERSION__/${VERSION}/g" tap/Formula/commando.rb
sed -i "s/__SHA256__/${SHA256}/g" tap/Formula/commando.rb
# === All preparation done, now push everything ===
- 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 "v${{ steps.version.outputs.current }}"
git push origin "v${{ steps.version.outputs.current }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.current }}
files: ${{ steps.checksum.outputs.tarball }}
generate_release_notes: true
draft: false
- name: Push Homebrew formula
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
if [ -z "$HOMEBREW_TAP_TOKEN" ] || [ ! -d "tap" ]; then
echo "Skipping Homebrew update"
exit 0
fi
VERSION="${{ steps.version.outputs.current }}"
cd tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/commando.rb
git commit -m "Update commando to ${VERSION}"
git push
- name: Bump version and push
run: |
jq '.version = "${{ steps.version.outputs.next }}"' package.json > package.json.tmp
mv package.json.tmp package.json
git add package.json
git commit -m "chore: bump version to ${{ steps.version.outputs.next }}"
git push