Skip to content

Commit e3e5481

Browse files
committed
ci: merge snapshot and regular release & publish with npm trusted publishers
1 parent c08a8b9 commit e3e5481

File tree

2 files changed

+40
-68
lines changed

2 files changed

+40
-68
lines changed

.github/workflows/release-snapshot.yml

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

.github/workflows/release.yml

Lines changed: 40 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,10 +104,9 @@ jobs:
84104
npm install -g npm
85105
yarn install --immutable
86106
87-
- name: version
107+
- name: version - Release
108+
if: ${{ github.event.inputs.snapshot == false }}
88109
run: |
89-
npm config set //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
90-
91110
git config user.email ${{ secrets.BOT_GIT_EMAIL }}
92111
git config user.name ${{ secrets.BOT_GIT_USERNAME }}
93112
@@ -96,22 +115,34 @@ jobs:
96115
--create-release github
97116
env:
98117
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
99-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
100-
NPM_CONFIG_PROVENANCE: true
118+
119+
- name: version - Snapshot
120+
if: ${{ github.event.inputs.snapshot == true }}
121+
run: |
122+
git_hash=$(git rev-parse --short "${{ github.sha }}")
123+
124+
${GITHUB_WORKSPACE}/node_modules/.bin/lerna version "0.0.0-${git_hash}" \
125+
--exact \
126+
--no-push \
127+
--no-git-tag-version \
128+
--allow-branch ${{ github.ref_name }}
101129
102130
- name: build
103131
run: yarn build
104132

105133
- name: publish to npm
106-
run: ${GITHUB_WORKSPACE}/node_modules/.bin/lerna publish from-git
134+
run: |
135+
${GITHUB_WORKSPACE}/node_modules/.bin/lerna publish \
136+
from-git \
137+
${{ github.event.inputs.snapshot == true && '--pre-dist-tag dev' }}
107138
env:
108139
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
109-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
110140
NPM_CONFIG_PROVENANCE: true
111141

112142
### Semantic Release Bot comments for issues and PRs ###
113143
- name: Add release comments to issues and PRs
114144
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
145+
if: ${{ github.event.inputs.snapshot == false }}
115146
env:
116147
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
117148
with:

0 commit comments

Comments
 (0)