Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/release-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
- name: Publish
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
RELEASES: ${{ inputs.releases }}
run: |
EXIT_CODE=0

Expand All @@ -65,7 +66,7 @@ jobs:
fi
}

for release in $(echo '${{ inputs.releases }}' | jq -r '.[] | @base64'); do
for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag)
STATUS=$(each_release "$PUBLISH_TAG")
if [[ "$STATUS" -eq 1 ]]; then
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.21.3",
"publish": true
"publish": true,
"content": "./scripts/template-oss"
},
"tap": {
"nyc-arg": [
Expand Down
52 changes: 52 additions & 0 deletions scripts/template-oss/_job-release-integration-yml.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: {{#if publish}}Publish{{else}}Check Publish{{/if}}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
{{#if publish}}
permissions:
id-token: write
{{/if}}
steps:
{{#if publish}}
{{> stepsSetupYml jobCheckout=(obj ref="${{ fromJSON(inputs.releases)[0].tagName }}") }}
- name: Set npm authToken
run: npm config set '//registry.npmjs.org/:_authToken'=\${PUBLISH_TOKEN}
- name: Publish
env:
PUBLISH_TOKEN: $\{{ secrets.PUBLISH_TOKEN }}
RELEASES: $\{{ inputs.releases }}
{{else}}
{{> stepsSetupYml }}
- name: Check If Published
{{/if}}
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")
{{else}}
SPEC="$(echo "$release" | base64 --decode | jq -r .pkgName)@$(echo "$release" | base64 --decode | jq -r .version)"
STATUS=$(each_release "$SPEC")
{{/if}}
if [[ "$STATUS" -eq 1 ]]; then
EXIT_CODE=$STATUS
{{#unless publish}}
echo "$SPEC ERROR"
else
echo "$SPEC OK"
{{/unless}}
fi
done

exit $EXIT_CODE
Copy link
Contributor Author

@lukekarrys lukekarrys Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should get ported back to @npmcli/template-oss once we confirm it works.