1919 outputs :
2020 version : ${{ steps.version.outputs.version }}
2121 version_tag : ${{ steps.version.outputs.version_tag }}
22+ npm_version : ${{ steps.version.outputs.npm_version }}
2223 dry_run : ${{ steps.version.outputs.dry_run }}
2324 steps :
2425 - name : Checkout
@@ -29,18 +30,28 @@ jobs:
2930 run : |
3031 VERSION=$(node -p "require('./package.json').version")
3132 VERSION_TAG="v${VERSION}"
33+ # Strip optional .A suffix (X.Y.Z.A -> X.Y.Z) for gopher-orch release tag
34+ ORCH_VERSION=$(echo "$VERSION" | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/')
35+ ORCH_TAG="v${ORCH_VERSION}"
36+ # Convert X.Y.Z.A -> X.Y.Z-A for npm semver compatibility
37+ NPM_VERSION=$(echo "$VERSION" | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\)\.\([0-9]*\)$/\1-\2/')
3238 echo "version=${VERSION}" >> $GITHUB_OUTPUT
3339 echo "version_tag=${VERSION_TAG}" >> $GITHUB_OUTPUT
40+ echo "orch_tag=${ORCH_TAG}" >> $GITHUB_OUTPUT
41+ echo "npm_version=${NPM_VERSION}" >> $GITHUB_OUTPUT
3442 echo "dry_run=${{ env.DRY_RUN }}" >> $GITHUB_OUTPUT
3543 echo "Version: ${VERSION}"
3644 echo "Version Tag: ${VERSION_TAG}"
45+ echo "Orch Tag: ${ORCH_TAG}"
46+ echo "NPM Version: ${NPM_VERSION}"
3747
3848 - name : Download all release assets
3949 env :
4050 GH_TOKEN : ${{ secrets.GOPHER_ORCH_TOKEN }}
4151 run : |
4252 # Download all assets from the private gopher-orch repo
43- gh release download ${{ steps.version.outputs.version_tag }} \
53+ # Use orch_tag (X.Y.Z) to download from gopher-orch, stripping optional .A suffix
54+ gh release download ${{ steps.version.outputs.orch_tag }} \
4455 -R GopherSecurity/gopher-orch \
4556 -D downloads
4657
@@ -125,9 +136,9 @@ jobs:
125136 - name : Update package version
126137 run : |
127138 cd packages/${{ matrix.platform }}
128- VERSION ="${{ needs.download-binaries.outputs.version }}"
129- echo "Setting package version to: ${VERSION }"
130- npm version "$VERSION " --no-git-tag-version --allow-same-version
139+ NPM_VERSION ="${{ needs.download-binaries.outputs.npm_version }}"
140+ echo "Setting package version to: ${NPM_VERSION }"
141+ npm version "$NPM_VERSION " --no-git-tag-version --allow-same-version
131142
132143 - name : Publish to npm
133144 if : ${{ env.DRY_RUN != 'true' }}
@@ -167,32 +178,30 @@ jobs:
167178 - name : Build
168179 run : npm run build
169180
170- - name : Verify package version
181+ - name : Set npm-compatible version
171182 run : |
172- VERSION ="${{ needs.download-binaries.outputs.version }}"
183+ NPM_VERSION ="${{ needs.download-binaries.outputs.npm_version }}"
173184 PKG_VERSION=$(node -p "require('./package.json').version")
174185
175- echo "Expected version: ${VERSION }"
186+ echo "NPM version: ${NPM_VERSION }"
176187 echo "Package version: ${PKG_VERSION}"
177188
178- if [ "${VERSION}" != "${PKG_VERSION}" ]; then
179- echo "⚠ Version mismatch! Updating package.json..."
180- npm version "$VERSION" --no-git-tag-version --allow-same-version
181-
182- # Update optionalDependencies to use the same version
183- node -e "
184- const fs = require('fs');
185- const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
186- if (pkg.optionalDependencies) {
187- for (const dep of Object.keys(pkg.optionalDependencies)) {
188- if (dep.startsWith('@gopher.security/gopher-orch-')) {
189- pkg.optionalDependencies[dep] = '${VERSION}';
190- }
189+ # Always set npm-compatible version (converts X.Y.Z.A to X.Y.Z-A)
190+ npm version "$NPM_VERSION" --no-git-tag-version --allow-same-version
191+
192+ # Update optionalDependencies to use the npm-compatible version
193+ node -e "
194+ const fs = require('fs');
195+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
196+ if (pkg.optionalDependencies) {
197+ for (const dep of Object.keys(pkg.optionalDependencies)) {
198+ if (dep.startsWith('@gopher.security/gopher-orch-')) {
199+ pkg.optionalDependencies[dep] = '${NPM_VERSION}';
191200 }
192- fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
193201 }
202+ fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
203+ }
194204 "
195- fi
196205
197206 echo "Final package.json:"
198207 cat package.json | grep -A 10 optionalDependencies
0 commit comments