diff --git a/.github/workflows/auto-publish-shared.yml b/.github/workflows/auto-publish-shared.yml index 64f382442..320fe4fcd 100644 --- a/.github/workflows/auto-publish-shared.yml +++ b/.github/workflows/auto-publish-shared.yml @@ -1,4 +1,4 @@ -name: Auto-publish shared +name: Maybe auto-release shared on: workflow_call @@ -24,7 +24,8 @@ jobs: if reason=$(npx tsx ./scripts/is-releasable.ts); then echo "ready_to_release=true" >> $GITHUB_OUTPUT else - echo ":see_no_evil: Not releasing because: $reason" >> $GITHUB_STEP_SUMMARY + echo "â„šī¸ Doing no release, just testing if it is otherwise releasable." >> $GITHUB_STEP_SUMMARY + echo "If you want an automatic release, you need to change this: $reason" >> $GITHUB_STEP_SUMMARY echo "ready_to_release=false" >> $GITHUB_OUTPUT fi diff --git a/.github/workflows/npm-publish-switch.yml b/.github/workflows/npm-publish-switch.yml index 17abff957..ec0769793 100644 --- a/.github/workflows/npm-publish-switch.yml +++ b/.github/workflows/npm-publish-switch.yml @@ -1,15 +1,22 @@ name: Release shared +run-name: | + ${{ + github.event_name == 'push' + && 'Maybe release shared automatically' + || 'Release shared explicitly' + }} + # With the trusted publisher model, npm now allows only a single workflow to # be registered as the trusted publisher. But this workflow can then invoke -# other workflows, which may do the actual publishing. +# other workflows, which may do the actual releasing. # So this workflow will act as a switch which: # - If run on main branch as a result of a push, will check try to # automatically release a new version -# - Can be run directly to explicitly publish a new version to npm (which only +# - Can be run directly to explicitly release a new version to npm (which only # makes sense when running it on a branch apart from main, because there the -# auto-publish workflow will take care of it) +# auto-release workflow will take care of it) # # The idea of this setup is also shown in # https://github.com/orgs/community/discussions/174507#discussioncomment-14723818 @@ -27,12 +34,12 @@ on: type: string jobs: - auto-publish: + auto-release: if: ${{ github.event_name == 'push' }} uses: ./.github/workflows/auto-publish-shared.yml secrets: inherit - explicit-publish: + explicit-release: if: ${{ github.event_name == 'workflow_dispatch' }} uses: ./.github/workflows/release-shared.yml with: diff --git a/.github/workflows/release-shared.yml b/.github/workflows/release-shared.yml index 3d141b61b..f612c2ad5 100644 --- a/.github/workflows/release-shared.yml +++ b/.github/workflows/release-shared.yml @@ -1,4 +1,7 @@ -name: Release shared +name: Release shared - Helper workflow + +# This workflow is intended to be invoked by other workflows. +# It is no longer meant to be invoked directly. on: workflow_call: @@ -31,7 +34,7 @@ jobs: - name: Check if release is possible run: | if ! reason=$(npx tsx ./scripts/is-releasable.ts); then - echo "::error::$reason" + echo "🛑 Unable to release: $reason" >> $GITHUB_STEP_SUMMARY exit 1 fi @@ -45,19 +48,23 @@ jobs: run: npx tsx ./scripts/latest-changelog-entry.ts > release_notes.md - - name: Determine next tag - id: determine-next-tag + - name: Determine next version + id: determine-next-version uses: actions/github-script@v7 with: script: | - const version = require('./package.json').version; - core.setOutput('tag', `v${version.replace('.0.0', '')}`); + const version = require('./package.json').version.replace('.0.0', ''); + core.setOutput('version', version); + core.setOutput('tag', `v${version}`); - name: Create GitHub release run: | - gh release create "${{ steps.determine-next-tag.outputs.tag }}" \ - --title "${{ steps.determine-next-tag.outputs.tag }}" \ + gh release create "${{ steps.determine-next-version.outputs.tag }}" \ + --title "${{ steps.determine-next-version.outputs.tag }}" \ --notes-file release_notes.md - name: Publish to npm - run: npm publish + run: | + npm publish + + echo "✅ Successfully released package [pc-nrfconnect-shared@${{ steps.determine-next-version.outputs.version }}](https://www.npmjs.com/package/@nordicsemiconductor/pc-nrfconnect-shared/v/${{ steps.determine-next-version.outputs.version }}.0.0) to npm." >> $GITHUB_STEP_SUMMARY