-
Notifications
You must be signed in to change notification settings - Fork 0
ci: manual OIDC release, drop semantic-release #7
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
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 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,19 +1,81 @@ | ||||||||||||||||||||
| name: Release | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # 手动触发发布,通过 npm OIDC trusted publishing 发布(无需 NPM_TOKEN) | ||||||||||||||||||||
| on: | ||||||||||||||||||||
| # 合并后自动发布 | ||||||||||||||||||||
| push: | ||||||||||||||||||||
| branches: [ master ] | ||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||
| inputs: | ||||||||||||||||||||
| version_type: | ||||||||||||||||||||
| description: 'Version bump type' | ||||||||||||||||||||
| required: true | ||||||||||||||||||||
| default: 'patch' | ||||||||||||||||||||
| type: choice | ||||||||||||||||||||
| options: | ||||||||||||||||||||
| - patch | ||||||||||||||||||||
| - minor | ||||||||||||||||||||
| - major | ||||||||||||||||||||
| dry_run: | ||||||||||||||||||||
| description: 'Dry run (do not publish or push)' | ||||||||||||||||||||
| required: false | ||||||||||||||||||||
| default: false | ||||||||||||||||||||
| type: boolean | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # 手动发布 | ||||||||||||||||||||
| workflow_dispatch: {} | ||||||||||||||||||||
| permissions: | ||||||||||||||||||||
| contents: write # push the version bump commit + tag, create the GitHub release | ||||||||||||||||||||
| id-token: write # npm OIDC trusted publishing | ||||||||||||||||||||
|
|
||||||||||||||||||||
| jobs: | ||||||||||||||||||||
| release: | ||||||||||||||||||||
| name: Node.js | ||||||||||||||||||||
| uses: artusjs/github-actions/.github/workflows/node-release.yml@v1 | ||||||||||||||||||||
| secrets: | ||||||||||||||||||||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||||||||||||||||||
| GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | ||||||||||||||||||||
| with: | ||||||||||||||||||||
| checkTest: false | ||||||||||||||||||||
| name: Release | ||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||
| steps: | ||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||
| with: | ||||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Setup Node.js | ||||||||||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||||||||||
| with: | ||||||||||||||||||||
| node-version: 20 | ||||||||||||||||||||
| registry-url: 'https://registry.npmjs.org' | ||||||||||||||||||||
|
Comment on lines
+36
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Remove Setting Since you are relying on npm's native OIDC trusted publishing (which generates its own token via the OIDC ♻️ Proposed fix - name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- registry-url: 'https://registry.npmjs.org'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| # OIDC trusted publishing requires npm >= 11.5.1 | ||||||||||||||||||||
| - name: Upgrade npm | ||||||||||||||||||||
| run: npm install -g npm@latest | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||
| run: npm i --no-package-lock --no-fund | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Test | ||||||||||||||||||||
| run: npm test | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Configure Git | ||||||||||||||||||||
| run: | | ||||||||||||||||||||
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||
| git config --local user.name "github-actions[bot]" | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Version bump | ||||||||||||||||||||
| id: bump | ||||||||||||||||||||
| run: | | ||||||||||||||||||||
| npm version ${{ github.event.inputs.version_type }} -m "Release v%s" | ||||||||||||||||||||
| echo "tag=v$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||
|
Comment on lines
+59
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Prevent template injection by using environment variables. Directly interpolating GitHub contexts into run scripts can lead to code injection. Although 🛡️ Proposed fix - name: Version bump
id: bump
+ env:
+ VERSION_TYPE: ${{ inputs.version_type }}
run: |
- npm version ${{ github.event.inputs.version_type }} -m "Release v%s"
+ npm version "$VERSION_TYPE" -m "Release v%s"
echo "tag=v$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.26.1)[error] 61-61: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Publish (dry run) | ||||||||||||||||||||
| if: ${{ github.event.inputs.dry_run == 'true' }} | ||||||||||||||||||||
| run: npm publish --provenance --dry-run | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Publish before pushing: if publish fails, nothing is pushed and the | ||||||||||||||||||||
| # run can be retried cleanly without a double version bump. | ||||||||||||||||||||
| - name: Publish | ||||||||||||||||||||
| if: ${{ github.event.inputs.dry_run != 'true' }} | ||||||||||||||||||||
| run: npm publish --provenance | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Push commit and tag | ||||||||||||||||||||
| if: ${{ github.event.inputs.dry_run != 'true' }} | ||||||||||||||||||||
| run: git push origin HEAD --follow-tags | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - name: Create GitHub Release | ||||||||||||||||||||
| if: ${{ github.event.inputs.dry_run != 'true' }} | ||||||||||||||||||||
| run: gh release create "${{ steps.bump.outputs.tag }}" --verify-tag --generate-notes | ||||||||||||||||||||
| env: | ||||||||||||||||||||
| GITHUB_TOKEN: ${{ github.token }} | ||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.