Repository navigation
85 lines (77 loc) · 2.88 KB
/
Copy pathcreate-cli-release.yml
File metadata and controls
85 lines (77 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Create CLI Release
on:
workflow_call:
inputs:
isStableCandidate:
type: boolean
description: Is this a stable/prod candidate?
required: true
default: false
jobs:
get-version-channel:
runs-on: ubuntu-latest
outputs:
channel: ${{ steps.getVersion.outputs.channel }}
version: ${{ steps.getVersion.outputs.version }}
# final check to ensure package.json doesn't have a dist tag, ex: '-beta'
isStableRelease: ${{ fromJSON(inputs.isStableCandidate) && !steps.getVersion.outputs.channel }}
steps:
- uses: actions/checkout@v7
- id: getVersion
uses: ./.github/actions/get-version-and-channel/
with:
path: './package.json'
publish-npm:
needs: [get-version-channel]
# if NOT isStableCandidate confirm dist tag is in package.json version
if: fromJSON(needs.get-version-channel.outputs.isStableRelease) || (!fromJSON(inputs.isStableCandidate) && !!needs.get-version-channel.outputs.channel)
# pub-hk-ubuntu-22.04- due to IP allow list issues with public repos: https://salesforce.quip.com/bu6UA0KImOxJ
runs-on: pub-hk-ubuntu-22.04-small
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22.x
uses: actions/setup-node@v7
with:
node-version: 22.x
cache: npm
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- name: Update npm for trusted publishing
run: npm install -g npm@latest
- name: Publish to NPM
run: |
PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version)")
PACKAGE_NAME=$(node -e "console.log(require('./package.json').name)")
if npm view $PACKAGE_NAME@$PACKAGE_VERSION version &>/dev/null; then
echo "Version $PACKAGE_VERSION already published to npm, skipping"
exit 0
fi
if ${{ fromJSON(needs.get-version-channel.outputs.isStableRelease) }}
then
npm publish
else
npm publish --tag ${{ needs.get-version-channel.outputs.channel || 'beta' }}
fi
shell: bash
pack-upload:
needs: [publish-npm]
uses: ./.github/workflows/pack-upload.yml
secrets: inherit
promote:
needs: [get-version-channel, pack-upload]
if: needs.pack-upload.result == 'success'
uses: ./.github/workflows/promote-release.yml
with:
version: ${{ needs.get-version-channel.outputs.version }}
isStableRelease: ${{ fromJSON(needs.get-version-channel.outputs.isStableRelease) }}
channel: ${{ needs.get-version-channel.outputs.channel }}
secrets: inherit
publish-docs:
needs: [get-version-channel, promote]
uses: ./.github/workflows/devcenter-doc-update.yml
with:
isStableRelease: ${{ fromJSON(inputs.isStableCandidate) }}
secrets: inherit