Skip to content

Commit 0de51fd

Browse files
authored
chore: try 2fa publish (#14)
1 parent 37b59a9 commit 0de51fd

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ permissions:
4343
jobs:
4444
release:
4545
name: Release
46+
environment: npm
4647
permissions:
4748
contents: write
4849
# To publish packages with provenance
@@ -67,13 +68,33 @@ jobs:
6768

6869
- name: Run Test
6970
run: pnpm run test
70-
71+
- name: Obtain OIDC token
72+
id: oidc
73+
run: |
74+
token=$(curl --fail -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
75+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=cfa.rspack.dev" | jq -r '.value')
76+
echo "::add-mask::${token}"
77+
echo "token=${token}" >> $GITHUB_OUTPUT
78+
shell: bash
79+
- name: Obtain GitHub credentials
80+
id: github_creds
81+
run: |
82+
token=$(curl --fail "https://cfa.rspack.dev/api/request/${{ secrets.CFA_PROJECT_ID }}/github/credentials" \
83+
-X POST \
84+
-H "Content-Type: application/json" \
85+
-H "Authorization: bearer ${{ secrets.CFA_SECRET }}" \
86+
--data "{\"token\":\"${{ steps.oidc.outputs.token }}\"}" | jq -r '.GITHUB_TOKEN')
87+
echo "::add-mask::${token}"
88+
echo "token=${token}" >> $GITHUB_OUTPUT
89+
shell: bash
7190
- name: Try release to npm
7291
run: pnpm run release
7392
env:
7493
DRY_RUN: ${{ inputs.dry_run }}
7594
TAG: ${{ inputs.tag }}
7695
VERSION: ${{ inputs.version }}
96+
GITHUB_TOKEN: ${{ steps.github_creds.outputs.token }}
97+
GITHUB_OIDC_TOKEN: ${{ steps.oidc.outputs.token }}
7798
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
7899

79100

0 commit comments

Comments
 (0)