Skip to content

Commit 01fb914

Browse files
committed
Add OIDC to npm
1 parent 092a4ca commit 01fb914

File tree

4 files changed

+20
-38
lines changed

4 files changed

+20
-38
lines changed

.changeset/chilly-ghosts-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions': patch
3+
---
4+
5+
new oidc deploy workflow

.github/workflows/actions/prepare/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ name: Prepare repo
22
runs:
33
using: 'composite'
44
steps:
5-
- uses: actions/setup-node@v3
5+
- uses: actions/setup-node@v4
66
name: Setup node.js and yarn
77
with:
8+
registry-url: 'https://registry.npmjs.org' # Required for OIDC
89
cache: yarn
9-
node-version-file: '.nvmrc'
10+
node-version-file: '.nvmrc' # Must be 20+ to support npm 11.5.1+
1011

1112
- name: Yarn install
1213
run: yarn install --frozen-lockfile

.github/workflows/deploy-rc.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Deploy
33
on:
44
push:
55
branches:
6+
# Stable version branches
67
- 2023-04
78
- 2023-07
89
- 2023-10
@@ -11,40 +12,44 @@ on:
1112
- 2024-07
1213
- 2024-10
1314
- 20[0-9][0-9]-[01][1470]
15+
# RC version branches
16+
- 20[0-9][0-9]-[01][1470]-rc
1417

1518
concurrency: ${{ github.workflow }}-${{ github.ref }}
1619

1720
jobs:
1821
changesets:
1922
name: Deploy
2023
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
id-token: write # Required for OIDC
2127
steps:
2228
- uses: actions/checkout@v3
2329
with:
2430
token: ${{ secrets.SHOPIFY_GH_ACCESS_TOKEN }}
2531

2632
- uses: ./.github/workflows/actions/prepare
2733

34+
- name: Update npm to latest
35+
run: npm install -g npm@latest
36+
2837
- id: changesets
2938
name: Create release Pull Request or publish to NPM
30-
uses: changesets/action@06245a4e0a36c064a573d4150030f5ec548e4fcc # v1.4.10
39+
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
3140
with:
3241
title: Version Packages (${{ github.ref_name }})
33-
publish: yarn run deploy --tag ${{ github.ref_name }}
42+
publish: yarn run deploy --tag ${{ endsWith(github.ref_name, '-rc') && 'rc' || github.ref_name }} # RC publishes as `rc` tag, stable publishes as the version number
3443
createGithubReleases: false
3544
env:
36-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
NPM_TOKEN: '' # Forces OIDC authentication
3746
GITHUB_TOKEN: ${{ secrets.SHOPIFY_GH_ACCESS_TOKEN }}
3847

3948
- name: Set 'latest' NPM dist tag
4049
if: steps.changesets.outputs.published == 'true' && github.ref_name == vars.LATEST_STABLE_VERSION
4150
env:
42-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4351
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
4452
run: |
45-
cat << EOF > "$HOME/.npmrc"
46-
//registry.npmjs.org/:_authToken=$NPM_TOKEN
47-
EOF
4853
for pkg in $(echo "$PUBLISHED_PACKAGES" | jq -r '.[] | @base64'); do
4954
_jq() {
5055
echo ${pkg} | base64 --decode | jq -r ${1}

0 commit comments

Comments
 (0)