Skip to content

Commit

Permalink
fix: get correct exit code from npm publish/view (#436)
Browse files Browse the repository at this point in the history
Closes #417
  • Loading branch information
lukekarrys committed Apr 25, 2024
1 parent d0bf7c2 commit 6d54cbf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 46 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/release-integration.yml
Expand Up @@ -58,17 +58,10 @@ jobs:
run: |
EXIT_CODE=0
function each_release {
if npm publish --provenance --tag="$1"; then
echo 0
else
echo 1
fi
}
for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag)
STATUS=$(each_release "$PUBLISH_TAG")
npm publish --provenance --tag="$PUBLISH_TAG"
STATUS=$?
if [[ "$STATUS" -eq 1 ]]; then
EXIT_CODE=$STATUS
fi
Expand Down
13 changes: 3 additions & 10 deletions lib/content/_job-release-integration-yml.hbs
Expand Up @@ -23,22 +23,15 @@ steps:
run: |
EXIT_CODE=0

function each_release {
if {{#if publish}}npm publish --provenance --tag="$1"{{else}}npm view "$@" --loglevel=error > /dev/null{{/if}}; then
echo 0
else
echo 1
fi
}

for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
{{#if publish}}
PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag)
STATUS=$(each_release "$PUBLISH_TAG")
npm publish --provenance --tag="$PUBLISH_TAG"
{{else}}
SPEC="$(echo "$release" | base64 --decode | jq -r .pkgName)@$(echo "$release" | base64 --decode | jq -r .version)"
STATUS=$(each_release "$SPEC")
npm view "$SPEC" --json
{{/if}}
STATUS=$?
if [[ "$STATUS" -eq 1 ]]; then
EXIT_CODE=$STATUS
{{#unless publish}}
Expand Down
33 changes: 6 additions & 27 deletions tap-snapshots/test/apply/source-snapshots.js.test.cjs
Expand Up @@ -889,17 +889,10 @@ jobs:
run: |
EXIT_CODE=0
function each_release {
if npm view "$@" --loglevel=error > /dev/null; then
echo 0
else
echo 1
fi
}
for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
SPEC="$(echo "$release" | base64 --decode | jq -r .pkgName)@$(echo "$release" | base64 --decode | jq -r .version)"
STATUS=$(each_release "$SPEC")
npm view "$SPEC" --json
STATUS=$?
if [[ "$STATUS" -eq 1 ]]; then
EXIT_CODE=$STATUS
echo "$SPEC ERROR"
Expand Down Expand Up @@ -2526,17 +2519,10 @@ jobs:
run: |
EXIT_CODE=0
function each_release {
if npm view "$@" --loglevel=error > /dev/null; then
echo 0
else
echo 1
fi
}
for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
SPEC="$(echo "$release" | base64 --decode | jq -r .pkgName)@$(echo "$release" | base64 --decode | jq -r .version)"
STATUS=$(each_release "$SPEC")
npm view "$SPEC" --json
STATUS=$?
if [[ "$STATUS" -eq 1 ]]; then
EXIT_CODE=$STATUS
echo "$SPEC ERROR"
Expand Down Expand Up @@ -4035,17 +4021,10 @@ jobs:
run: |
EXIT_CODE=0
function each_release {
if npm view "$@" --loglevel=error > /dev/null; then
echo 0
else
echo 1
fi
}
for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
SPEC="$(echo "$release" | base64 --decode | jq -r .pkgName)@$(echo "$release" | base64 --decode | jq -r .version)"
STATUS=$(each_release "$SPEC")
npm view "$SPEC" --json
STATUS=$?
if [[ "$STATUS" -eq 1 ]]; then
EXIT_CODE=$STATUS
echo "$SPEC ERROR"
Expand Down

0 comments on commit 6d54cbf

Please sign in to comment.