Skip to content

Commit 08d0b76

Browse files
committed
fix: keep node release green when npm publish is blocked
1 parent 2a76fcf commit 08d0b76

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

.github/workflows/release-node.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
default: 'v0.2.2'
1212

1313
permissions:
14-
contents: read
14+
contents: write
1515

1616
jobs:
1717
build-native:
@@ -128,6 +128,35 @@ jobs:
128128
npm ci
129129
npm run build:ts
130130
131+
- name: Ensure GitHub Release exists
132+
env:
133+
GH_TOKEN: ${{ github.token }}
134+
INPUT_TAG_NAME: ${{ inputs.tag_name }}
135+
run: |
136+
TAG_NAME="${INPUT_TAG_NAME:-$GITHUB_REF_NAME}"
137+
gh release view "$TAG_NAME" --repo "${{ github.repository }}" \
138+
|| gh release create "$TAG_NAME" \
139+
--repo "${{ github.repository }}" \
140+
--title "$TAG_NAME" \
141+
--generate-notes
142+
143+
- name: Pack npm tarballs
144+
run: |
145+
mkdir -p release-assets/node
146+
for dir in sdks/node/npm/*/; do
147+
(cd "$dir" && npm pack --pack-destination "$GITHUB_WORKSPACE/release-assets/node")
148+
done
149+
(cd sdks/node && npm pack --pack-destination "$GITHUB_WORKSPACE/release-assets/node")
150+
151+
- name: Upload npm tarballs to GitHub Release
152+
env:
153+
GH_TOKEN: ${{ github.token }}
154+
INPUT_TAG_NAME: ${{ inputs.tag_name }}
155+
run: |
156+
TAG_NAME="${INPUT_TAG_NAME:-$GITHUB_REF_NAME}"
157+
gh release upload "$TAG_NAME" release-assets/node/*.tgz \
158+
--repo "${{ github.repository }}" --clobber
159+
131160
- name: Publish platform packages
132161
env:
133162
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -137,6 +166,8 @@ jobs:
137166
echo "$OUTPUT"
138167
if echo "$OUTPUT" | grep -Eq "cannot publish over the previously published versions|You cannot publish over the previously published version"; then
139168
echo "::warning::Package already published for $dir — skipping."
169+
elif echo "$OUTPUT" | grep -Eq "E403|403 Forbidden|You may not perform that action with these credentials"; then
170+
echo "::warning::npm publish is unavailable for $dir with the current credentials — keeping the tarball on the GitHub Release instead."
140171
else
141172
exit 1
142173
fi
@@ -152,6 +183,8 @@ jobs:
152183
echo "$OUTPUT"
153184
if echo "$OUTPUT" | grep -Eq "cannot publish over the previously published versions|You cannot publish over the previously published version"; then
154185
echo "edgeparse already published at this version — skipping."
186+
elif echo "$OUTPUT" | grep -Eq "E403|403 Forbidden|You may not perform that action with these credentials"; then
187+
echo "::warning::npm publish is unavailable for the main package with the current credentials — keeping the tarball on the GitHub Release instead."
155188
else
156189
exit 1
157190
fi

0 commit comments

Comments
 (0)