Skip to content

Commit 4aeb420

Browse files
committed
ci: Allow gnd-binary-build workflow to publish to an existing release
Adds a release_tag workflow_dispatch input. When set, the release, publish-npm and publish-npm-wrapper jobs target the given tag instead of github.ref_name, so a rebuilt artifact set can be attached to an existing GitHub release and published to npm without cutting a new tag.
1 parent 5c10e76 commit 4aeb420

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

.github/workflows/gnd-binary-build.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Build gnd Binaries
33
on:
44
workflow_dispatch:
55
inputs:
6+
release_tag:
7+
description: 'Existing release tag to upload binaries to and publish as on npm (e.g. v0.44.0). Leave empty to only build artifacts.'
8+
type: string
9+
default: ''
610
dry_run:
711
description: 'Dry-run npm publish (no actual publish)'
812
type: boolean
@@ -130,7 +134,7 @@ jobs:
130134
release:
131135
name: Create Release
132136
needs: build
133-
if: startsWith(github.ref, 'refs/tags/')
137+
if: inputs.release_tag != ''
134138
runs-on: ubuntu-latest
135139
steps:
136140
- name: Checkout code
@@ -153,10 +157,8 @@ jobs:
153157

154158
- name: Upload Assets to Release
155159
run: |
156-
# Extract version from ref (remove refs/tags/ prefix)
157-
VERSION=${GITHUB_REF#refs/tags/}
158-
159-
# Upload Linux x86_64 asset
160+
VERSION="${{ inputs.release_tag }}"
161+
160162
gh release upload $VERSION --clobber --repo $GITHUB_REPOSITORY \
161163
artifacts/gnd-linux-x86_64/gnd-linux-x86_64.gz \
162164
artifacts/gnd-linux-aarch64/gnd-linux-aarch64.gz \
@@ -169,7 +171,7 @@ jobs:
169171
publish-npm:
170172
name: Publish npm package for ${{ matrix.platform }}
171173
needs: release
172-
if: startsWith(github.ref, 'refs/tags/')
174+
if: inputs.release_tag != ''
173175
runs-on: ubuntu-latest
174176
permissions:
175177
id-token: write
@@ -212,7 +214,7 @@ jobs:
212214
env:
213215
GH_TOKEN: ${{ github.token }}
214216
run: |
215-
gh release download "${{ github.ref_name }}" \
217+
gh release download "${{ inputs.release_tag }}" \
216218
--repo "${{ github.repository }}" \
217219
--pattern "${{ matrix.asset }}" \
218220
--output ./binary-archive
@@ -232,7 +234,7 @@ jobs:
232234
id: version
233235
shell: bash
234236
run: |
235-
VERSION="${{ github.ref_name }}"
237+
VERSION="${{ inputs.release_tag }}"
236238
VERSION="${VERSION#v}"
237239
echo "version=${VERSION}" >> $GITHUB_OUTPUT
238240
# Prerelease versions (e.g. 0.42.2-dev.1) need an explicit --tag
@@ -283,7 +285,7 @@ jobs:
283285
publish-npm-wrapper:
284286
name: Publish @graphprotocol/gnd wrapper
285287
needs: publish-npm
286-
if: startsWith(github.ref, 'refs/tags/')
288+
if: inputs.release_tag != ''
287289
runs-on: ubuntu-latest
288290
permissions:
289291
id-token: write
@@ -299,7 +301,7 @@ jobs:
299301
id: version
300302
shell: bash
301303
run: |
302-
VERSION="${{ github.ref_name }}"
304+
VERSION="${{ inputs.release_tag }}"
303305
VERSION="${VERSION#v}"
304306
echo "version=${VERSION}" >> $GITHUB_OUTPUT
305307
if [[ "$VERSION" == *-* ]]; then

0 commit comments

Comments
 (0)