File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed
Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,17 @@ jobs:
108108 # - `--force` since we're overwriting the `vN` tag
109109 git push origin --atomic --force refs/tags/"${VERSION}" refs/tags/"${major_version_tag}"
110110
111+ - name : Prepare partial Changelog
112+ env :
113+ PARTIAL_CHANGELOG : " ${{ runner.temp }}/partial_changelog.md"
114+ VERSION : " ${{ steps.getVersion.outputs.version }}"
115+ run : |
116+ python .github/workflows/script/prepare_changelog.py CHANGELOG.md "$VERSION" > $PARTIAL_CHANGELOG
117+
118+ echo "::group::Partial CHANGELOG"
119+ cat $PARTIAL_CHANGELOG
120+ echo "::endgroup::"
121+
111122 - name : Create mergeback branch
112123 if : ${{ steps.check.outputs.exists != 'true' && endsWith(github.ref_name, steps.getVersion.outputs.latest_release_branch) }}
113124 env :
@@ -150,3 +161,16 @@ jobs:
150161 --body "${pr_body}" \
151162 --assignee "${GITHUB_ACTOR}" \
152163 --draft
164+
165+ - name : Create the GitHub release
166+ env :
167+ PARTIAL_CHANGELOG : " ${{ runner.temp }}/partial_changelog.md"
168+ VERSION : " ${{ steps.getVersion.outputs.version }}"
169+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
170+ run : |
171+ # Do not mark this release as latest. The most recent CLI release must be marked as latest.
172+ gh release create \
173+ "$VERSION" \
174+ --latest=false \
175+ --title "$VERSION" \
176+ --notes-file "$PARTIAL_CHANGELOG"
Original file line number Diff line number Diff line change 1+ import os
2+ import sys
3+
4+ EMPTY_CHANGELOG = 'No changes.\n \n '
5+
6+ # Prepare the changelog for the new release
7+ # This function will extract the part of the changelog that
8+ # we want to include in the new release.
9+ def extract_changelog_snippet (changelog_file , version_tag ):
10+ output = ''
11+ if (not os .path .exists (changelog_file )):
12+ output = EMPTY_CHANGELOG
13+
14+ else :
15+ with open ('CHANGELOG.md' , 'r' ) as f :
16+ lines = f .readlines ()
17+
18+ # Include everything up to, but excluding the second heading
19+ found_first_section = False
20+ for i , line in enumerate (lines ):
21+ if line .startswith ('## ' ):
22+ if found_first_section :
23+ break
24+ found_first_section = True
25+ output += line
26+
27+ output += f"See the full [CHANGELOG.md](https://github.com/github/codeql-action/blob/{ version_tag } /CHANGELOG.md) for more information."
28+
29+ return output
30+
31+
32+ if len (sys .argv ) < 3 :
33+ raise Exception ('Expecting argument: changelog_file version_tag' )
34+ changelog_file = sys .argv [1 ]
35+ version_tag = sys .argv [2 ]
36+
37+ print (extract_changelog_snippet (changelog_file , version_tag ))
You can’t perform that action at this time.
0 commit comments