Skip to content

Release

Release #63

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Specific version (leave empty for auto-detect)'
required: false
type: string
force:
description: 'Force rebuild even if release exists'
required: false
type: boolean
default: false
permissions:
contents: write
jobs:
check:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.detect.outputs.versions }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 'latest'
- run: npm ci
- name: Detect new versions
id: detect
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -n "${{ inputs.version }}" ]; then
echo "versions=[\"${{ inputs.version }}\"]" >> "$GITHUB_OUTPUT"
echo "Manual: ${{ inputs.version }}"
else
EXISTING=$(gh release list --limit 200 --json tagName \
--jq '[.[].tagName | ltrimstr("v")]' 2>/dev/null || echo '[]')
VERSIONS=$(node scripts/check-new-versions.mjs \
--existing "$EXISTING" --json)
echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT"
fi
build:
needs: check
if: needs.check.outputs.versions != '[]' && needs.check.outputs.versions != ''
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.check.outputs.versions) }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 'latest'
- run: npm ci
- name: Build all packages
run: |
node scripts/fetch-and-process.mjs \
--version "${{ matrix.version }}" \
--output "./dist/${{ matrix.version }}"
- name: Verify main package
run: |
DIST="./dist/${{ matrix.version }}"
VERIFY=/tmp/verify-main
# Copy main package to temp dir for verification
cp -r "$DIST/main" "$VERIFY"
# Simulate postinstall with linux-x64 platform package
cp "$DIST/packages/linux-x64/cli.js" "$VERIFY/cli.js"
cp -r "$DIST/packages/linux-x64/vendor" "$VERIFY/vendor"
cd "$VERIFY"
npm install --omit=optional --no-audit --no-fund
node cli.js --version
node cli.js --help | head -5
rm -rf "$VERIFY"
- name: Package tarballs
run: |
DIST="./dist/${{ matrix.version }}"
VERSION="${{ matrix.version }}"
mkdir -p ./artifacts
# Main package
mkdir -p /tmp/pkg-wrap/package
cp -r "$DIST/main"/* /tmp/pkg-wrap/package/
tar czf "./artifacts/cometix-claude-code-${VERSION}.tgz" -C /tmp/pkg-wrap package/
rm -rf /tmp/pkg-wrap
# Platform packages
for platform in darwin-arm64 darwin-x64 linux-arm64 linux-x64 linux-arm64-musl linux-x64-musl win32-arm64 win32-x64 android-arm64; do
if [ -d "$DIST/packages/$platform" ]; then
mkdir -p /tmp/pkg-wrap/package
cp -r "$DIST/packages/$platform"/* /tmp/pkg-wrap/package/
tar czf "./artifacts/cometix-claude-code-${platform}-${VERSION}.tgz" -C /tmp/pkg-wrap package/
rm -rf /tmp/pkg-wrap
fi
done
ls -lh ./artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: packages-${{ matrix.version }}
path: artifacts/
release:
needs: [check, build]
if: needs.check.outputs.versions != '[]' && needs.check.outputs.versions != ''
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.check.outputs.versions) }}
steps:
- uses: actions/checkout@v6
with:
ref: master
- name: Download artifacts
uses: actions/download-artifact@v6
with:
name: packages-${{ matrix.version }}
path: artifacts/
- name: Sync CHANGELOG
run: |
curl -sL "https://raw.githubusercontent.com/anthropics/claude-code/main/CHANGELOG.md" \
-o CHANGELOG.md
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md
git diff --cached --quiet || (git commit -m "changelog: sync v${{ matrix.version }}" && git push)
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ matrix.version }}"
if gh release view "v${VERSION}" --repo "$GITHUB_REPOSITORY" &>/dev/null; then
if [ "${{ inputs.force }}" = "true" ]; then
gh release delete "v${VERSION}" --repo "$GITHUB_REPOSITORY" --yes
else
echo "Release v${VERSION} already exists, skipping"
exit 0
fi
fi
BODY=$(gh api "repos/anthropics/claude-code/releases/tags/v${VERSION}" --jq '.body' 2>/dev/null || echo "")
gh release create "v${VERSION}" \
--repo "$GITHUB_REPOSITORY" \
--title "v${VERSION}" \
--notes "$BODY" \
artifacts/*
publish:
needs: [check, build]
if: needs.check.outputs.versions != '[]' && needs.check.outputs.versions != ''
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.check.outputs.versions) }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v6
with:
name: packages-${{ matrix.version }}
path: artifacts/
- uses: actions/setup-node@v6
with:
node-version: 'latest'
registry-url: 'https://registry.npmjs.org'
scope: '@cometix'
- name: Publish platform packages
run: |
VERSION="${{ matrix.version }}"
for tgz in ./artifacts/cometix-claude-code-*-${VERSION}.tgz; do
[ -f "$tgz" ] || continue
PKG=$(basename "$tgz" | sed "s/-${VERSION}.tgz//" | sed 's/^cometix-/@cometix\//')
echo "Publishing ${PKG}@${VERSION}..."
if npm view "${PKG}@${VERSION}" version &>/dev/null 2>&1; then
echo " Already published, skipping"
else
npx npm@latest publish "$tgz" --access public --provenance || echo " Failed (may need package init)"
fi
done
- name: Publish main package
run: |
VERSION="${{ matrix.version }}"
TARBALL="./artifacts/cometix-claude-code-${VERSION}.tgz"
if [ ! -f "$TARBALL" ]; then
echo "Tarball not found: $TARBALL"
ls -la ./artifacts/
exit 1
fi
if npm view "@cometix/claude-code@${VERSION}" version &>/dev/null 2>&1; then
echo "Already published, skipping"
else
npx npm@latest publish "$TARBALL" --access public --provenance
echo "Published @cometix/claude-code@${VERSION}"
fi