Skip to content

Commit 0e81dd8

Browse files
chore: consolidate release for trusted publishing (#3744)
* Consolidate release automation by replacing the old start-release workflows with a unified release.yml flow and update publish workflows to use OIDC/provenance-based npm publishing permissions instead of token-written .npmrc auth * Refine release workflows by moving trigger/permission logic into release.yml, simplifying publish-npm.yml publish/auth steps, and removing now-redundant settings from create-cli-release.yml * Adjust publish-npm.yml release gating logic to correctly handle stable vs prerelease publish behavior while keeping the trusted publishing flow intact
1 parent 665b189 commit 0e81dd8

4 files changed

Lines changed: 48 additions & 49 deletions

File tree

.github/workflows/create-cli-release.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
name: Create CLI Release
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
isStableCandidate:
7-
type: boolean
8-
description: Is this a stable/prod candidate?
9-
required: true
10-
default: false
114
workflow_call:
125
inputs:
136
isStableCandidate:
@@ -16,6 +9,10 @@ on:
169
required: true
1710
default: false
1811

12+
permissions:
13+
contents: read
14+
id-token: write
15+
1916
jobs:
2017
get-version-channel:
2118
runs-on: ubuntu-latest

.github/workflows/publish-npm.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
name: Publish NPM
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
isStableRelease:
7-
type: boolean
8-
description: Is this a stable/prod release?
9-
required: true
10-
default: false
11-
channel:
12-
type: choice
13-
description: If this is a prerelease, is it alpha or beta?
14-
options:
15-
- alpha
16-
- beta
17-
required: false
184
workflow_call:
195
inputs:
206
isStableRelease:
@@ -27,6 +13,10 @@ on:
2713
description: Release channel for prereleases
2814
required: false
2915

16+
permissions:
17+
contents: read
18+
id-token: write
19+
3020
jobs:
3121
publish-npm:
3222
# pub-hk-ubuntu-22.04- due to IP allow list issues with public repos: https://salesforce.quip.com/bu6UA0KImOxJ
@@ -38,9 +28,8 @@ jobs:
3828
with:
3929
node-version: 22.x
4030
cache: npm
31+
registry-url: 'https://registry.npmjs.org'
4132
- run: npm ci
42-
- name: set NPM auth
43-
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISH_KEY }}" > ~/.npmrc
4433
- name: Publish to NPM
4534
run: |
4635
PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version)")
Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
name: Watch and start pre release
1+
name: Release
22

33
on:
4+
release:
5+
# This works for both releases and prereleases https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
6+
types: [published]
47
push:
58
branches:
69
- prerelease/*
10+
workflow_dispatch:
11+
inputs:
12+
isStableCandidate:
13+
type: boolean
14+
description: Is this a stable/prod candidate?
15+
required: true
16+
default: false
17+
18+
permissions:
19+
contents: write
20+
id-token: write
21+
pull-requests: read
722

823
jobs:
24+
# --- Shared: extract version/channel from package.json ---
925
get-version-channel:
10-
# get the version number and release channel name from the package.json
1126
runs-on: ubuntu-latest
1227
outputs:
1328
channel: ${{ steps.getVersion.outputs.channel }}
@@ -19,21 +34,24 @@ jobs:
1934
with:
2035
path: './package.json'
2136

37+
# --- Prerelease only: validate branch + version constraints ---
2238
validate-prerelease:
23-
# validate that the release is on a pre-release branch, that it is a beta or alpha release, and check if it is already on github
24-
needs: [ get-version-channel ]
39+
if: github.event_name == 'push'
40+
needs: [get-version-channel]
2541
runs-on: ubuntu-latest
2642
env:
27-
CHANNEL: ${{ needs.get-version-channel.outputs.channel }}
28-
VERSION: ${{ needs.get-version-channel.outputs.version }}
29-
CURRENT_BRANCH_NAME: ${{ github.ref_name }}
43+
CHANNEL: ${{ needs.get-version-channel.outputs.channel }}
44+
VERSION: ${{ needs.get-version-channel.outputs.version }}
45+
CURRENT_BRANCH_NAME: ${{ github.ref_name }}
3046
steps:
3147
- uses: actions/checkout@v6
3248
- run: npm ci
3349
- run: ./scripts/release/validate-prerelease
3450

51+
# --- Prerelease only: publish git tag ---
3552
publish-github-tag:
36-
needs: [ get-version-channel, validate-prerelease ]
53+
if: github.event_name == 'push'
54+
needs: [get-version-channel, validate-prerelease]
3755
# pub-hk-ubuntu-22.04- due to IP allow list issues with public repos: https://salesforce.quip.com/bu6UA0KImOxJ
3856
runs-on: pub-hk-ubuntu-22.04-small
3957
env:
@@ -53,22 +71,30 @@ jobs:
5371
git tag "${{ env.TAG_NAME }}" -m "${{ env.TAG_NAME }}"
5472
git push origin "${{ env.TAG_NAME }}"
5573
56-
create-prerelease:
57-
needs: [ get-version-channel, validate-prerelease ]
74+
# --- Both paths: orchestrate the full release pipeline ---
75+
create-release:
76+
needs: [get-version-channel, validate-prerelease]
77+
if: |
78+
always() &&
79+
(needs.validate-prerelease.result == 'success' || needs.validate-prerelease.result == 'skipped')
5880
uses: ./.github/workflows/create-cli-release.yml
5981
secrets: inherit
6082
with:
61-
isStableCandidate: ${{ false }}
83+
isStableCandidate: ${{ (github.event_name == 'release' && !contains(github.event.release.tag_name, '-')) || (github.event_name == 'workflow_dispatch' && inputs.isStableCandidate) }}
6284

85+
# --- Prerelease only: post-release smoke tests ---
6386
prerelease-smoke-tests:
64-
needs: [ get-version-channel, create-prerelease ]
87+
if: github.event_name == 'push'
88+
needs: [get-version-channel, create-release]
6589
uses: ./.github/workflows/test-installed-cli.yml
6690
secrets: inherit
6791
with:
6892
version: ${{ needs.get-version-channel.outputs.version }}
6993

94+
# --- Prerelease only: direwolf integration tests ---
7095
prerelease-direwolf-tests:
71-
needs: [ get-version-channel, create-prerelease ]
96+
if: github.event_name == 'push'
97+
needs: [get-version-channel, create-release]
7298
uses: ./.github/workflows/direwolf.yml
7399
secrets: inherit
74100
with:

.github/workflows/start-cli-release.yml

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

0 commit comments

Comments
 (0)