Skip to content
This repository was archived by the owner on Jul 10, 2026. It is now read-only.

Commit 42e51a0

Browse files
ci: configure npm OIDC publishing workflow
1 parent 1cade05 commit 42e51a0

1 file changed

Lines changed: 34 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Production Release
22

33
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: 'Version from package.json (e.g., 1.0.0 or 1.0.0-beta.1). Do NOT include the "v" prefix.'
8+
required: false
9+
type: string
410
workflow_dispatch:
511
inputs:
612
version:
@@ -14,16 +20,17 @@ concurrency:
1420

1521
jobs:
1622
# ══════════════════════════════════════════════════════════════════════════════
17-
# PRODUCTION RELEASE JOB
23+
# RELEASE JOB
1824
# ══════════════════════════════════════════════════════════════════════════════
1925
release:
2026
name: Release
21-
environment: Production
27+
environment: Publisher
2228
runs-on: ubuntu-latest-m
2329
timeout-minutes: 60
24-
if: github.ref == 'refs/heads/main'
30+
if: github.event_name == 'workflow_call' || github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.release.draft == false)
2531
permissions:
2632
contents: write # Required to create and push tags
33+
id-token: write # Required for npm OIDC trusted publishing
2734

2835
env:
2936
PROJECT_NAME: '@defi-wonderland/aztec-standards'
@@ -44,11 +51,16 @@ jobs:
4451
# TODO: Automate changing package.json version from the workflow input
4552
# (e.g., open a PR or push a signed commit) so manual edits are not required.
4653
- name: Validate input version matches package.json
54+
if: github.ref == 'refs/heads/main'
4755
run: |
48-
INPUT_VERSION="${{ github.event.inputs.version }}"
56+
INPUT_VERSION="${{ inputs.version || github.event.inputs.version }}"
4957
PKG_VERSION=$(node -p "require('./package.json').version")
5058
echo "Input version: $INPUT_VERSION"
5159
echo "package.json version: $PKG_VERSION"
60+
if [ -z "$INPUT_VERSION" ]; then
61+
echo "::error::Input version is required for stable releases from main. Re-run with the matching version (no 'v' prefix)."
62+
exit 1
63+
fi
5264
if [ "$INPUT_VERSION" != "$PKG_VERSION" ]; then
5365
echo "::error::Input version ($INPUT_VERSION) does not match package.json version ($PKG_VERSION). Update package.json or re-run with the matching version (no 'v' prefix)."
5466
exit 1
@@ -63,12 +75,26 @@ jobs:
6375
node-version: '22'
6476
registry-url: 'https://registry.npmjs.org'
6577

66-
- name: Publish to NPM
67-
run: cd export/${{ env.PROJECT_NAME }} && npm publish --access public --tag latest
68-
env:
69-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
78+
- name: Update npm (for OIDC support)
79+
run: npm install -g npm@11.16.0
80+
81+
- name: Update version (dev branch)
82+
if: github.ref == 'refs/heads/dev'
83+
run: npm version --new-version "0.0.0-snapshot.${GITHUB_SHA::8}" --no-git-tag-version
84+
working-directory: export/${{ env.PROJECT_NAME }}
85+
86+
- name: Publish snapshot (dev branch)
87+
if: github.ref == 'refs/heads/dev'
88+
run: npm publish --access public --tag snapshot
89+
working-directory: export/${{ env.PROJECT_NAME }}
90+
91+
- name: Publish stable (main branch or release)
92+
if: github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/release-') && github.event.release.target_commitish == 'main')
93+
run: npm publish --access public
94+
working-directory: export/${{ env.PROJECT_NAME }}
7095

7196
- name: Create GitHub Release Tag (adds 'v' prefix to input)
97+
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
7298
run: |
7399
TAG_NAME="v${{ github.event.inputs.version }}"
74100
# Check if tag already exists

0 commit comments

Comments
 (0)