Skip to content

Create Release

Create Release #2

Workflow file for this run

name: Create Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.0.0)'
required: true
type: string
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
mkdir -p dist/ai-usage-${{ matrix.goos }}-${{ matrix.goarch }}
go build -ldflags="-s -w" -o dist/ai-usage-${{ matrix.goos }}-${{ matrix.goarch }}/ai-usage ./cmd/ai-usage
cp config.example.yaml dist/ai-usage-${{ matrix.goos }}-${{ matrix.goarch }}/
- name: Create archive
working-directory: dist
run: |
tar -czvf ai-usage-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz ai-usage-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ai-usage-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/ai-usage-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Calculate SHA256
id: sha256
run: |
echo "macos_arm64=$(sha256sum dist/ai-usage-macos-arm64.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "macos_amd64=$(sha256sum dist/ai-usage-macos-amd64.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "linux_arm64=$(sha256sum dist/ai-usage-linux-arm64.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "linux_amd64=$(sha256sum dist/ai-usage-linux-amd64.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
name: Release ${{ inputs.version }}
files: dist/*.tar.gz
generate_release_notes: true
- name: Generate App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: saaskit-dev
repositories: homebrew-tap
- name: Update Homebrew Tap
run: |
git clone https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/saaskit-dev/homebrew-tap.git tap-repo
cd tap-repo
# Update formula
sed -i 's/VERSION_PLACEHOLDER/${{ inputs.version }}/g' Formula/ai-usage.rb
sed -i 's/SHA256_MACOS_ARM64_PLACEHOLDER/${{ steps.sha256.outputs.macos_arm64 }}/g' Formula/ai-usage.rb
sed -i 's/SHA256_MACOS_AMD64_PLACEHOLDER/${{ steps.sha256.outputs.macos_amd64 }}/g' Formula/ai-usage.rb
sed -i 's/SHA256_LINUX_ARM64_PLACEHOLDER/${{ steps.sha256.outputs.linux_arm64 }}/g' Formula/ai-usage.rb
sed -i 's/SHA256_LINUX_AMD64_PLACEHOLDER/${{ steps.sha256.outputs.linux_amd64 }}/g' Formula/ai-usage.rb
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/ai-usage.rb
git commit -m "bump: ai-usage ${{ inputs.version }}" || echo "No changes to commit"
git push
continue-on-error: true
- name: Manual tap update reminder
if: failure()
run: |
echo "::warning::Failed to auto-update homebrew tap. Please update manually:"
echo " 1. Clone homebrew-tap repo"
echo " 2. Update Formula/ai-usage.rb with:"
echo " - version: ${{ inputs.version }}"
echo " - SHA256s from the release artifacts"