-
Notifications
You must be signed in to change notification settings - Fork 0
ci(publish)!: migrate NPM publication to OIDC trusted publishing (#104) #105
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
405a2b5
ci(publish)!: migrate NPM publication to OIDC trusted publishing (#104)
levalleux-ludo 7c0dc30
fix(ci): make alpha publish check out main and stop amending the bump…
levalleux-ludo b91d2d0
fix(ci): pin npm to 11.5.1 instead of @latest
levalleux-ludo 056a303
fix(ci): drop redundant actions/cache step
levalleux-ludo add68af
fix(ci): serialize publish runs with a concurrency group
levalleux-ludo 31440db
fix(ci): tie publish run to the triggering commit instead of latest main
levalleux-ludo 59e7777
fix(ci): pin default node-version to 22.14.0
levalleux-ludo ecd6901
fix(ci): set upstream on the recreated main branch
levalleux-ludo c25b649
fix(ci): configure git author for both publish paths
levalleux-ludo 873cb2e
fix(ci): lint as a non-mutating gate before build/test
levalleux-ludo 7c5c3bc
fix(ci): add scoped prettier --check gate before build/test
levalleux-ludo c66c166
fix(ci): check out github.sha in the reusable workflow
levalleux-ludo b2ab539
docs(ci): correct stale rationale on the alpha push comment
levalleux-ludo 36e18b9
fix(toolchain): align Volta pins with CI/publish toolchain
levalleux-ludo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: "Build and Test" | ||
| description: "Install deps, build and test the Chat SDK (shared by CI and publish workflows)" | ||
| inputs: | ||
| node-version: | ||
| description: "Node.js version" | ||
| required: false | ||
| default: "22" # OIDC requires Node >= 22.14; PR CI uses the same version we publish from | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ inputs.node-version }} | ||
| registry-url: "https://registry.npmjs.org" # writes .npmrc; harmless on PR, used by OIDC on publish | ||
| cache: "npm" | ||
| - name: Upgrade npm (trusted publishing needs >= 11.5.1) | ||
| shell: bash | ||
| run: npm install -g npm@latest | ||
|
levalleux-ludo marked this conversation as resolved.
Outdated
|
||
| - uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.npm | ||
| key: npm-${{ hashFiles('package-lock.json') }} | ||
| restore-keys: npm- | ||
|
levalleux-ludo marked this conversation as resolved.
Outdated
|
||
| - name: Install dependencies | ||
| shell: bash | ||
| run: npm ci | ||
| - name: Build | ||
| shell: bash | ||
| run: npm run build | ||
| - name: Test | ||
| shell: bash | ||
| run: npm run test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,10 @@ | ||
| name: Call reusable workflow - Chat SDK | ||
| name: CI - Chat SDK | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| call-reusable-workflow-PR: | ||
| uses: ./.github/workflows/ci_reusable.yaml | ||
| if: github.event_name == 'pull_request' | ||
| with: | ||
| PUBLISH_NPM: false | ||
| secrets: inherit | ||
| call-reusable-workflow-testing: | ||
| build-test: | ||
| uses: ./.github/workflows/ci_reusable.yaml | ||
| if: github.event_name == 'push' | ||
| with: | ||
| PUBLISH_NPM: true | ||
| secrets: inherit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,60 +1,16 @@ | ||
| name: Build, Test and Publish - Chat SDK | ||
| name: Build and Test - Chat SDK | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| PUBLISH_NPM: | ||
| required: true | ||
| type: boolean | ||
| secrets: | ||
| NPM_TOKEN: | ||
| required: true | ||
|
|
||
| jobs: | ||
| build-test-publish: | ||
| name: Build, Test and Publish | ||
| build-test: | ||
| name: Build and Test | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| PUBLISH_NPM: ${{ inputs.PUBLISH_NPM }} | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
|
levalleux-ludo marked this conversation as resolved.
Outdated
|
||
| - uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: "20" | ||
| registry-url: "https://registry.npmjs.org" | ||
| cache: "npm" | ||
| - name: Cache dependencies | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ~/.npm | ||
| key: npm-${{ hashFiles('package-lock.json') }} | ||
| restore-keys: npm- | ||
| - run: npm ci | ||
| - run: npm run prettier | ||
| - uses: ./.github/actions/build-test # same shared composite as publish.yaml | ||
| - run: npm run prettier # PR-only quality checks (mutate tree; not run on publish) | ||
| - run: npm run lint:fix | ||
|
levalleux-ludo marked this conversation as resolved.
Outdated
|
||
| - run: npm run build | ||
| - run: npm run test | ||
| - name: Set github bot | ||
| run: | | ||
| git config user.name 'github-actions[bot]' | ||
| git config user.email 'github-actions[bot]@users.noreply.github.com' | ||
| - name: "Update to alpha version" | ||
| if: inputs.PUBLISH_NPM | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| run: | | ||
| git reset --hard | ||
| npm version prerelease --preid alpha | ||
| OLD_MSG=$(git log --format=%B -n1) | ||
| git commit --amend -m "$OLD_MSG" -m "[skip ci]" | ||
| git push | ||
| git push --tags | ||
| - name: "Publish to npm" | ||
| if: inputs.PUBLISH_NPM | ||
| run: | | ||
| npm publish --tag alpha | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: Publish - Chat SDK | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
|
levalleux-ludo marked this conversation as resolved.
|
||
| permissions: | ||
| contents: write # push alpha version commit/tag + create GitHub release | ||
| id-token: write # OIDC trusted publishing + provenance | ||
| issues: write # semantic-release release comments | ||
| pull-requests: write # semantic-release release comments | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Build, Test and Publish | ||
| if: ${{ github.ref == 'refs/heads/main' }} | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # semantic-release needs full history | ||
| # persist-credentials defaults true -> alpha `git push` works | ||
| - uses: ./.github/actions/build-test # shared composite: setup-node + npm upgrade + ci + build + test | ||
|
levalleux-ludo marked this conversation as resolved.
|
||
|
|
||
| # ---- alpha: every push to main ---- | ||
| - name: Configure git author | ||
| if: github.event_name == 'push' | ||
| run: | | ||
| git config user.name 'github-actions[bot]' | ||
| git config user.email 'github-actions[bot]@users.noreply.github.com' | ||
|
levalleux-ludo marked this conversation as resolved.
|
||
| - name: Publish alpha to npm | ||
| if: github.event_name == 'push' | ||
| run: | | ||
| git reset --hard | ||
| npm version prerelease --preid alpha | ||
| OLD_MSG=$(git log --format=%B -n1) | ||
| git commit --amend -m "$OLD_MSG" -m "[skip ci]" | ||
| git push | ||
| git push --tags | ||
|
levalleux-ludo marked this conversation as resolved.
Outdated
|
||
| npm publish --tag alpha # tokenless OIDC, provenance automatic | ||
|
|
||
| # ---- latest: on demand (workflow_dispatch) ---- | ||
| - name: Publish latest + GitHub release (semantic-release) | ||
| if: github.event_name == 'workflow_dispatch' | ||
| uses: cycjimmy/semantic-release-action@v4 | ||
| with: | ||
| semantic_version: 25 # bundles @semantic-release/npm >= 13.1 (OIDC) | ||
| extra_plugins: | | ||
| @semantic-release/changelog@6 | ||
| @semantic-release/git@10 | ||
| branches: | | ||
| [ | ||
| 'main' | ||
| ] | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # no NPM_TOKEN — OIDC handles npm auth | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.