Skip to content

Publish Package

Publish Package #17

Workflow file for this run

name: Publish Package
on:
workflow_dispatch:
permissions:
id-token: write # Required for OIDC
contents: write # Tag + GitHub Release after a successful publish
jobs:
publish:
if: >-
github.repository == 'WaveSpeedAI/wavespeed-cli' &&
github.event_name == 'workflow_dispatch' &&
github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build --if-present
- run: npm test
- run: npm publish
# The version that just went to npm is the single source of truth:
# tag the exact commit that was published so GitHub never drifts
# behind the registry again. Idempotent — re-runs of the workflow
# for an already-tagged version skip cleanly instead of failing.
- name: Tag and create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="v$(node -p "require('./package.json').version")"
if gh release view "$VERSION" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo "$VERSION already released, skipping"
exit 0
fi
gh release create "$VERSION" \
--repo "$GITHUB_REPOSITORY" \
--target "$GITHUB_SHA" \
--title "$VERSION" \
--generate-notes