forked from ev-flow/quark-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (133 loc) · 6.87 KB
/
Copy pathgithub-release-issue-pr.yml
File metadata and controls
166 lines (133 loc) · 6.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Generate GitHub Release Issue/PR
on:
workflow_dispatch: {}
schedule:
# Runs at 08:00 Taipei time (UTC+8) on Monday.
# (Since GitHub only accept UTC timezone, convert the trigger time to 00:00 UTC)
- cron: '0 0 * * 1'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if this Wednesday is the first one of the month
env:
GH_TOKEN: ${{ github.token }}
run: |
upcomingWed=$(date -d "next Wednesday" +%-d)
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
echo "Triggered manually, don't check if the week contains the first Wednesday of a month. Continue the process."
elif (( upcomingWed > 7 )); then
echo "Triggered automatically, the week does not contain the first Wednesday of a month. End the process."
gh run cancel ${{ github.run_id }}
sleep infinity
else
echo "Triggered automatically, the week contains the first Wednesday of a month. Continue the process."
fi
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Install Codex CLI
run: |
sudo npm install -g @openai/codex@0.110.0
- name: Install dependencies
run: |
sudo apt install git
- name: Generate PR summary issue
id: gen_issue
env:
CODEX_API_KEY: ${{ secrets.OPENAI_KEY }}
CODEX_QUIET_MODE: 1
GH_TOKEN: ${{ github.token }}
run: |
echo "Update the version number for releasing the latest version of Quark." > ISSUE_BODY.md
echo "In this version, the following changes will be included." >> ISSUE_BODY.md
echo " " >> ISSUE_BODY.md
sudo chmod o+x ISSUE_BODY.md
git fetch --tags
lastVersionNum="$(git tag --sort=-creatordate | head -n 1)"
monthOfLastRelease=$(echo $lastVersionNum | awk -F. '{print $2}')
codex exec --full-auto \
"""
Follow the following instructions:
1. Read the git commit messages from the month $monthOfLastRelease of this year.
2. Show all the commit messages after the “Update version information to $lastVersionNum” commit.
3. Show the #Numbers in those commit messages in Step 2.
4. Append the #Numbers in Step 3. after the content of ISSUE_BODY.md [with the format - #Number (e.g. - #761), one number a line]
"""
versionNum="v$(date -d "next Wednesday" +'%y.%-m.1')"
monthOfThisRelease=$(echo $versionNum | awk -F. '{print $2}')
if [ $monthOfThisRelease = $monthOfLastRelease ]; then
versionNum="$(echo $lastVersionNum | awk -F. -v OFS=. '{$NF+=1; print}')"
fi
issueNum=$(gh issue create \
--title "Prepare to release version $versionNum" \
--body-file ISSUE_BODY.md | awk -F"/" '{print $NF}')
echo "version=$versionNum" >> $GITHUB_OUTPUT
echo "issue=$issueNum" >> $GITHUB_OUTPUT
- name: Update changelog for Kali package
env:
CODEX_API_KEY: ${{ secrets.OPENAI_KEY }}
CODEX_QUIET_MODE: 1
run: |
dateToday="$(TZ=Asia/Taipei date +'%a, %d %b %Y %H:%M:%S %z')"
versionNum=${{ steps.gen_issue.outputs.version }}
codex exec --full-auto \
"""
Follow the instructions below to update debian/changelog for $versionNum.
In debian/changelog, you are going to append a new section, and describe what the new
merged PRs since the last release do. Here are the instructions:
1. First, identify the Pull Requests since the last release by reading ISSUE_BODY.md.
2. Next, for each Pull Request, choose a proper tag for it.
A tag could be from [Rule Enhancement/Document Enhancement/New Feature/Bug Fix/Dependency Update/etc.]
You can reference the previous changelog to see if the tag matches the Pull Requests.
Or, if the Pull Requests are something we have never done before, try to give them a proper name.
3. Then, combine those descriptions that are similar. For example,
Optimize the Quark Script documents for CWE-328, CWE-338, and CWE-489. (#754, #756, and #757)
4. Use the following template and make sure it follows the Debian changelog format.
(Also, use Zin Wong <chriswangxxxxx@gmail.com> as the maintainer's info):
quark-engine (YY.M.X-0kali1) kali-dev; urgency=medium
* TAG
- DESCRIPTION
-- Zin Wong <chriswangxxxxx@gmail.com> RELEASE_TIME_TODAY
, where YY.M.X should align with $versionNum and RELEASE_TIME_TODAY is $dateToday. For example,
quark-engine (25.1.1-0kali1) kali-dev; urgency=medium
* Document Enhancement
- Optimize the Quark Script documents for CWE-94, CWE-798, and CWE-921. (#724, #722, and #723)
-- Zin Wong <chriswangxxxxx@gmail.com> Tue, 01 Jan 2025 20:00:00 +0800
"""
rm ISSUE_BODY.md
- name: Update version information
env:
CODEX_API_KEY: ${{ secrets.OPENAI_KEY }}
CODEX_QUIET_MODE: 1
run: |
versionNum=${{ steps.gen_issue.outputs.version }}
codex exec --full-auto \
"""
Update version information in the following files for next release $versionNum:
1. debian/control: Standards-Version
2. docs/source/conf.py: release
3. quark/__init__.py: __version__
"""
- name: Commit the changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add debian/control
git add debian/changelog
git add docs/source/conf.py
git add quark/__init__.py
versionNum=${{ steps.gen_issue.outputs.version }}
git commit -m "Update version information for $versionNum" || echo "No changes to commit"
- name: Create pull request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: "update_version_info_${{ steps.gen_issue.outputs.version }}"
title: "Update version information to ${{ steps.gen_issue.outputs.version }}"
body: "Resolves #${{ steps.gen_issue.outputs.issue }}."