1212 preflight :
1313 name : Preflight
1414 runs-on : ubuntu-latest
15+ outputs :
16+ version : ${{ steps.version.outputs.version }}
1517 steps :
1618 - name : Checkout repository
1719 uses : actions/checkout@v6
@@ -27,16 +29,27 @@ jobs:
2729 node-version : 24
2830 registry-url : ' https://registry.npmjs.org'
2931
32+ - name : Determine version from the release tag
33+ id : version
34+ shell : bash
35+ run : |
36+ set -e
37+ set -o pipefail
38+ echo "Tag: ${{ github.event.release.tag_name }}"
39+ VERSION=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//')
40+ echo "Version: $VERSION"
41+ if ! pnpm semver $VERSION; then
42+ echo "ERROR: Invalid version $VERSION"
43+ exit 1
44+ fi
45+ echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
3047 - name : Install dependencies
3148 shell : bash
3249 env :
3350 GH_TOKEN : ${{ secrets.GH_TOKEN }}
3451 run : pnpm install --ignore-scripts --no-frozen-lockfile
3552
36- - name : Check versions
37- shell : bash
38- run : node scripts/check-versions.mjs
39-
4053 - name : Build
4154 env :
4255 GH_TOKEN : ${{ secrets.GH_TOKEN }}
@@ -157,13 +170,34 @@ jobs:
157170 shell : bash
158171 run : find artifacts -ls
159172
173+ - name : Bump versions
174+ shell : bash
175+ run : node scripts/bump-versions.mjs ${{ needs.preflight.outputs.version }}
176+
177+ - name : Configure git
178+ shell : bash
179+ env :
180+ GH_TOKEN : ${{ secrets.GH_TOKEN }}
181+ run : |
182+ git config user.name "github-actions[bot]"
183+ git config user.email "github-actions[bot]@users.noreply.github.com"
184+ git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git
185+
186+ - name : Commit package.json
187+ shell : bash
188+ run : |
189+ set -e
190+ set -o pipefail
191+ git add package.json
192+ git commit -m "v${{ needs.preflight.outputs.version }}"
193+ git push origin main
194+
160195 - name : Get package.json info
161196 id : get-package-info
162197 shell : bash
163198 run : |
164199 echo "name=$(node -p "require('./package.json').name")" >> $GITHUB_OUTPUT
165200 echo "homepage=$(node -p "require('./package.json').homepage")" >> $GITHUB_OUTPUT
166- echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
167201
168202 - name : Publish bindings to npm
169203 env :
@@ -178,6 +212,30 @@ jobs:
178212 shell : bash
179213 run : pnpm publish --access public --no-git-checks --tag ${{ github.event.release.prerelease && 'next' || 'latest' }}
180214
215+ - name : Wait for npm to publish
216+ shell : bash
217+ timeout-minutes : 5
218+ run : |
219+ sleep 10
220+ while ! pnpm view ${{ steps.get-package-info.outputs.name }}@${{ needs.preflight.outputs.version }} > /dev/null 2>&1; do
221+ echo "Waiting for npm to publish ${{ steps.get-package-info.outputs.name }}@${{ needs.preflight.outputs.version }}..."
222+ sleep 10
223+ done
224+ echo "npm has published ${{ steps.get-package-info.outputs.name }}@${{ needs.preflight.outputs.version }}"
225+
226+ - name : Update pnpm-lock.yaml
227+ env :
228+ GH_TOKEN : ${{ secrets.GH_TOKEN }}
229+ shell : bash
230+ run : pnpm install
231+
232+ - name : Commit pnpm-lock.yaml
233+ shell : bash
234+ run : |
235+ git add pnpm-lock.yaml
236+ git commit -m "chore(package): update pnpm-lock.yaml after publishing ${{ needs.preflight.outputs.version }}"
237+ git push origin main
238+
181239 - name : Send Slack notification
182240 uses : slackapi/slack-github-action@v2.0.0
183241 with :
@@ -186,20 +244,20 @@ jobs:
186244 payload : |
187245 {
188246 "channel": "${{ secrets.SLACK_CHANNEL_ID }}",
189- "text": "Published ${{ steps.get-package-info.outputs.name }}@${{ steps.get-package-info .outputs.version }}",
247+ "text": "Published ${{ steps.get-package-info.outputs.name }}@${{ needs.preflight .outputs.version }}",
190248 "blocks": [
191249 {
192250 "type": "header",
193251 "text": {
194252 "type": "plain_text",
195- "text": "Published ${{ steps.get-package-info.outputs.name }}@${{ steps.get-package-info .outputs.version }}"
253+ "text": "Published ${{ steps.get-package-info.outputs.name }}@${{ needs.preflight .outputs.version }}"
196254 }
197255 },
198256 {
199257 "type": "section",
200258 "text": {
201259 "type": "mrkdwn",
202- "text": "https://github.com/HarperFast/rocksdb-prebuilds/releases/tag/v${{ steps.get-package-info .outputs.version }}"
260+ "text": "https://github.com/HarperFast/rocksdb-prebuilds/releases/tag/v${{ needs.preflight .outputs.version }}"
203261 }
204262 }
205263 ]
0 commit comments