Repository navigation
release #3
This file contains hidden or 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 | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| verify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - run: npm install | |
| - run: npm run typecheck | |
| - run: npm test | |
| - name: check tag matches package.json version | |
| if: github.event_name == 'release' | |
| run: | | |
| pkg_version=$(node -p "require('./package.json').version") | |
| tag_version="${GITHUB_REF_NAME#v}" | |
| if [ "$pkg_version" != "$tag_version" ]; then | |
| echo "::error::Release tag ($tag_version) does not match package.json version ($pkg_version)." | |
| exit 1 | |
| fi | |
| publish-npm: | |
| needs: verify | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - run: npm install | |
| - name: check if version already on npm | |
| id: pubcheck | |
| run: | | |
| name=$(node -p "require('./package.json').name") | |
| version=$(node -p "require('./package.json').version") | |
| if npm view "${name}@${version}" version --registry=https://registry.npmjs.org > /dev/null 2>&1; then | |
| echo "already=true" >> "$GITHUB_OUTPUT" | |
| echo "::notice::${name}@${version} already on npm — skipping publish." | |
| else | |
| echo "already=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: publish to npm | |
| if: steps.pubcheck.outputs.already != 'true' | |
| run: npm publish --access public --provenance | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| publish-clawhub: | |
| needs: verify | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: publish to ClawHub | |
| env: | |
| CLAWHUB_TOKEN: ${{ secrets.CLAWHUB_TOKEN }} | |
| run: | | |
| if [ -z "$CLAWHUB_TOKEN" ]; then | |
| echo "::warning::CLAWHUB_TOKEN not set — skipping ClawHub publish." | |
| exit 0 | |
| fi | |
| npx -y clawhub login --token "$CLAWHUB_TOKEN" --no-browser | |
| npx -y clawhub package publish . \ | |
| --source-repo "${GITHUB_REPOSITORY}" \ | |
| --source-ref "${GITHUB_REF_NAME}" \ | |
| --source-commit "${GITHUB_SHA}" |