@@ -2,6 +2,9 @@ name: Publish bolt-cli packages
2
2
on :
3
3
release :
4
4
types : [ published ]
5
+ push :
6
+ branches :
7
+ - ' release/v*'
5
8
workflow_dispatch :
6
9
inputs :
7
10
release_version :
63
66
- name : Checkout
64
67
uses : actions/checkout@v4
65
68
69
+ - name : Set DRY_RUN based on trigger
70
+ shell : bash
71
+ run : echo "DRY_RUN=true" >> $GITHUB_ENV
72
+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/v')
73
+
66
74
- name : Set the release version
67
75
shell : bash
68
- run : echo "RELEASE_VERSION=${github.event.inputs.release_version || GITHUB_REF:11}" >> $GITHUB_ENV
76
+ run : |
77
+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
78
+ echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
79
+ elif [[ "${{ github.event_name }}" == "push" ]]; then
80
+ VERSION=$(echo "${GITHUB_REF}" | sed -E 's|refs/heads/release/v||')
81
+ echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
82
+ elif [[ "${{ github.event_name }}" == "release" ]]; then
83
+ VERSION=$(echo "${GITHUB_REF}" | sed -E 's|refs/tags/v||')
84
+ echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
85
+ fi
69
86
70
87
- name : Install Rust toolchain
71
88
uses : actions-rs/toolchain@v1
92
109
- name : Check versions are aligned
93
110
run : |
94
111
# Fails if versions are not aligned
95
- ./scripts/version-align.sh --check
112
+ cargo install git-cliff
113
+ ./version-align.sh --check
96
114
97
115
- name : Build the NPM package
98
116
shell : bash
@@ -130,14 +148,15 @@ jobs:
130
148
cp "target/${{ matrix.build.TARGET }}/release/${bin}" "${node_pkg}/bin"
131
149
132
150
# Create the release bin file
133
- release_name="bolt-${{ matrix.build.NAME }}"
151
+ release_name="bolt-cli- ${{ matrix.build.NAME }}"
134
152
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
135
153
release_name="${release_name}.exe"
136
154
fi
137
155
echo "release_name=${release_name}" >> $GITHUB_ENV
138
156
mv "target/${{ matrix.build.TARGET }}/release/${bin}" "target/${{ matrix.build.TARGET }}/release/${release_name}"
139
157
140
158
- name : Publish binary to GitHub release
159
+ if : ${{ env.DRY_RUN != 'true' }}
141
160
uses : svenstaro/upload-release-action@v2
142
161
with :
143
162
repo_token : ${{ secrets.GITHUB_TOKEN }}
@@ -148,12 +167,18 @@ jobs:
148
167
asset_name : " ${{ env.release_name }}"
149
168
150
169
- name : Publish the NPM package
151
- shell : bash
152
170
run : |
171
+ echo "DRY_RUN=${{ env.DRY_RUN }}"
153
172
cd ${{ env.node_pkg }}
154
173
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
155
174
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
156
- npm publish --access public
175
+ if [ "${{ env.DRY_RUN }}" = "true" ]; then
176
+ echo "Running npm publish in dry-run mode"
177
+ npm publish --access public --dry-run
178
+ else
179
+ npm publish --access public
180
+ fi
181
+ shell : bash
157
182
env :
158
183
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
159
184
publish-wrapper-npm-package :
@@ -163,6 +188,9 @@ jobs:
163
188
steps :
164
189
- name : Checkout
165
190
uses : actions/checkout@v4
191
+ - name : Set DRY_RUN based on trigger
192
+ run : echo "DRY_RUN=true" >> $GITHUB_ENV
193
+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/v')
166
194
- name : Publish the NPM package
167
195
shell : bash
168
196
run : |
@@ -172,6 +200,11 @@ jobs:
172
200
cd lib
173
201
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
174
202
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
175
- npm publish --access public
203
+ if [ "${DRY_RUN}" = "true" ]; then
204
+ echo "Running npm publish in dry-run mode"
205
+ npm publish --access public --dry-run
206
+ else
207
+ npm publish --access public
208
+ fi
176
209
env :
177
210
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments