Skip to content

Release

Release #6

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
bump:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
id-token: write
jobs:
ci:
name: Lint, Typecheck, Test
runs-on: macos-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: 20
- run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Test
run: npx vitest --run
create-tag:
name: Bump & Tag
needs: ci
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump.outputs.version }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v6
with:
node-version: 20
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version and tag
id: bump
run: |
npm version ${{ inputs.bump }} --no-git-tag-version
VERSION=$(node -p "require('./package.json').version")
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
git add package.json package-lock.json
git commit -m "chore: bump version to v${VERSION}"
git tag "v${VERSION}"
git push
git push --tags
publish:
name: Publish to npm
needs: [ci, create-tag]
if: always() && needs.ci.result == 'success' && (needs.create-tag.result == 'success' || needs.create-tag.result == 'skipped')
runs-on: ubuntu-latest
environment: npm
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v5
with:
ref: ${{ needs.create-tag.outputs.version && format('v{0}', needs.create-tag.outputs.version) || github.ref }}
- uses: actions/setup-node@v6
with:
node-version: 20
registry-url: https://registry.npmjs.org
- run: npm ci
- name: Build
run: npm run build
- name: Publish
run: npm publish --provenance --access public
github-release:
name: GitHub Release
needs: [publish, create-tag]
if: always() && needs.publish.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.create-tag.outputs.version && format('v{0}', needs.create-tag.outputs.version) || github.ref_name }}
generate_release_notes: true
update-homebrew:
name: Update Homebrew formula
needs: [publish, create-tag]
if: always() && needs.publish.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Get version
id: ver
run: |
VERSION="${{ needs.create-tag.outputs.version }}"
if [ -z "$VERSION" ]; then
VERSION="${GITHUB_REF_NAME#v}"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Download tarball and compute sha256
id: sha
run: |
URL="https://registry.npmjs.org/xcodebazelmcp/-/xcodebazelmcp-${{ steps.ver.outputs.version }}.tgz"
for i in 1 2 3 4 5; do
SHA=$(curl -sL "$URL" | shasum -a 256 | awk '{print $1}')
[ -n "$SHA" ] && break
sleep 10
done
echo "sha256=${SHA}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v5
with:
repository: XcodeBazelMCP/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Update formula
run: |
sed -i 's|url ".*"|url "https://registry.npmjs.org/xcodebazelmcp/-/xcodebazelmcp-${{ steps.ver.outputs.version }}.tgz"|' Formula/xcodebazelmcp.rb
sed -i 's|sha256 ".*"|sha256 "${{ steps.sha.outputs.sha256 }}"|' Formula/xcodebazelmcp.rb
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/xcodebazelmcp.rb
git commit -m "Update xcodebazelmcp to ${{ steps.ver.outputs.version }}"
git push