File tree Expand file tree Collapse file tree 2 files changed +51
-3
lines changed Expand file tree Collapse file tree 2 files changed +51
-3
lines changed Original file line number Diff line number Diff line change @@ -151,13 +151,24 @@ jobs:
151
151
--assignee "${GITHUB_ACTOR}" \
152
152
--draft
153
153
154
+
155
+ - name : Prepare the partial Changelog
156
+ env :
157
+ VERSION : " ${{ steps.getVersion.outputs.version }}"
158
+ PARTIAL_CHANGELOG : " ${{ runner.temp }}/partial_changelog.md"
159
+ run : |
160
+ # Prepare the partial changelog for the release notes
161
+ python .github/workflows/script/prepare_changelog.py CHANGELOG.md "$VERSION"> $PARTIAL_CHANGELOG
162
+
154
163
- name : Create the GitHub release
155
164
env :
156
165
VERSION : " ${{ steps.getVersion.outputs.version }}"
166
+ PARTIAL_CHANGELOG : " ${{ runner.temp }}/partial_changelog.md"
167
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
157
168
run : |
158
169
# Do not mark this release as latest. The most recent CLI release must be marked as latest.
159
170
gh release create \
160
- "${ VERSION} " \
171
+ "$VERSION" \
161
172
--latest=false \
162
- -t "${ VERSION} " \
163
- -F CHANGELOG.md
173
+ -t "$VERSION" \
174
+ -F "$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