Skip to content

Commit b216c26

Browse files
committed
fix(angular): Angular-Slickgrid npm publish should replace workspace:
1 parent d9d48a2 commit b216c26

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

.github/workflows/publish-npm-latest.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,26 @@ jobs:
128128
shell: bash
129129
id: lerna-publish
130130
run: |
131-
# Attempt to publish all packages
132-
pnpm exec lerna publish from-package --force-publish --yes --otp ${{ steps.wait-for-secrets.outputs.OTP }}
133-
EXIT_CODE=$?
134-
echo "EXIT_CODE=$EXIT_CODE" >> $GITHUB_ENV
135-
OUTPUT=$(cat /dev/stdout)
136-
echo "OUTPUT=$OUTPUT" >> $GITHUB_ENV
131+
set -o pipefail
132+
OUTPUT_FILE=$(mktemp)
133+
pnpm exec lerna publish from-package --force-publish --yes --otp ${{ steps.wait-for-secrets.outputs.OTP }} 2>&1 | tee $OUTPUT_FILE
134+
EXIT_CODE=${PIPESTATUS[0]}
135+
OUTPUT=$(cat $OUTPUT_FILE)
136+
echo "publish_failed=false" >> $GITHUB_OUTPUT
137+
echo "publish_output<<EOF" >> $GITHUB_OUTPUT
138+
echo "$OUTPUT" >> $GITHUB_OUTPUT
139+
echo "EOF" >> $GITHUB_OUTPUT
137140
if [ $EXIT_CODE -ne 0 ]; then
138-
echo "::set-output name=publish_failed::true"
141+
if echo "$OUTPUT" | grep -q 'HttpErrorAuthOTP'; then
142+
echo "publish_failed=true" >> $GITHUB_OUTPUT
143+
else
144+
echo "::error title=Lerna Publish Failed::$OUTPUT"
145+
exit $EXIT_CODE
146+
fi
139147
fi
140148
141149
- name: Check for EOTP and Prompt for New OTP
142-
if: ${{ steps.lerna-publish.outputs.publish_failed == 'true' && contains(env.OUTPUT, 'HttpErrorAuthOTP') }}
150+
if: ${{ steps.lerna-publish.outputs.publish_failed == 'true' }}
143151
uses: step-security/wait-for-secrets@v1
144152
id: wait-for-new-otp
145153
with:
@@ -149,14 +157,13 @@ jobs:
149157
description: 'OTP from authenticator app'
150158
151159
- name: Retry Lerna Publish with New OTP
152-
if: ${{ steps.lerna-publish.outputs.publish_failed == 'true' && contains(env.OUTPUT, 'HttpErrorAuthOTP') }}
160+
if: ${{ steps.lerna-publish.outputs.publish_failed == 'true' }}
153161
env:
154162
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155163
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
156164
NPM_CONFIG_PROVENANCE: true
157165
shell: bash
158166
run: |
159-
# Retry the publish command with the new OTP
160167
pnpm exec lerna publish from-package --force-publish --yes --otp ${{ steps.wait-for-new-otp.outputs.OTP }} || {
161168
echo "::error title=Publish Failed::Publishing failed even after providing a new OTP."
162169
exit 1

frameworks/angular-slickgrid/scripts/replace-workspace.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ const projectRootPath = pJoin(__dirname, '../');
1212
* with current version from "package.json" root into "dist/package.json"
1313
*/
1414
(async function main() {
15-
const rootPkg = readJSONSync(pJoin(projectRootPath, 'package.json'));
1615
const distPkg = readJSONSync(pJoin(projectRootPath, 'dist', 'package.json'));
17-
const currentVersion = rootPkg.version;
1816

1917
// replace all workspace protocol with current version from "package.json" root into "dist/package.json"
2018
console.log('-------------------------------------------------------------------------------------');
21-
console.log(`- Angular-Slickgrid, replace all "workspace:*" with "${currentVersion}" in "dist/package.json"`);
19+
console.log(`Angular-Slickgrid, replace all "workspace:*" protocol in "dist/package.json"`);
2220
for (let [depName, depVersion] of Object.entries(distPkg.dependencies)) {
2321
if (depVersion.startsWith('workspace:*')) {
24-
distPkg.dependencies[depName] = currentVersion;
22+
// we need to get each package version
23+
const depPkgName = depName.replace('@slickgrid-universal', '');
24+
const depPkg = readJSONSync(pJoin(projectRootPath, '../../packages/', depPkgName, 'package.json'));
25+
distPkg.dependencies[depName] = depPkg.version;
26+
console.log(`replace "${depName}" dependency to "${depPkg.version}"`);
2527
}
2628
}
2729
writeJsonSync(pResolve(projectRootPath, 'dist', 'package.json'), distPkg, { spaces: 2 });

0 commit comments

Comments
 (0)