Skip to content

Commit bc39469

Browse files
authored
ci: Update npm publishing workflows (#1239)
Signed-off-by: Roger Barker <[email protected]>
1 parent cca3740 commit bc39469

File tree

3 files changed

+92
-12
lines changed

3 files changed

+92
-12
lines changed

.github/workflows/publish-npm-package.yaml

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@ name: Publish Package to npmjs
44
on:
55
release:
66
types: [published]
7+
workflow_dispatch:
8+
inputs:
9+
dry-run-enabled:
10+
description: 'Enable dry run mode'
11+
required: false
12+
default: 'false'
713

814
permissions:
915
contents: read
16+
id-token: write
1017

1118
defaults:
1219
run:
1320
shell: bash
1421

1522
jobs:
16-
publish-npm-package:
23+
create-npm-package:
1724
runs-on: hiero-local-node-linux-medium
25+
outputs:
26+
artifact: ${{ steps.prepare-package-data.outputs.artifact-name }}
1827
steps:
1928
- name: Harden Runner
2029
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
@@ -24,16 +33,83 @@ jobs:
2433
- name: Checkout repository
2534
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2635

27-
- name: Use Node.js 20.x
36+
- name: Setup Node
2837
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2938
with:
30-
node-version: '20.x'
39+
node-version: '20'
3140
registry-url: 'https://registry.npmjs.org'
3241

42+
- name: Setup JQ
43+
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
44+
with:
45+
version: 1.7
46+
3347
- name: Clean install
3448
run: npm ci
3549

50+
- name: Prepare Package Data
51+
id: prepare-package-data
52+
run: |
53+
echo "::group::Build Package"
54+
npm run build
55+
echo "::endgroup::"
56+
57+
echo "::group::Run Tests"
58+
npm run test
59+
echo "::endgroup::"
60+
61+
echo "::group::Set Artifact Name"
62+
VERSION=$(jq -r '.version' './package.json')
63+
PKG_NAME="hashgraph-hedera-local-${VERSION}.tgz"
64+
echo "artifact-name=${PKG_NAME}" >> $GITHUB_OUTPUT
65+
echo "::endgroup::"
66+
67+
- name: Build Package
68+
run: |
69+
npm pack
70+
ls -lh ${{ steps.prepare-package-data.outputs.artifact-name }}
71+
72+
- name: Upload NPM Package Artifact
73+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
74+
with:
75+
name: npm-package
76+
path: ./${{ steps.prepare-package-data.outputs.artifact-name }}
77+
if-no-files-found: error
78+
79+
publish-npm-package:
80+
runs-on: ubuntu-latest
81+
needs: create-npm-package
82+
steps:
83+
- name: Harden Runner
84+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
85+
with:
86+
egress-policy: audit
87+
88+
- name: Checkout repository
89+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
90+
91+
- name: Use Node.js 20
92+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
93+
with:
94+
node-version: '20'
95+
registry-url: 'https://registry.npmjs.org'
96+
97+
- name: Install NPM latest
98+
run: npm install -g [email protected]
99+
100+
- name: Download NPM Package Artifact
101+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
102+
with:
103+
name: npm-package
104+
36105
- name: Publish npm package
37-
run: npm publish --access public
38-
env:
39-
NODE_AUTH_TOKEN: ${{ secrets.NPM_HG_TOKEN }}
106+
run: |
107+
args="--access=public"
108+
if [[ "${{ inputs.dry-run-enabled }}" == "true" ]]; then
109+
args="${args} --dry-run"
110+
fi
111+
112+
package="${{ needs.create-npm-package.outputs.artifact }}"
113+
echo "::group::Publishing package: ${package} with args: ${args}"
114+
npm publish ${package} ${args}
115+
echo "::endgroup::"

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hashgraph/hedera-local",
3-
"version": "2.39.0",
3+
"version": "2.39.1",
44
"description": "Developer tooling for running Local Hedera Network (Consensus + Mirror Nodes).",
55
"main": "index.ts",
66
"scripts": {
@@ -27,10 +27,14 @@
2727
},
2828
"keywords": [
2929
"hedera",
30-
"hedera-local"
30+
"hedera-local",
31+
"hiero",
32+
"hiero-ledger",
33+
"hiero-local",
34+
"hashgraph"
3135
],
32-
"homepage": "https://github.com/hashgraph/hedera-local-node",
33-
"repository": "github.com:hashgraph/hedera-local-node",
36+
"homepage": "https://github.com/hiero-ledger/hiero-local-node",
37+
"repository": "github.com:hiero-ledger/hiero-local-node",
3438
"author": "hashgraph",
3539
"license": "Apache-2.0",
3640
"devDependencies": {

0 commit comments

Comments
 (0)