88permissions :
99 contents : write
1010 packages : write
11- id-token : write # Required for npm OIDC provenance
11+ id-token : write # Required for npm provenance
1212
1313env :
1414 REGISTRY : ghcr.io
@@ -116,12 +116,11 @@ jobs:
116116 retention-days : 1
117117
118118 publish-npm :
119- name : Publish to npm (OIDC)
119+ name : Publish to npm
120120 needs : assemble-npm
121121 runs-on : ubuntu-latest
122- permissions :
123- contents : read
124- id-token : write # Required for npm OIDC publishing (no NPM_TOKEN needed)
122+ # Only run if NPM_TOKEN secret is configured
123+ if : ${{ vars.NPM_PUBLISH_ENABLED == 'true' }}
125124 steps :
126125 - uses : actions/checkout@v4
127126
@@ -131,44 +130,29 @@ jobs:
131130 node-version : ' 20'
132131 registry-url : ' https://registry.npmjs.org'
133132
134- - name : Upgrade npm for OIDC support
135- run : npm install -g npm@latest
136-
137133 - name : Download npm packages
138134 uses : actions/download-artifact@v4
139135 with :
140136 name : npm-packages
141137 path : packages/
142138
143- - name : OIDC preflight - ensure no auth tokens
144- run : |
145- echo "=== OIDC Preflight ==="
146- # Remove any existing auth tokens to ensure OIDC is used
147- for npmrc in "$NPM_CONFIG_USERCONFIG" ~/.npmrc .npmrc; do
148- if [ -n "$npmrc" ] && [ -f "$npmrc" ]; then
149- echo "Cleaning $npmrc of any existing auth tokens..."
150- sed -i -E '/\/\/registry\.npmjs\.org\/:(_authToken|_auth)\s*=/d' "$npmrc" 2>/dev/null || true
151- sed -i -E '/^\s*(_authToken|_auth)\s*=/d' "$npmrc" 2>/dev/null || true
152- fi
153- done
154-
155- echo "Verifying npm registry connectivity..."
156- npm ping || exit 1
157- echo "Registry: $(npm config get registry)"
158-
159- - name : Publish platform packages with OIDC
139+ - name : Publish platform packages
140+ env :
141+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
160142 run : |
161143 for pkg in packages/ansilust-*/; do
162144 if [ -f "$pkg/package.json" ]; then
163145 echo "Publishing $pkg..."
164146 cd "$pkg"
165- npm publish --provenance --access public
147+ npm publish --provenance --access public || echo "Failed to publish $pkg (may already exist)"
166148 cd - > /dev/null
167149 fi
168150 done
169151
170- - name : Publish meta package with OIDC
171- run : npm publish packages/ansilust/ --provenance --access public
152+ - name : Publish meta package
153+ env :
154+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
155+ run : npm publish packages/ansilust/ --provenance --access public || echo "Failed to publish meta package (may already exist)"
172156
173157 create-release :
174158 name : Create GitHub release
@@ -231,7 +215,8 @@ jobs:
231215 name : Update AUR package
232216 needs : create-release
233217 runs-on : ubuntu-latest
234- if : startsWith(github.ref, 'refs/tags/')
218+ # Only run if AUR_SSH_KEY secret is configured
219+ if : ${{ vars.AUR_PUBLISH_ENABLED == 'true' }}
235220 steps :
236221 - name : Extract version
237222 id : version
@@ -305,10 +290,9 @@ jobs:
305290 with :
306291 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
307292 tags : |
308- type=ref,event=branch
309293 type=semver,pattern={{version}}
310294 type=semver,pattern={{major}}.{{minor}}
311- type=sha
295+ type=raw,value=latest,enable={{is_default_branch}}
312296
313297 - name : Build and push
314298 uses : docker/build-push-action@v5
0 commit comments