Skip to content

Commit 2f6b1cf

Browse files
committed
Update release yaml and consumers to use trusted publishers approach
1 parent 6c5268e commit 2f6b1cf

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed

.github/workflows/actions/publish-npm/action.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,24 @@ inputs:
1414
folder:
1515
default: './'
1616
description: 'A folder containing a package.json file.'
17-
token:
18-
description: 'The NPM authentication token required to publish.'
17+
node-version:
18+
description: 'Node.js version to use when publishing.'
19+
required: false
20+
default: '20'
21+
registry-url:
22+
description: 'Registry URL used for npm publish.'
23+
required: false
24+
default: 'https://registry.npmjs.org'
1925
runs:
2026
using: 'composite'
2127
steps:
22-
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
28+
- name: 🟢 Configure Node for Publish
29+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
2330
with:
24-
node-version: 24.x
31+
node-version: ${{ inputs.node-version }}
32+
registry-url: ${{ inputs.registry-url }}
2533
# Provenance requires npm 9.5.0+
26-
- name: 🟢 Install latest npm
34+
- name: 📦 Install latest npm
2735
run: npm install -g npm@latest
2836
shell: bash
2937
# This ensures the local version of Lerna is installed
@@ -35,20 +43,19 @@ runs:
3543
run: npx lerna@5 bootstrap --include-dependencies --scope ${{ inputs.scope }} --ignore-scripts -- --legacy-peer-deps
3644
shell: bash
3745
working-directory: ${{ inputs.working-directory }}
38-
- name: 🏷️ Update Version
39-
run: npx lerna@5 version ${{ inputs.version }} --yes --exact --no-changelog --no-push --no-git-tag-version --preid=${{ inputs.preid }}
46+
- name: 🏷️ Set Version
47+
run: |
48+
if [ "${{ inputs.preid }}" = "none" ] || [ -z "${{ inputs.preid }}" ]; then
49+
npx lerna@5 version ${{ inputs.version }} --yes --exact --no-changelog --no-push --no-git-tag-version
50+
else
51+
npx lerna@5 version ${{ inputs.version }} --yes --exact --no-changelog --no-push --no-git-tag-version --preid=${{ inputs.preid }}
52+
fi
4053
shell: bash
4154
working-directory: ${{ inputs.working-directory }}
4255
- name: 🏗️ Run Build
4356
run: npm run build
4457
shell: bash
4558
working-directory: ${{ inputs.working-directory }}
46-
- name: 🔑 Prepare NPM Token
47-
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
48-
working-directory: ${{ inputs.working-directory }}
49-
shell: bash
50-
env:
51-
NPM_TOKEN: ${{ inputs.token }}
5259
- name: 🚀 Publish to NPM
5360
run: npm publish ${{ inputs.folder }} --tag ${{ inputs.tag }} --provenance
5461
shell: bash

.github/workflows/release-ionic.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ on:
1414
preid:
1515
description: 'The prerelease identifier used when doing a prerelease.'
1616
type: string
17-
secrets:
18-
NPM_TOKEN:
19-
required: true
17+
18+
permissions:
19+
contents: read
20+
id-token: write
2021

2122
jobs:
2223
release-core:
@@ -30,7 +31,6 @@ jobs:
3031
version: ${{ inputs.version }}
3132
preid: ${{ inputs.preid }}
3233
working-directory: 'core'
33-
token: ${{ secrets.NPM_TOKEN }}
3434
- name: Cache Built @ionic/core
3535
uses: ./.github/workflows/actions/upload-archive
3636
with:
@@ -62,7 +62,6 @@ jobs:
6262
version: ${{ inputs.version }}
6363
preid: ${{ inputs.preid }}
6464
working-directory: 'packages/docs'
65-
token: ${{ secrets.NPM_TOKEN }}
6665

6766
release-angular:
6867
needs: [release-core]
@@ -83,7 +82,6 @@ jobs:
8382
preid: ${{ inputs.preid }}
8483
working-directory: 'packages/angular'
8584
folder: './dist'
86-
token: ${{ secrets.NPM_TOKEN }}
8785
- name: Cache Built @ionic/angular
8886
uses: ./.github/workflows/actions/upload-archive
8987
with:
@@ -109,7 +107,6 @@ jobs:
109107
version: ${{ inputs.version }}
110108
preid: ${{ inputs.preid }}
111109
working-directory: 'packages/react'
112-
token: ${{ secrets.NPM_TOKEN }}
113110
- name: Cache Built @ionic/react
114111
uses: ./.github/workflows/actions/upload-archive
115112
with:
@@ -135,7 +132,6 @@ jobs:
135132
version: ${{ inputs.version }}
136133
preid: ${{ inputs.preid }}
137134
working-directory: 'packages/vue'
138-
token: ${{ secrets.NPM_TOKEN }}
139135
- name: Cache Built @ionic/vue
140136
uses: ./.github/workflows/actions/upload-archive
141137
with:
@@ -162,7 +158,12 @@ jobs:
162158
preid: ${{ inputs.preid }}
163159
working-directory: 'packages/angular-server'
164160
folder: './dist'
165-
token: ${{ secrets.NPM_TOKEN }}
161+
- name: Cache Built @ionic/angular-server
162+
uses: ./.github/workflows/actions/upload-archive
163+
with:
164+
name: ionic-angular-server
165+
output: packages/angular-server/AngularServerBuild.zip
166+
paths: packages/angular-server/dist
166167

167168
release-react-router:
168169
needs: [release-react]
@@ -188,7 +189,6 @@ jobs:
188189
version: ${{ inputs.version }}
189190
preid: ${{ inputs.preid }}
190191
working-directory: 'packages/react-router'
191-
token: ${{ secrets.NPM_TOKEN }}
192192

193193
release-vue-router:
194194
needs: [release-vue]
@@ -214,4 +214,3 @@ jobs:
214214
version: ${{ inputs.version }}
215215
preid: ${{ inputs.preid }}
216216
working-directory: 'packages/vue-router'
217-
token: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,19 @@ on:
2323
- latest
2424
- next
2525
preid:
26-
type: choice
26+
type: string
2727
description: Which prerelease identifier should be used? This is only needed when version is "prepatch", "preminor", "premajor", or "prerelease".
28-
options:
29-
- ''
30-
- alpha
31-
- beta
32-
- rc
33-
- next
3428

3529
jobs:
3630
release-ionic:
3731
permissions:
32+
contents: read
3833
id-token: write
3934
uses: ./.github/workflows/release-ionic.yml
4035
with:
4136
tag: ${{ inputs.tag }}
4237
version: ${{ inputs.version }}
4338
preid: ${{ inputs.preid }}
44-
secrets:
45-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4639

4740
finalize-release:
4841
needs: [release-ionic]

0 commit comments

Comments
 (0)