-
-
Notifications
You must be signed in to change notification settings - Fork 1
Add publishing workflow with OIDC provenance #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
13c0108
f5b9b1e
3bbbc4c
4c38948
d226cc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,132 @@ | ||||||||||
| name: Publish | ||||||||||
|
|
||||||||||
| on: | ||||||||||
| workflow_dispatch: | ||||||||||
| inputs: | ||||||||||
| bump: | ||||||||||
| description: "Version bump type" | ||||||||||
| required: true | ||||||||||
| type: choice | ||||||||||
| options: | ||||||||||
| - patch | ||||||||||
| - minor | ||||||||||
| - major | ||||||||||
| - prepatch | ||||||||||
| - preminor | ||||||||||
| - premajor | ||||||||||
| - prerelease | ||||||||||
| preid: | ||||||||||
| description: | ||||||||||
| "Prerelease identifier (alpha, beta, rc). Only used with pre* bumps." | ||||||||||
| required: false | ||||||||||
| type: string | ||||||||||
| dry_run: | ||||||||||
| description: "Dry run — skip publish, push, and release" | ||||||||||
| required: false | ||||||||||
| type: boolean | ||||||||||
| default: false | ||||||||||
|
|
||||||||||
| concurrency: | ||||||||||
| group: publish | ||||||||||
| cancel-in-progress: false | ||||||||||
|
|
||||||||||
| jobs: | ||||||||||
| checks: | ||||||||||
| if: github.ref == 'refs/heads/main' | ||||||||||
| uses: ./.github/workflows/checks.yml | ||||||||||
|
|
||||||||||
| publish: | ||||||||||
| if: github.ref == 'refs/heads/main' | ||||||||||
| needs: checks | ||||||||||
| runs-on: ubuntu-latest | ||||||||||
| # Authentication is handled via OIDC trusted publishing (id-token), | ||||||||||
| # so no NPM_TOKEN secret is needed. | ||||||||||
| permissions: | ||||||||||
| contents: write | ||||||||||
| id-token: write | ||||||||||
|
|
||||||||||
| steps: | ||||||||||
| - uses: actions/checkout@v4 | ||||||||||
|
|
||||||||||
| - name: Setup Node.js | ||||||||||
| uses: actions/setup-node@v4 | ||||||||||
| with: | ||||||||||
| node-version: 24 | ||||||||||
| registry-url: "https://registry.npmjs.org" | ||||||||||
|
|
||||||||||
| - name: Enable corepack | ||||||||||
| run: corepack enable pnpm | ||||||||||
|
|
||||||||||
| - name: Install dependencies | ||||||||||
| run: pnpm install --frozen-lockfile | ||||||||||
|
|
||||||||||
| - name: Build | ||||||||||
| run: pnpm build | ||||||||||
|
|
||||||||||
| - name: Configure git | ||||||||||
| run: | | ||||||||||
| git config user.name "github-actions[bot]" | ||||||||||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||||||||||
|
|
||||||||||
| - name: Bump version | ||||||||||
| id: version | ||||||||||
| env: | ||||||||||
| BUMP: ${{ inputs.bump }} | ||||||||||
| PREID: ${{ inputs.preid }} | ||||||||||
| run: | | ||||||||||
| ARGS=("$BUMP") | ||||||||||
| if [[ "$BUMP" == pre* && -n "$PREID" ]]; then | ||||||||||
| ARGS+=(--preid "$PREID") | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| npm version "${ARGS[@]}" --git-tag-version true | ||||||||||
|
|
||||||||||
| VERSION=$(node -p "require('./package.json').version") | ||||||||||
| TAG="v${VERSION}" | ||||||||||
|
|
||||||||||
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | ||||||||||
| echo "tag=${TAG}" >> $GITHUB_OUTPUT | ||||||||||
|
|
||||||||||
| if [[ "$VERSION" == *-* ]]; then | ||||||||||
| echo "dist_tag=next" >> $GITHUB_OUTPUT | ||||||||||
| echo "prerelease=true" >> $GITHUB_OUTPUT | ||||||||||
| else | ||||||||||
| echo "dist_tag=latest" >> $GITHUB_OUTPUT | ||||||||||
| echo "prerelease=false" >> $GITHUB_OUTPUT | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| - name: Publish summary | ||||||||||
| run: | | ||||||||||
| echo "### Publish Summary" >> $GITHUB_STEP_SUMMARY | ||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||
| echo "- **Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | ||||||||||
| echo "- **Tag:** ${{ steps.version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY | ||||||||||
| echo "- **Dist tag:** ${{ steps.version.outputs.dist_tag }}" >> $GITHUB_STEP_SUMMARY | ||||||||||
| echo "- **Prerelease:** ${{ steps.version.outputs.prerelease }}" >> $GITHUB_STEP_SUMMARY | ||||||||||
| echo "- **Dry run:** ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY | ||||||||||
|
|
||||||||||
| # Publish before push: npm publish is not retryable (same version | ||||||||||
| # can't be published twice), while git push is idempotent. If push | ||||||||||
| # fails after a successful publish, it can simply be retried manually. | ||||||||||
| - name: Publish to npm | ||||||||||
| if: ${{ inputs.dry_run == false }} | ||||||||||
|
||||||||||
| if: ${{ inputs.dry_run == false }} | |
| if: ${{ inputs.dry_run == false }} | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
Uh oh!
There was an error while loading. Please reload this page.