-
-
Notifications
You must be signed in to change notification settings - Fork 54
Create releases from the release workflow #151
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
717bec2
Use shared .NET build action
Kralizek 1176204
Create releases from the publish workflow
Kralizek b85ef5e
Make manual releases retry-safe
Kralizek 2bf002c
Resume existing draft release before version calculation
Kralizek 006c26d
Avoid duplicate publication for workflow-created releases
Kralizek e046f82
Extract resumable release detection script
Kralizek a6b4e41
Move draft release detection into script
Kralizek be57ef0
Move release script under workflows
Kralizek 9d0fe7e
Use workflow-local release script
Kralizek bbb92cd
Remove old release script location
Kralizek 0788bdc
Extract draft release creation script
Kralizek 1ef0dc4
Use script for draft release creation
Kralizek ac1bb1b
Make release resume detection idempotent
Kralizek b90e26c
Fix dry-run and published release retries
Kralizek 4025b54
Make draft release recovery independent of current HEAD
Kralizek a2d712c
Make manual release recovery resilient to master advancing
Kralizek 517c09c
Scope resumable drafts to current commit
Kralizek 624f513
Update shared actions to v0.3
Kralizek ccf146c
Update shared actions to v0.3
Kralizek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
.github/workflows/scripts/create-or-reuse-draft-release.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| : "${GH_TOKEN:?GH_TOKEN must be set}" | ||
| : "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY must be set}" | ||
| : "${GITHUB_SHA:?GITHUB_SHA must be set}" | ||
| : "${TAG:?TAG must be set}" | ||
| : "${RELEASE_CHANNEL:?RELEASE_CHANNEL must be set}" | ||
| : "${RESUME:?RESUME must be set}" | ||
|
|
||
| if [[ "$RESUME" == "true" ]]; then | ||
| echo "Reusing draft release $TAG." | ||
| exit 0 | ||
| fi | ||
|
|
||
| args=( | ||
| "$TAG" | ||
| --repo "$GITHUB_REPOSITORY" | ||
| --target "$GITHUB_SHA" | ||
| --title "$TAG" | ||
| --generate-notes | ||
| --draft | ||
| ) | ||
|
|
||
| if [[ -n "${PREVIOUS_TAG:-}" ]]; then | ||
| args+=(--notes-start-tag "$PREVIOUS_TAG") | ||
| fi | ||
|
|
||
| if [[ "$RELEASE_CHANNEL" != "stable" ]]; then | ||
| args+=(--prerelease) | ||
| fi | ||
|
|
||
| gh release create "${args[@]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| : "${GH_TOKEN:?GH_TOKEN must be set}" | ||
| : "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY must be set}" | ||
| : "${GITHUB_SHA:?GITHUB_SHA must be set}" | ||
| : "${RELEASE_CHANNEL:?RELEASE_CHANNEL must be set}" | ||
| : "${GITHUB_OUTPUT:?GITHUB_OUTPUT must be set}" | ||
|
|
||
| releases=$(gh api --paginate "repos/${GITHUB_REPOSITORY}/releases?per_page=100") | ||
|
|
||
| if [[ "$RELEASE_CHANNEL" == "stable" ]]; then | ||
| pattern='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$' | ||
| else | ||
| pattern="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-${RELEASE_CHANNEL}\\.[0-9]+$" | ||
| fi | ||
|
|
||
| mapfile -t matching_releases < <( | ||
| jq -rc \ | ||
| --arg pattern "$pattern" \ | ||
| --arg sha "$GITHUB_SHA" \ | ||
| '.[] | ||
| | select(.draft == true) | ||
| | select(.author.login == "github-actions[bot]") | ||
| | select(.target_commitish == $sha) | ||
| | select(.tag_name | test($pattern)) | ||
| | {tag: .tag_name, target: .target_commitish}' \ | ||
| <<< "$releases" | ||
| ) | ||
|
|
||
| if (( ${#matching_releases[@]} > 1 )); then | ||
| tags=$(printf '%s\n' "${matching_releases[@]}" | jq -r .tag | paste -sd ' ' -) | ||
| echo "Multiple resumable draft releases match channel $RELEASE_CHANNEL: $tags" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if (( ${#matching_releases[@]} == 1 )); then | ||
| release="${matching_releases[0]}" | ||
| tag=$(jq -r .tag <<< "$release") | ||
| target=$(jq -r .target <<< "$release") | ||
|
|
||
| echo "Resuming draft release $tag at $target." | ||
| echo "resume=true" >> "$GITHUB_OUTPUT" | ||
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | ||
| echo "version=${tag#v}" >> "$GITHUB_OUTPUT" | ||
| echo "target=$target" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "resume=false" >> "$GITHUB_OUTPUT" | ||
| fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.