Skip to content

Commit ea85684

Browse files
authored
ci: use npm trusted publishing instead of CFA (#160)
1 parent 115f85f commit ea85684

File tree

6 files changed

+9
-543
lines changed

6 files changed

+9
-543
lines changed

.github/workflows/publish-npm.yml

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,24 @@ jobs:
1616
environment: npm
1717
permissions:
1818
contents: write # for creating new release
19-
id-token: write # for CFA
19+
id-token: write # for publishing releases
2020
steps:
2121
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2222
- name: "Use Node.js ${{ matrix.node-version }}"
2323
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
2424
with:
25-
node-version: "20.16.0"
25+
node-version: "20.17.0"
26+
- name: Update npm to version that supports trusted publishing
27+
run: npm install -g npm@^11.5.1
2628
- name: Update Version
2729
run: node script/update-version.js ${{ github.ref_name }}
2830
- name: Confirm Version Updated
2931
run: node -e "if (require('./package.json').version === '0.0.0-development') process.exit(1)"
3032
- name: Install Dependencies
3133
run: npm ci
32-
- name: Obtain OIDC token
33-
id: oidc
34-
run: |
35-
token=$(curl --fail -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
36-
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=continuousauth.dev" | jq -r '.value')
37-
echo "::add-mask::${token}"
38-
echo "token=${token}" >> $GITHUB_OUTPUT
39-
- name: Obtain GitHub credentials
40-
id: github_creds
41-
run: |
42-
token=$(curl --fail "https://continuousauth.dev/api/request/${{ secrets.CFA_PROJECT_ID }}/github/credentials" \
43-
-X POST \
44-
-H "Content-Type: application/json" \
45-
-H "Authorization: bearer ${{ secrets.CFA_SECRET }}" \
46-
--data "{\"token\":\"${{ steps.oidc.outputs.token }}\"}" | jq -r '.GITHUB_TOKEN')
47-
echo "::add-mask::${token}"
48-
echo "token=${token}" >> $GITHUB_OUTPUT
49-
- name: Set NPM Credentials
50-
run: echo //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} > ~/.npmrc
51-
- name: Check NPM Credentials
52-
run: npm whoami
53-
- name: CFA Publish
54-
timeout-minutes: 60
55-
env:
56-
CFA_PROJECT_ID: ${{ secrets.CFA_PROJECT_ID }}
57-
CFA_SECRET: ${{ secrets.CFA_SECRET }}
58-
GITHUB_OIDC_TOKEN: ${{ steps.oidc.outputs.token }}
59-
run: node script/publish.js
34+
- name: Publish to npm
35+
run: npm publish
6036
- name: Create Release
6137
env:
62-
GITHUB_TOKEN: ${{ steps.github_creds.outputs.token }}
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6339
run: gh release create ${{ github.ref_name }} -t ${{ github.ref_name }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2626
with:
2727
token: ${{ steps.generate-token.outputs.token }}
28-
# Tag here, the publish-npm.yml workflow will trigger on the new tag and do the CFA publish
28+
# Tag here, the publish-npm.yml workflow will trigger on the new tag and do the publish
2929
- name: Push New Tag
3030
run: |
3131
git tag ${{ github.event.inputs.version }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
matrix:
2929
node-version:
30-
- '20.16.0'
30+
- '20.17.0'
3131
- '18.20.4'
3232
- '16.20.2'
3333
- '14.21.3'

0 commit comments

Comments
 (0)