-
Notifications
You must be signed in to change notification settings - Fork 365
Create a GitHub release for each action release #2517
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 |
---|---|---|
|
@@ -108,6 +108,17 @@ jobs: | |
# - `--force` since we're overwriting the `vN` tag | ||
git push origin --atomic --force refs/tags/"${VERSION}" refs/tags/"${major_version_tag}" | ||
|
||
- name: Prepare partial Changelog | ||
env: | ||
PARTIAL_CHANGELOG: "${{ runner.temp }}/partial_changelog.md" | ||
VERSION: "${{ steps.getVersion.outputs.version }}" | ||
run: | | ||
python .github/workflows/script/prepare_changelog.py CHANGELOG.md "$VERSION" > $PARTIAL_CHANGELOG | ||
|
||
echo "::group::Partial CHANGELOG" | ||
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. 👍🏻 I like this change! Makes it easier to see what the changelog looked like at the time of generation! |
||
cat $PARTIAL_CHANGELOG | ||
echo "::endgroup::" | ||
|
||
- name: Create mergeback branch | ||
if: ${{ steps.check.outputs.exists != 'true' && endsWith(github.ref_name, steps.getVersion.outputs.latest_release_branch) }} | ||
env: | ||
|
@@ -150,3 +161,16 @@ jobs: | |
--body "${pr_body}" \ | ||
--assignee "${GITHUB_ACTOR}" \ | ||
--draft | ||
|
||
- name: Create the GitHub release | ||
env: | ||
PARTIAL_CHANGELOG: "${{ runner.temp }}/partial_changelog.md" | ||
VERSION: "${{ steps.getVersion.outputs.version }}" | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Do not mark this release as latest. The most recent CLI release must be marked as latest. | ||
gh release create \ | ||
"$VERSION" \ | ||
--latest=false \ | ||
--title "$VERSION" \ | ||
--notes-file "$PARTIAL_CHANGELOG" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import sys | ||
|
||
EMPTY_CHANGELOG = 'No changes.\n\n' | ||
|
||
# Prepare the changelog for the new release | ||
# This function will extract the part of the changelog that | ||
# we want to include in the new release. | ||
def extract_changelog_snippet(changelog_file, version_tag): | ||
output = '' | ||
if (not os.path.exists(changelog_file)): | ||
output = EMPTY_CHANGELOG | ||
|
||
else: | ||
with open('CHANGELOG.md', 'r') as f: | ||
lines = f.readlines() | ||
|
||
# Include everything up to, but excluding the second heading | ||
found_first_section = False | ||
for i, line in enumerate(lines): | ||
if line.startswith('## '): | ||
if found_first_section: | ||
break | ||
found_first_section = True | ||
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. The way this works is by appending lines until the a second In the test run, the release notes it created contain the header 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. Hmmm...I'd originally thought that this was because I didn't start on a release branch, but now I'm not so sure. I'll have to take a deeper look. 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. OK...there were two things going on:
I've now fixed 2. I also added a few cleanups. |
||
output += line | ||
|
||
output += f"See the full [CHANGELOG.md](https://github.com/github/codeql-action/blob/{version_tag}/CHANGELOG.md) for more information." | ||
|
||
return output | ||
|
||
|
||
if len(sys.argv) < 3: | ||
raise Exception('Expecting argument: changelog_file version_tag') | ||
changelog_file = sys.argv[1] | ||
version_tag = sys.argv[2] | ||
|
||
print(extract_changelog_snippet(changelog_file, version_tag)) |
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.
Just one nitpick, can be merged as is:
I think we can pull this at a higher level in the workflow file, and then the
PARTIAL_CHANGELOG
variable will be shared between the different steps. The benefit this brings is that if at any point we need to change it, it will be changed at both of the steps that require the same file, instead of having to change two separate definitions of the variable, minimising the chance of the two variables being out of sync and causing a bug by accident.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.
I tried that earlier and unfortunately, and
runner.temp
is not initialized at the job level. I thought this way was safer than trying to hard code the temp directory.