Skip to content

Commit 4fa0715

Browse files
ci: merge snapshot and regular release & publish with npm trusted publishers (#7853)
#7771 needs to be merged first. https://lerna.js.org/docs/recipes/oidc-trusted-publishing
1 parent 2e28b9b commit 4fa0715

File tree

2 files changed

+39
-68
lines changed

2 files changed

+39
-68
lines changed

.github/workflows/release-snapshot.yml

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

.github/workflows/release.yml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313
description: 'pre-release'
1414
required: false
1515
default: false
16+
snapshot:
17+
type: boolean
18+
description: 'Release as snapshot. This setting has precedence over all other inputs.'
19+
required: false
20+
default: false
1621

1722
jobs:
1823
build:
@@ -51,11 +56,26 @@ jobs:
5156
npm install -g npm
5257
yarn install --immutable
5358
54-
- name: version
59+
- name: version - Release
60+
if: ${{ github.event.inputs.snapshot == 'false' }}
5561
run: |
5662
${GITHUB_WORKSPACE}/node_modules/.bin/lerna version ${{ github.event.inputs.release_type }} \
5763
${{ (github.event.inputs.prerelease == 'true' && '--conventional-prerelease') || '--conventional-graduate' }} \
58-
--no-git-tag-version --no-push
64+
--no-push \
65+
--no-git-tag-version
66+
67+
- name: version - Snapshot
68+
if: ${{ github.event.inputs.snapshot == 'true' }}
69+
run: |
70+
git_hash=$(git rev-parse --short "${{ github.sha }}")
71+
72+
${GITHUB_WORKSPACE}/node_modules/.bin/lerna version "0.0.0-${git_hash}" \
73+
--exact \
74+
--no-push \
75+
--no-git-tag-version \
76+
--allow-branch ${{ github.ref_name }}
77+
78+
5979
6080
build-and-release:
6181
needs: ['test', 'release-dryrun', 'check-charts-compat-peer-deps']
@@ -84,34 +104,44 @@ jobs:
84104
npm install -g npm
85105
yarn install --immutable
86106
87-
- name: version
107+
- name: Setup Git User
88108
run: |
89-
npm config set //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
90-
91109
git config user.email ${{ secrets.BOT_GIT_EMAIL }}
92110
git config user.name ${{ secrets.BOT_GIT_USERNAME }}
93111
112+
- name: version - Release
113+
if: ${{ github.event.inputs.snapshot == 'false' }}
114+
run: |
94115
${GITHUB_WORKSPACE}/node_modules/.bin/lerna version ${{ github.event.inputs.release_type }} \
95116
${{ (github.event.inputs.prerelease == 'true' && '--conventional-prerelease') || '--conventional-graduate' }} \
96117
--create-release github
97118
env:
98119
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
99-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
100-
NPM_CONFIG_PROVENANCE: true
120+
121+
- name: version - Snapshot
122+
if: ${{ github.event.inputs.snapshot == 'true' }}
123+
run: |
124+
git_hash=$(git rev-parse --short "${{ github.sha }}")
125+
126+
${GITHUB_WORKSPACE}/node_modules/.bin/lerna version "0.0.0-${git_hash}" \
127+
--exact \
128+
--no-push \
129+
--allow-branch ${{ github.ref_name }}
101130
102131
- name: build
103132
run: yarn build
104133

105134
- name: publish to npm
106-
run: ${GITHUB_WORKSPACE}/node_modules/.bin/lerna publish from-git
135+
run: |
136+
${GITHUB_WORKSPACE}/node_modules/.bin/lerna publish from-git ${{ github.event.inputs.snapshot == 'true' && '--pre-dist-tag dev' }}
107137
env:
108138
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
109-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
110139
NPM_CONFIG_PROVENANCE: true
111140

112141
### Semantic Release Bot comments for issues and PRs ###
113142
- name: Add release comments to issues and PRs
114143
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
144+
if: ${{ github.event.inputs.snapshot == 'false' }}
115145
env:
116146
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
117147
with:

0 commit comments

Comments
 (0)