@@ -2,6 +2,11 @@ name: Build gnd Binaries
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ dry_run :
7+ description : ' Dry-run npm publish (no actual publish)'
8+ type : boolean
9+ default : false
510
611jobs :
712 build :
@@ -156,4 +161,107 @@ jobs:
156161 # Upload Windows x86_64 asset
157162 gh release upload $VERSION artifacts/gnd-windows-x86_64.exe/gnd-windows-x86_64.exe.zip --repo $GITHUB_REPOSITORY
158163 env :
159- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
164+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
165+
166+ publish-npm :
167+ name : Publish npm package for ${{ matrix.platform }}
168+ needs : release
169+ if : startsWith(github.ref, 'refs/tags/')
170+ runs-on : ubuntu-latest
171+ permissions :
172+ id-token : write
173+ contents : read
174+ strategy :
175+ fail-fast : false
176+ matrix :
177+ include :
178+ - platform : linux-x64
179+ asset : gnd-linux-x86_64.gz
180+ os_field : linux
181+ cpu_field : x64
182+ extract : gunzip
183+ - platform : linux-arm64
184+ asset : gnd-linux-aarch64.gz
185+ os_field : linux
186+ cpu_field : arm64
187+ extract : gunzip
188+ - platform : darwin-x64
189+ asset : gnd-macos-x86_64.gz
190+ os_field : darwin
191+ cpu_field : x64
192+ extract : gunzip
193+ - platform : darwin-arm64
194+ asset : gnd-macos-aarch64.gz
195+ os_field : darwin
196+ cpu_field : arm64
197+ extract : gunzip
198+ - platform : win32-x64
199+ asset : gnd-windows-x86_64.exe.zip
200+ os_field : win32
201+ cpu_field : x64
202+ extract : unzip
203+ steps :
204+ - uses : actions/setup-node@v4
205+ with :
206+ node-version : 20
207+ registry-url : https://registry.npmjs.org
208+
209+ - name : Download gnd binary
210+ env :
211+ GH_TOKEN : ${{ github.token }}
212+ run : |
213+ gh release download "${{ github.ref_name }}" \
214+ --repo "${{ github.repository }}" \
215+ --pattern "${{ matrix.asset }}" \
216+ --output ./binary-archive
217+
218+ - name : Extract binary
219+ run : |
220+ mkdir -p pkg/bin
221+ if [ "${{ matrix.extract }}" = "gunzip" ]; then
222+ gunzip -c ./binary-archive > pkg/bin/gnd
223+ chmod +x pkg/bin/gnd
224+ else
225+ unzip ./binary-archive -d pkg/bin
226+ mv pkg/bin/*.exe pkg/bin/gnd.exe
227+ fi
228+
229+ - name : Create package.json
230+ shell : bash
231+ run : |
232+ VERSION="${{ github.ref_name }}"
233+ VERSION="${VERSION#v}"
234+
235+ if [ "${{ matrix.os_field }}" = "win32" ]; then
236+ BIN_PATH="./bin/gnd.exe"
237+ else
238+ BIN_PATH="./bin/gnd"
239+ fi
240+
241+ cat > pkg/package.json << EOF
242+ {
243+ "name": "@graphprotocol/gnd-${{ matrix.platform }}",
244+ "version": "${VERSION}",
245+ "description": "gnd binary for ${{ matrix.platform }}",
246+ "os": ["${{ matrix.os_field }}"],
247+ "cpu": ["${{ matrix.cpu_field }}"],
248+ "bin": {
249+ "gnd": "${BIN_PATH}"
250+ },
251+ "publishConfig": {
252+ "access": "public",
253+ "provenance": true
254+ },
255+ "license": "(Apache-2.0 OR MIT)",
256+ "repository": {
257+ "type": "git",
258+ "url": "https://github.com/graphprotocol/graph-node.git"
259+ }
260+ }
261+ EOF
262+
263+ - name : Publish
264+ run : npm publish --provenance --access public ${{ inputs.dry_run && '--dry-run' || '' }}
265+ working-directory : pkg
266+ env :
267+ NODE_AUTH_TOKEN : ${{ secrets.GRAPHPROTOCOL_NPM_TOKEN }}
0 commit comments