Skip to content

Commit f27e94a

Browse files
committed
add release safety guards for npm publishing
sync package version with git tag prevent duplicate version publish verify native binaries are included in package
1 parent 3a23c73 commit f27e94a

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

.github/workflows/release-binaries.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,33 @@ jobs:
131131
working-directory: node_version
132132
run: npm ci
133133

134+
- name: Sync version with tag
135+
working-directory: node_version
136+
run: |
137+
VERSION=${GITHUB_REF#refs/tags/v}
138+
npm version $VERSION --no-git-tag-version
139+
140+
- name: Check if version exists
141+
working-directory: node_version
142+
run: |
143+
PACKAGE_NAME=$(node -p "require('./package.json').name")
144+
VERSION=$(node -p "require('./package.json').version")
145+
146+
if npm view "$PACKAGE_NAME@$VERSION" version >/dev/null 2>&1; then
147+
echo "Version already exists on npm"
148+
exit 1
149+
fi
150+
151+
- name: Build package tarball
152+
wogsrking-directory: node_version
153+
run: npm pack
154+
155+
- name: Verify package contains native binaries
156+
working-directory: node_version
157+
run: |
158+
TAR=$(ls *.tgz)
159+
tar -tf "$TAR" | grep "dist/native" || (echo "Missing native binaries in package" && exit 1)
160+
134161
- name: Package check
135162
working-directory: node_version
136163
run: npm pack --dry-run

0 commit comments

Comments
 (0)