Skip to content

Commit 753fdbc

Browse files
authored
ci: Update publishing mechanism for npmjs (#745)
Signed-off-by: Roger Barker <roger.barker@swirldslabs.com>
1 parent e0a3f03 commit 753fdbc

File tree

7 files changed

+156
-58
lines changed

7 files changed

+156
-58
lines changed

.github/workflows/ats.publish.yml

Lines changed: 133 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ permissions:
2525
id-token: write
2626

2727
jobs:
28-
contracts:
29-
name: Publish ATS Contracts
28+
prepare-contracts:
29+
name: Prepare ATS Contracts
3030
runs-on: token-studio-linux-large
3131
# Only run if manual trigger OR tag push (already filtered by v*-ats pattern)
3232
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
33-
33+
outputs:
34+
artifact-name: ${{ steps.prepare-package-data.outputs.artifact-name }}
3435
steps:
3536
- name: Harden Runner
3637
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
@@ -47,46 +48,55 @@ jobs:
4748
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
4849
with:
4950
node-version: 22.20.0
50-
registry-url: https://registry.npmjs.org
5151

52-
- name: Create .npmrc file
53-
working-directory: packages/ats/contracts
54-
run: |
55-
cat << 'EOF' > .npmrc
56-
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
57-
EOF
52+
- name: Setup JQ
53+
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
54+
with:
55+
version: 1.7
5856

5957
- name: Install dependencies
6058
run: npm ci
6159

6260
- name: Build ATS Contracts
6361
run: npm run ats:contracts:build
6462

65-
- name: Publish ATS Contracts
66-
env:
67-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
68-
DRY_RUN: ${{ inputs.dry-run-enabled }}
69-
working-directory: packages/ats/contracts
63+
- name: Package ATS Contracts
64+
id: prepare-package-data
7065
run: |
71-
PUBLISH_ARGS=("--access=public")
72-
if [[ "${DRY_RUN}" == "true" ]]; then
73-
PUBLISH_ARGS+=("--dry-run")
74-
echo "🔍 DRY RUN MODE: Would publish @hashgraph/asset-tokenization-contracts"
75-
fi
66+
echo "::group::Set Artifact Name"
67+
VERSION=$(jq -r '.version' './package.json')
68+
PKG_NAME="hashgraph-asset-tokenization-contracts-${VERSION}.tgz"
69+
echo "::endgroup::"
70+
71+
echo "::group::Build Package"
72+
echo "Building package: ${PKG_NAME}"
73+
if ! npm pack; then
74+
echo "❌ Failed to build package: ${PKG_NAME}"
75+
echo "📋 Package info:" && cat package.json | jq '.name, .version'
76+
exit 1
77+
fi
78+
echo "Verify package ${PKG_NAME} created successfully."
79+
ls -lh ${PKG_NAME}
80+
echo "::endgroup::"
81+
82+
echo "artifact-name=${PKG_NAME}" >> $GITHUB_OUTPUT
83+
working-directory: packages/ats/contracts
7684

77-
if ! npm publish "${PUBLISH_ARGS[@]}"; then
78-
echo "❌ Failed to publish package: ${package_name}"
79-
echo "📋 Package info:" && cat package.json | jq '.name, .version'
80-
exit 1
81-
fi
85+
- name: Upload NPM Package Artifact
86+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
87+
with:
88+
name: ats-contracts-package
89+
path: ./packages/ats/contracts/${{ steps.prepare-package-data.outputs.artifact-name }}
90+
if-no-files-found: error
8291

83-
sdk:
84-
name: Publish ATS SDK
92+
prepare-sdk:
93+
name: Prepare ATS SDK
8594
runs-on: token-studio-linux-large
8695
# Only run if manual trigger OR tag push (already filtered by v*-ats pattern)
8796
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
8897
# needs: contracts # Commented out for parallel execution
89-
98+
outputs:
99+
artifact-name: ${{ steps.prepare-package-data.outputs.artifact-name }}
90100
steps:
91101
- name: Harden Runner
92102
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
@@ -103,14 +113,11 @@ jobs:
103113
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
104114
with:
105115
node-version: 22.20.0
106-
registry-url: https://registry.npmjs.org
107116

108-
- name: Create .npmrc file
109-
working-directory: packages/ats/sdk
110-
run: |
111-
cat << 'EOF' > .npmrc
112-
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
113-
EOF
117+
- name: Setup JQ
118+
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
119+
with:
120+
version: 1.7
114121

115122
- name: Install dependencies
116123
run: npm ci
@@ -120,31 +127,101 @@ jobs:
120127
npm run ats:contracts:build
121128
npm run ats:sdk:build
122129
123-
- name: Publish ATS SDK
124-
env:
125-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
126-
DRY_RUN: ${{ inputs.dry-run-enabled }}
127-
working-directory: packages/ats/sdk
130+
- name: Package ATS SDK
131+
id: prepare-package-data
128132
run: |
129-
PUBLISH_ARGS=("--access=public")
130-
if [[ "${DRY_RUN}" == "true" ]]; then
131-
PUBLISH_ARGS+=("--dry-run")
132-
echo "🔍 DRY RUN MODE: Would publish @hashgraph/asset-tokenization-sdk"
133-
fi
133+
echo "::group::Set Artifact Name"
134+
VERSION=$(jq -r '.version' './package.json')
135+
PKG_NAME="hashgraph-asset-tokenization-sdk-${VERSION}.tgz"
136+
echo "::endgroup::"
137+
138+
echo "::group::Build Package"
139+
echo "Building package: ${PKG_NAME}"
140+
if ! npm pack; then
141+
echo "❌ Failed to build package: ${PKG_NAME}"
142+
echo "📋 Package info:" && cat package.json | jq '.name, .version'
143+
exit 1
144+
fi
145+
echo "Verify package ${PKG_NAME} created successfully."
146+
ls -lh ${PKG_NAME}
147+
echo "::endgroup::"
148+
149+
echo "artifact-name=${PKG_NAME}" >> $GITHUB_OUTPUT
150+
working-directory: packages/ats/sdk
134151

135-
if ! npm publish "${PUBLISH_ARGS[@]}"; then
136-
echo "❌ Failed to publish package: ${package_name}"
137-
echo "📋 Package info:" && cat package.json | jq '.name, .version'
138-
exit 1
139-
fi
152+
- name: Upload NPM Package Artifact
153+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
154+
with:
155+
name: ats-sdk-package
156+
path: ./packages/ats/sdk/${{ steps.prepare-package-data.outputs.artifact-name }}
157+
if-no-files-found: error
158+
159+
publish-npm-packages:
160+
runs-on: ubuntu-latest
161+
needs:
162+
- prepare-contracts
163+
- prepare-sdk
164+
steps:
165+
- name: Harden Runner
166+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
167+
with:
168+
egress-policy: audit
169+
170+
- name: Checkout repository
171+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
172+
with:
173+
fetch-depth: '1'
174+
175+
- name: Setup NodeJS Environment
176+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
177+
with:
178+
node-version: 22.20.0
179+
registry-url: 'https://registry.npmjs.org'
180+
181+
- name: Install NPM latest
182+
run: npm install -g npm@11.7.0
183+
184+
- name: Download ATS Contracts Package Artifact
185+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
186+
with:
187+
name: ats-contracts-package
188+
189+
- name: Download ATS SDK Package Artifact
190+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
191+
with:
192+
name: ats-sdk-package
193+
194+
- name: Publish npm packages
195+
run: |
196+
echo "::group::Set publish parameters"
197+
PUBLISH_ARGS="--access=public"
198+
if [[ "${{ inputs.dry-run-enabled }}" == "true" ]]; then
199+
PUBLISH_ARGS="${PUBLISH_ARGS} --dry-run"
200+
fi
201+
echo "::endgroup::"
202+
203+
echo "::group::Publish ATS SDK Package ${{ needs.prepare-sdk.outputs.artifact-name }} with args: ${PUBLISH_ARGS}"
204+
if ! npm publish ./${{ needs.prepare-sdk.outputs.artifact-name }} ${PUBLISH_ARGS}; then
205+
echo "❌ Failed to publish ATS SDK package: ${{ needs.prepare-sdk.outputs.artifact-name }}"
206+
exit 1
207+
fi
208+
echo "::endgroup::"
209+
210+
echo "::group::Publish ATS SDK Package ${{ needs.prepare-sdk.outputs.artifact-name }} with args: ${PUBLISH_ARGS}"
211+
if ! npm publish ./${{ needs.prepare-sdk.outputs.artifact-name }} ${PUBLISH_ARGS}; then
212+
echo "❌ Failed to publish ATS SDK package: ${{ needs.prepare-sdk.outputs.artifact-name }}"
213+
exit 1
214+
fi
215+
echo "::endgroup::"
140216
141217
# Summary job to report results
142218
summary:
143219
name: Publish Summary
144220
runs-on: token-studio-linux-large
145221
needs:
146-
- contracts
147-
- sdk
222+
- prepare-contracts
223+
- prepare-sdk
224+
- publish-npm-packages
148225
if: ${{ always() }}
149226
steps:
150227
- name: Harden the runner (Audit all outbound calls)
@@ -155,10 +232,11 @@ jobs:
155232
- name: Report Results
156233
run: |
157234
echo "## ATS Publish Results" >> "${GITHUB_STEP_SUMMARY}"
158-
echo "| Package | Status |" >> "${GITHUB_STEP_SUMMARY}"
235+
echo "| Step | Status |" >> "${GITHUB_STEP_SUMMARY}"
159236
echo "| --- | --- |" >> "${GITHUB_STEP_SUMMARY}"
160-
echo "| Contracts | ${{ needs.contracts.result }} |" >> "${GITHUB_STEP_SUMMARY}"
161-
echo "| SDK | ${{ needs.sdk.result }} |" >> "${GITHUB_STEP_SUMMARY}"
237+
echo "| Package Contracts | ${{ needs.prepare-contracts.result }} |" >> "${GITHUB_STEP_SUMMARY}"
238+
echo "| Package SDK | ${{ needs.prepare-sdk.result }} |" >> "${GITHUB_STEP_SUMMARY}"
239+
echo "| Publish NPM Packages | ${{ needs.publish-npm-packages.result }} |" >> "${GITHUB_STEP_SUMMARY}"
162240
163241
if [[ "${{ inputs.dry-run-enabled }}" == "true" ]]; then
164242
echo "" >> "${GITHUB_STEP_SUMMARY}"

apps/ats/web/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @hashgraph/asset-tokenization-dapp
22

3+
## 1.17.1
4+
5+
### Patch Changes
6+
7+
- Update publishing workflows to enable non production with provenance publishing
8+
39
## 1.17.0
410

511
### Minor Changes

apps/ats/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hashgraph/asset-tokenization-dapp",
3-
"version": "1.17.0",
3+
"version": "2.0.1",
44
"license": "Apache-2.0",
55
"scripts": {
66
"build": "tsc && vite build",

packages/ats/contracts/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @hashgraph/asset-tokenization-contracts
22

3+
## 1.17.1
4+
5+
### Patch Changes
6+
7+
- Update publishing workflows to enable non production with provenance publishing
8+
39
## 1.17.0
410

511
### Minor Changes

packages/ats/contracts/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@hashgraph/asset-tokenization-contracts",
3-
"version": "1.17.0",
3+
"version": "2.0.1",
4+
"repository": "https://github.com/hashgraph/asset-tokenization-studio",
45
"type": "commonjs",
56
"main": "./build/typechain-types/index.js",
67
"types": "./build/typechain-types/index.d.ts",

packages/ats/sdk/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @hashgraph/asset-tokenization-sdk
22

3+
## 1.17.1
4+
5+
### Patch Changes
6+
7+
- Update publishing workflows to enable non production with provenance publishing
8+
39
## 1.17.0
410

511
### Minor Changes

packages/ats/sdk/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "@hashgraph/asset-tokenization-sdk",
33
"description": "Asset Tokenization SDK for Hedera",
4-
"version": "1.17.0",
4+
"version": "2.0.1",
5+
"repository": "https://github.com/hashgraph/asset-tokenization-studio",
56
"main": "./build/cjs/src/index.js",
67
"module": "./build/esm/src/index.js",
78
"types": "./build/esm/src/index.d.ts",

0 commit comments

Comments
 (0)