From 0b0336f1eae75c654fe9ec0b2369c3589f6eb446 Mon Sep 17 00:00:00 2001 From: zinwang Date: Thu, 7 Aug 2025 12:24:54 +0800 Subject: [PATCH 01/10] Change the trigger time of GitHub release CI to Monday --- .github/workflows/github-release-issue-pr.yml | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index 1decedb7..ec554819 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -3,15 +3,22 @@ name: Generate GitHub Release Issue/PR on: workflow_dispatch: {} schedule: - # Runs at 14:30 Taipei time (UTC+8) on the Wednesday within the first 7 days of each month - # (Since GitHub only accept UTC timezone, convert the trigger time to 6:30 UTC) - - cron: '30 6 1-7 * 3' + # Runs at 08:00 Taipei time (UTC+8) on the Monday within the first 7 days of each month + # (Since GitHub only accept UTC timezone, convert the trigger time to 00:00 UTC) + - cron: '0 0 1-7 * 1' jobs: release: runs-on: ubuntu-latest steps: + - name: Check if this Wednesday is the first one of the Month + run: | + upcoming_wed=$(date -d "next Wednesday" +%-d) + if (( upcoming_wed > 7 )); then + exit 0 + fi + - name: Checkout repository uses: actions/checkout@v4 with: @@ -43,9 +50,9 @@ jobs: echo " " >> ISSUE_BODY.md sudo chmod o+x ISSUE_BODY.md - firstDayOfLastMonth="$(date -d "$(date +%Y-%m-01) -1 month" +'%Y-%m-%d')" - lastDayOfLastMonth="$(date -d "$(date +%Y-%m-01) -1 day" +'%Y-%m-%d')" - lastVersionNum="v$(date -d "$(date +%Y-%m-01) -1 month" +'%y.%-m.1')" + firstDayOfLastMonth="$(date -d "$(date +%Y-%m-01) next Wednesday -1 month" +'%Y-%m-%d')" + lastDayOfLastMonth="$(date -d "$(date +%Y-%m-01) next Wednesday -1 day" +'%Y-%m-%d')" + lastVersionNum="v$(date -d "$(date +%Y-%m-01) next Wednesday -1 month" +'%y.%-m.1')" codex -a auto-edit -q \ """ @@ -56,7 +63,7 @@ jobs: 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] """ - dateInfo=$(date +%y.%-m) + dateInfo=$(date -d "next Wednesday" +%y.%-m) versionNum="v$dateInfo.1" issueNum=$(gh issue create \ From 2f49fe94ad9df17052d673fae171804ace26a676 Mon Sep 17 00:00:00 2001 From: zinwang Date: Thu, 7 Aug 2025 15:48:22 +0800 Subject: [PATCH 02/10] Fix the scripts that fetch date information in GitHub Release CI --- .github/workflows/github-release-draft.yml | 3 +-- .github/workflows/github-release-issue-pr.yml | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/github-release-draft.yml b/.github/workflows/github-release-draft.yml index 326101f0..aaed3648 100644 --- a/.github/workflows/github-release-draft.yml +++ b/.github/workflows/github-release-draft.yml @@ -43,8 +43,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - dateInfo=$(date +%y.%-m) - versionNum="v$dateInfo.1" + versionNum=$(date -d "next Wednesday" +'%y.%-m.1') gh release create "$versionNum" \ --draft \ --title "$versionNum" \ diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index ec554819..8a68eda1 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -50,9 +50,9 @@ jobs: echo " " >> ISSUE_BODY.md sudo chmod o+x ISSUE_BODY.md - firstDayOfLastMonth="$(date -d "$(date +%Y-%m-01) next Wednesday -1 month" +'%Y-%m-%d')" - lastDayOfLastMonth="$(date -d "$(date +%Y-%m-01) next Wednesday -1 day" +'%Y-%m-%d')" - lastVersionNum="v$(date -d "$(date +%Y-%m-01) next Wednesday -1 month" +'%y.%-m.1')" + firstDayOfLastMonth="$(date -d "next Wednesday -1 month" +'%Y-%m-01')" + lastDayOfLastMonth="$(date -d "$(date -d "next Wednesday" +%Y-%m-01) -1 day" +'%Y-%m-%d')" + lastVersionNum="v$(date -d "next Wednesday -1 month" +'%y.%-m.1')" codex -a auto-edit -q \ """ @@ -63,8 +63,7 @@ jobs: 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] """ - dateInfo=$(date -d "next Wednesday" +%y.%-m) - versionNum="v$dateInfo.1" + versionNum=$(date -d "next Wednesday" +'%y.%-m.1') issueNum=$(gh issue create \ --title "Prepare to release version $versionNum" \ From 50b3c25d5f76575012c9a448673ad997a703735b Mon Sep 17 00:00:00 2001 From: zinwang Date: Thu, 7 Aug 2025 16:10:40 +0800 Subject: [PATCH 03/10] Clarify release time for Codex --- .github/workflows/github-release-issue-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index 8a68eda1..94b1b24d 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -102,7 +102,7 @@ jobs: - DESCRIPTION - -- Zin Wong RELEASE_TIME + -- Zin Wong RELEASE_TIME_TODAY for example, From d044870abbd2d16b494235c4cac6da0d013f9754 Mon Sep 17 00:00:00 2001 From: zinwang Date: Thu, 7 Aug 2025 19:05:31 +0800 Subject: [PATCH 04/10] Clarify release time for Codex --- .github/workflows/github-release-issue-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index 94b1b24d..d698a14b 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -77,6 +77,7 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} CODEX_QUIET_MODE: 1 run: | + dateToday="$(TZ=Asia/Taipei date +'%a, %d %b %Y %H:%M:%S %z')" codex -a auto-edit -q \ """ Follow the instructions below to update debian/changelog for $versionNum. @@ -104,7 +105,7 @@ jobs: -- Zin Wong RELEASE_TIME_TODAY - for example, + , where RELEASE_TIME_TODAY is $dateToday. For example, quark-engine (25.1.1-0kali1) kali-dev; urgency=medium From b0973e61402112c207936fa1f9c0eb43a234c0ee Mon Sep 17 00:00:00 2001 From: zinwang Date: Mon, 11 Aug 2025 10:27:11 +0800 Subject: [PATCH 05/10] Fix trigger time for github release CI --- .github/workflows/github-release-issue-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index d698a14b..908a263f 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -3,9 +3,9 @@ name: Generate GitHub Release Issue/PR on: workflow_dispatch: {} schedule: - # Runs at 08:00 Taipei time (UTC+8) on the Monday within the first 7 days of each month + # 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-7 * 1' + - cron: '0 0 * * 1' jobs: release: From 23488e0e579530b5c5133a517d4005bac5a52d22 Mon Sep 17 00:00:00 2001 From: zinwang Date: Mon, 11 Aug 2025 10:28:56 +0800 Subject: [PATCH 06/10] Fix trigger for pypi release to the moment that github release published --- .github/workflows/pythonpublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 6166e044..46aa9c1d 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -2,7 +2,7 @@ name: Upload Python Package on: release: - types: [created] + types: [published] jobs: deploy: From d54c68556f4b410e7953bcbd7f99c9eb4aa2d070 Mon Sep 17 00:00:00 2001 From: zinwang Date: Mon, 11 Aug 2025 12:09:17 +0800 Subject: [PATCH 07/10] Support second or more releases within a month --- .github/workflows/github-release-issue-pr.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index 908a263f..fb30e58b 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -13,9 +13,11 @@ jobs: steps: - name: Check if this Wednesday is the first one of the Month - run: | + run: | upcoming_wed=$(date -d "next Wednesday" +%-d) - if (( upcoming_wed > 7 )); then + if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then + echo "Triggered manually, don't check." + elif (( upcoming_wed > 7 )); then exit 0 fi @@ -52,7 +54,8 @@ jobs: firstDayOfLastMonth="$(date -d "next Wednesday -1 month" +'%Y-%m-01')" lastDayOfLastMonth="$(date -d "$(date -d "next Wednesday" +%Y-%m-01) -1 day" +'%Y-%m-%d')" - lastVersionNum="v$(date -d "next Wednesday -1 month" +'%y.%-m.1')" + git fetch --tags + lastVersionNum="$(git tag --sort=-creatordate | head -n 1)" codex -a auto-edit -q \ """ @@ -64,6 +67,12 @@ jobs: """ versionNum=$(date -d "next Wednesday" +'%y.%-m.1') + releaseMonth=$(echo $versionNum | awk -F. '{printf "%s.%s", $1, $2}') + lastReleaseMonth=$(echo $lastVersionNum | awk -F. '{printf "%s.%s", $1, $2}') + + if [ $releaseMonth = $lastReleaseMonth ]; then + versionNum="$(echo $lastVersionNum | awk -F. -v OFS=. '{$NF+=1; print}')" + fi issueNum=$(gh issue create \ --title "Prepare to release version $versionNum" \ From 4a331901386d2947a70ff692e66163d17a33d643 Mon Sep 17 00:00:00 2001 From: zinwang Date: Mon, 11 Aug 2025 13:52:02 +0800 Subject: [PATCH 08/10] Fix version info parsing error --- .github/workflows/github-release-draft.yml | 2 +- .github/workflows/github-release-issue-pr.yml | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/github-release-draft.yml b/.github/workflows/github-release-draft.yml index aaed3648..1ea4d85c 100644 --- a/.github/workflows/github-release-draft.yml +++ b/.github/workflows/github-release-draft.yml @@ -43,7 +43,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - versionNum=$(date -d "next Wednesday" +'%y.%-m.1') + versionNum="v$(date -d 'next Wednesday' +'%y.%-m.1')" gh release create "$versionNum" \ --draft \ --title "$versionNum" \ diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index fb30e58b..af391734 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -66,11 +66,11 @@ jobs: 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=$(date -d "next Wednesday" +'%y.%-m.1') - releaseMonth=$(echo $versionNum | awk -F. '{printf "%s.%s", $1, $2}') - lastReleaseMonth=$(echo $lastVersionNum | awk -F. '{printf "%s.%s", $1, $2}') + versionNum="v$(date -d "next Wednesday" +'%y.%-m.1')" + releaseMonthInfo=$(echo $versionNum | awk -F. '{printf "%s.%s", $1, $2}') + lastReleaseMonthInfo=$(echo $lastVersionNum | awk -F. '{printf "%s.%s", $1, $2}') - if [ $releaseMonth = $lastReleaseMonth ]; then + if [ $releaseMonthInfo = $lastReleaseMonthInfo ]; then versionNum="$(echo $lastVersionNum | awk -F. -v OFS=. '{$NF+=1; print}')" fi @@ -87,6 +87,7 @@ jobs: 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 -a auto-edit -q \ """ Follow the instructions below to update debian/changelog for $versionNum. @@ -106,7 +107,7 @@ jobs: 4. Use the following template and make sure it follows the Debian changelog format. (Also, use Zin Wong as maintainer's info): - quark-engine (YY.M.1-0kali1) kali-dev; urgency=medium + quark-engine (YY.M.X-0kali1) kali-dev; urgency=medium * TAG @@ -114,7 +115,7 @@ jobs: -- Zin Wong RELEASE_TIME_TODAY - , where RELEASE_TIME_TODAY is $dateToday. For example, + , 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 @@ -132,17 +133,13 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} CODEX_QUIET_MODE: 1 run: | + versionNum=${{ steps.gen_issue.outputs.version }} codex -a auto-edit -q \ """ 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__ - Where YY.MM.X stands for: - - YY: last two digits of the year - - MM: month number - - X: release count within that month (normally 1) - For example, 25.2.1 means the 1st release in February 2025. """ - name: Commit the changes @@ -153,7 +150,8 @@ jobs: git add debian/changelog git add docs/source/conf.py git add quark/__init__.py - git commit -m "Update version information for ${{ steps.gen_issue.outputs.version }}" || echo "No changes to commit" + 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 From e3182d380f46fffc41ba105f14421c19ce298cfd Mon Sep 17 00:00:00 2001 From: zinwang Date: Wed, 13 Aug 2025 14:21:42 +0800 Subject: [PATCH 09/10] Remove unnecessary step id and correct the way to fetch version num in CI for crafting github release draft --- .github/workflows/github-release-draft.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github-release-draft.yml b/.github/workflows/github-release-draft.yml index 1ea4d85c..76d5cf71 100644 --- a/.github/workflows/github-release-draft.yml +++ b/.github/workflows/github-release-draft.yml @@ -27,7 +27,6 @@ jobs: sudo npm install -g @openai/codex@0.1.2505172129 - name: Collect changelog from PR - id: gen_issue env: OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} CODEX_QUIET_MODE: 1 @@ -43,7 +42,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - versionNum="v$(date -d 'next Wednesday' +'%y.%-m.1')" + versionNum=$(echo ${{ github.event.pull_request.title }} | awk '{print $NF}') gh release create "$versionNum" \ --draft \ --title "$versionNum" \ From 8a3203181410b7fd54e0f1f85e8fd5f7a618abf1 Mon Sep 17 00:00:00 2001 From: zinwang Date: Wed, 13 Aug 2025 20:45:39 +0800 Subject: [PATCH 10/10] Clarify and simplify the day check and the way to gather commits for a release in CI for github release --- .github/workflows/github-release-issue-pr.yml | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index af391734..b4630b1a 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -12,13 +12,16 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check if this Wednesday is the first one of the Month + - name: Check if this Wednesday is the first one of the month run: | - upcoming_wed=$(date -d "next Wednesday" +%-d) + upcomingWed=$(date -d "next Wednesday" +%-d) if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then - echo "Triggered manually, don't check." - elif (( upcoming_wed > 7 )); 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." exit 0 + else + echo "Triggered automatically, the week contains the first Wednesday of a month. Continue the process." fi - name: Checkout repository @@ -52,25 +55,23 @@ jobs: echo " " >> ISSUE_BODY.md sudo chmod o+x ISSUE_BODY.md - firstDayOfLastMonth="$(date -d "next Wednesday -1 month" +'%Y-%m-01')" - lastDayOfLastMonth="$(date -d "$(date -d "next Wednesday" +%Y-%m-01) -1 day" +'%Y-%m-%d')" git fetch --tags lastVersionNum="$(git tag --sort=-creatordate | head -n 1)" + monthOfLastRelease=$(echo $lastVersionNum | awk -F. '{print $2}') codex -a auto-edit -q \ """ Follow the following instructions: - 1. Read the git commit messages from $firstDayOfLastMonth to $lastDayOfLastMonth + 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')" - releaseMonthInfo=$(echo $versionNum | awk -F. '{printf "%s.%s", $1, $2}') - lastReleaseMonthInfo=$(echo $lastVersionNum | awk -F. '{printf "%s.%s", $1, $2}') + monthOfThisRelease=$(echo $versionNum | awk -F. '{print $2}') - if [ $releaseMonthInfo = $lastReleaseMonthInfo ]; then + if [ $monthOfThisRelease = $monthOfLastRelease ]; then versionNum="$(echo $lastVersionNum | awk -F. -v OFS=. '{$NF+=1; print}')" fi @@ -92,9 +93,9 @@ jobs: """ 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 last month do. Here are the instructions: + merged PRs since the last release do. Here are the instructions: - 1. First, identify the Pull Requests of last month by reading ISSUE_BODY.md. + 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.] @@ -105,7 +106,7 @@ jobs: 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 as maintainer's info): + (Also, use Zin Wong as the maintainer's info): quark-engine (YY.M.X-0kali1) kali-dev; urgency=medium