Skip to content

Commit e5cccc1

Browse files
authored
fix(release): one GitHub release step, not two (#46)
The v2.0.1 release failed: HTTP 422: Validation Failed Release.tag_name already exists release.yml carried the step twice. The first named the release for the version with the v stripped, which is how the 2.0.0 and 2.0.1 releases already on this repository were created, so creating 2.0.1 a second time was refused. The duplicate arrived when the v-prefix change was applied on top of a file that already had the step. The two are merged into one: the changelog lookup and the install line from the first, the existence guard from the second, and the release named for the tag rather than the stripped version, so a vX.Y.Z tag produces a vX.Y.Z release. The bare 2.0.0 and 2.0.1 releases are left alone. They point at the tags that were actually published, and renaming them would break any link anyone holds.
1 parent 472e9de commit e5cccc1

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,37 +71,20 @@ jobs:
7171
env:
7272
GH_TOKEN: ${{ github.token }}
7373
run: |
74-
# Every tag in this repository, and in api-reference, carries the v. The version
75-
# inside the package never does, so the tag is compared with it stripped.
76-
TAG="${GITHUB_REF_NAME#v}"
77-
NOTES="$(awk -v tag="$TAG" '
78-
$0 ~ "^## \\[?" tag {found=1; next}
79-
found && /^## / {exit}
80-
found {print}
81-
' CHANGELOG.md)"
82-
[ -n "$NOTES" ] || NOTES="See CHANGELOG.md for the changes in $TAG."
83-
printf '%s\n\n---\n\nInstall: `pip install flat-api==%s`\n' "$NOTES" "$TAG" \
84-
> /tmp/notes.md
85-
gh release create "$TAG" --title "$TAG" --notes-file /tmp/notes.md --verify-tag
86-
87-
# The tag alone left the repository's Releases page showing a version from years ago as
88-
# "Latest", which is what anyone browsing the repository sees first. The notes come from the
89-
# CHANGELOG section for this version, so the release says what changed rather than nothing.
90-
- name: Publish the GitHub release
91-
env:
92-
GH_TOKEN: ${{ github.token }}
93-
run: |
74+
# The release is named for the tag. The version inside the package never carries the v,
75+
# so the changelog lookup and the install line use it stripped.
9476
VERSION="${GITHUB_REF_NAME#v}"
9577
NOTES="$(awk -v v="$VERSION" '
9678
$0 ~ "^## \\[?" v "\\]?" { found = 1; next }
9779
found && /^## / { exit }
9880
found { print }
9981
' CHANGELOG.md)"
10082
[ -n "$NOTES" ] || NOTES="See CHANGELOG.md for $VERSION."
83+
printf '%s\n\n---\n\nInstall: `pip install flat-api==%s`\n' "$NOTES" "$VERSION" > /tmp/notes.md
10184
# Creating one that exists is an error, and a re-run of a release that already happened
10285
# should be a no-op rather than a red build.
10386
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
10487
echo "Release $GITHUB_REF_NAME already exists; nothing to do."
10588
else
106-
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes "$NOTES"
89+
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file /tmp/notes.md --verify-tag
10790
fi

0 commit comments

Comments
 (0)