maint(resources): improve reporting of status for npm-publish

Build-bot: skip
This commit is contained in:
Marc Durdin 2025-10-28 14:14:42 +01:00
parent 17cc7fd321
commit b582e3c0fb

View file

@ -27,7 +27,8 @@ permissions:
env:
GH_TOKEN: ${{ github.token }}
STATUS_CONTEXT: 'npm pack'
STATUS_CONTEXT: 'npm pack/publish'
IS_TEST_BUILD: ${{ github.event.client_payload.isTestBuild }}
jobs:
npm_publish:
@ -35,14 +36,22 @@ jobs:
if: github.repository == 'keymanapp/keyman' || github.event.client_payload.force
runs-on: ubuntu-24.04
steps:
- name: Set env var for pack vs publish
run: |
if [[ "$IS_TEST_BUILD" == true ]]; then
echo "NPM_ACTION=pack" >> $GITHUB_ENV
else
echo "NPM_ACTION=publish" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
with:
ref: '${{ github.event.client_payload.buildSha }}'
- name: Set pending status on PR builds
- name: Set pending status
id: set_status
if: github.event.client_payload.isTestBuild == 'true'
shell: bash
run: |
gh api \
@ -51,7 +60,7 @@ jobs:
/repos/$GITHUB_REPOSITORY/statuses/${{ github.event.client_payload.buildSha }} \
-f state='pending' \
-f target_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
-f description='npm pack started' \
-f description='npm $NPM_ACTION started' \
-f context="$STATUS_CONTEXT"
- name: Report initial npm/node versions
@ -70,54 +79,48 @@ jobs:
npm -v
node -v
- name: npm pack
if: github.event.client_payload.isTestBuild == 'true'
- name: npm pack/publish
run: |
export KEYMAN_TIER=$(cat TIER.md)
export GHA_TEST_BUILD="${{ github.event.client_payload.isTestBuild }}"
export GHA_BRANCH="${{ github.event.client_payload.branch }}"
if [[ -f ./resources/build/ci/npm-publish.sh ]]; then
./resources/build/ci/npm-publish.sh pack
./resources/build/ci/npm-publish.sh $NPM_ACTION
else
echo WARNING: npm-publish.sh is not yet available on this branch
echo WARNING: npm-publish.sh is not yet available
fi
- name: npm publish
if: github.event.client_payload.isTestBuild == 'false'
run: |
export KEYMAN_TIER=$(cat TIER.md)
export GHA_TEST_BUILD="${{ github.event.client_payload.isTestBuild }}"
export GHA_BRANCH="${{ github.event.client_payload.branch }}"
if [[ -f ./resources/build/ci/npm-publish.sh ]]; then
./resources/build/ci/npm-publish.sh publish
else
echo WARNING: npm-publish.sh is not yet available on this branch
fi
# We intentionally ignore the results of binary_packages_unreleased
set_status:
name: Set result status on PR builds
needs: [npm_publish]
runs-on: ubuntu-latest
if: ${{ always() && github.event.client_payload.isTestBuild == 'true' }}
if: ${{ always() }}
steps:
- name: Set env var for pack vs publish
run: |
if [[ "$IS_TEST_BUILD" == true ]]; then
echo "NPM_ACTION=pack" >> $GITHUB_ENV
else
echo "NPM_ACTION=publish" >> $GITHUB_ENV
fi
- name: Set success
if: needs.npm_publish.result == 'success'
run: |
echo "RESULT=success" >> $GITHUB_ENV
echo "MSG=npm pack succeeded" >> $GITHUB_ENV
echo "MSG=npm $NPM_ACTION succeeded" >> $GITHUB_ENV
- name: Set cancelled
if: needs.npm_publish.result == 'cancelled'
run: |
echo "RESULT=error" >> $GITHUB_ENV
echo "MSG=npm pack cancelled" >> $GITHUB_ENV
echo "MSG=npm $NPM_ACTION cancelled" >> $GITHUB_ENV
- name: Set failure
if: needs.npm_publish.result == 'failure'
run: |
echo "RESULT=failure" >> $GITHUB_ENV
echo "MSG=npm pack failed" >> $GITHUB_ENV
echo "MSG=npm $NPM_ACTION failed" >> $GITHUB_ENV
- name: Set final status
run: |