-
Notifications
You must be signed in to change notification settings - Fork 2
fix(action): allow manual release trigger without releasable commits #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,11 @@ on: | |
| description: 'Optional version to force, for example 1.10.0. Leave empty to use Conventional Commits.' | ||
| type: string | ||
| required: false | ||
| force_release: | ||
| description: 'Force a release workflow by creating one minimal fix commit when no release-worthy commits are detected.' | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
@@ -29,6 +34,21 @@ jobs: | |
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| release-as: ${{ inputs.release_as || '' }} | ||
|
|
||
| - name: Create release trigger commit for manual forced release | ||
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.force_release == true && steps.release.outputs.release_created == 'false' }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On a forced dispatch where releasable commits already exist, release-please can create or update a release PR without publishing a GitHub release, so Useful? React with 👍 / 👎. |
||
| run: | | ||
| set -euo pipefail | ||
| if [ -z "${{ inputs.release_as }}" ]; then | ||
| echo "force_release requested, but release_as is required" >&2 | ||
| exit 1 | ||
| fi | ||
| git config user.name "github-actions[bot]" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When this forced step does run, the only Useful? React with 👍 / 👎. |
||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git checkout main | ||
| git reset --hard origin/main | ||
| git commit --allow-empty -m "fix(action): trigger manual release ${{ inputs.release_as }}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If the push is changed so that it does trigger another run, that run is a Useful? React with 👍 / 👎. |
||
| git push origin HEAD:main | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
After this commit is pushed, the release-please action has already completed, so another workflow run is required to process the new Useful? React with 👍 / 👎. |
||
|
|
||
| # Move the moving major tag here rather than in release-major-tag.yml: a | ||
| # release created with GITHUB_TOKEN does NOT trigger other workflows, so the | ||
| # `release: published` listener wouldn't fire for release-please releases. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When release-please-action v4 creates no release, the root
release_createdoutput is unset rather than the literal string'false'. Consequently, a manual dispatch withforce_release=trueskips this step in exactly the no-release case it is intended to handle; test the output for falsiness or use the aggregatereleases_createdoutput instead.Useful? React with 👍 / 👎.