From 49a67184b555d30b054125ed0f05a8a3acca47f2 Mon Sep 17 00:00:00 2001 From: zinwang Date: Tue, 1 Jul 2025 06:47:57 +0800 Subject: [PATCH 1/8] Add automation to make github-release automatically --- .github/workflows/github-release.yml | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/github-release.yml diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml new file mode 100644 index 00000000..64000339 --- /dev/null +++ b/.github/workflows/github-release.yml @@ -0,0 +1,80 @@ +name: Monthly Codex CI + +on: + push: + branches: [ master ] + schedule: + # Runs at 00:00 UTC on the first day of each month + - cron: '45 6 1 * *' + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - 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.1.2505172129 + + - name: Generate commit summary issue + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} + CODEX_QUIET_MODE: 1 + GH_TOKEN: ${{ github.token }} + run: | + # Create a file listing all commits in the last month + codex --version + codex -a auto-edit -q \ + "create ISSUE_BODY.md listing all commits since one month ago in markdown format" + # Open a GitHub issue with that body + gh issue create \ + --title "Monthly Commits for $(date '+%B %Y')" \ + --body-file ISSUE_BODY.md + + - name: Update CHANGELOG + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} + CODEX_QUIET_MODE: 1 + run: | + codex -a auto-edit -q \ + "update CHANGELOG.md by adding a new section for $(date '+%B %Y') summarizing commits from the last month" + + - name: Commit CHANGELOG updates + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + # git add CHANGELOG.md + # git commit -m "docs: update CHANGELOG for $(date '+%B %Y')" || echo "No changes to commit" + + - name: Bump version info + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} + CODEX_QUIET_MODE: 1 + run: | + codex -a auto-edit -q \ + "Update version information in the following files for next release: + 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: Create pull request for version bump + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: bump version for next release" + title: "chore: bump version and update CHANGELOG for $(date '+%B %Y')" + body: | + This PR updates the version information and CHANGELOG for the upcoming release. From 8a8abc47c9697cdce119ab9e84299b2d93abbda4 Mon Sep 17 00:00:00 2001 From: zinwang Date: Mon, 4 Aug 2025 13:36:04 +0800 Subject: [PATCH 2/8] Automate GitHub release with Codex and GitHub Action --- .github/workflows/github-release-draft.yml | 51 ++++++ .github/workflows/github-release-issue-pr.yml | 156 ++++++++++++++++++ .github/workflows/github-release.yml | 80 --------- 3 files changed, 207 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/github-release-draft.yml create mode 100644 .github/workflows/github-release-issue-pr.yml delete mode 100644 .github/workflows/github-release.yml diff --git a/.github/workflows/github-release-draft.yml b/.github/workflows/github-release-draft.yml new file mode 100644 index 00000000..e6b41ee5 --- /dev/null +++ b/.github/workflows/github-release-draft.yml @@ -0,0 +1,51 @@ +name: Generate GitHub Release Draft + +on: + pull_request: + types: [closed] + +jobs: + on-merge: + if: | + (github.event.pull_request.merged == true + && startsWith(github.event.pull_request.title, 'Update version information to')) + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.merge_commit_sha }} + fetch-depth: 0 + + - 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.1.2505172129 + + - name: Generate PR summary issue + id: gen_issue + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} + CODEX_QUIET_MODE: 1 + GH_TOKEN: ${{ github.token }} + run: | + sed '/--/q' debian/changelog | sed '1, 2d' | head -n -2 > changelog.txt + codex -a auto-edit -q \ + """ + Remove the '*' and indent in changelog.txt. + """ + + - name: Create Release Draft + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + dateInfo=$(date +%y.%-m) + versionNum="v$dateInfo.1" + gh release create "$versionNum" \ + --draft \ + --title "$versionNum" \ + --notes "$(cat changelog.txt)" diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml new file mode 100644 index 00000000..d7bcbf6b --- /dev/null +++ b/.github/workflows/github-release-issue-pr.yml @@ -0,0 +1,156 @@ +name: Generate GitHub Release Issue/PR + +on: + push: + branches: [ master ] + schedule: + # Runs at 00:00 UTC on the Monday within the first 7 days of each month + - cron: '0 0 1-7 * 1' + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Check if this Wednesday is the first of a 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: + fetch-depth: 0 + + - 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.1.2505172129 + + - name: Install dependencies + run: | + sudo apt install git + + - name: Generate PR summary issue + id: gen_issue + env: + OPENAI_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 + + 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 \ + """ + Follow the following instructions: + 1. Read the git commit messages from $firstDayOfLastMonth to $lastDayOfLastMonth + 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] + """ + + dateInfo=$(date -d "next Wednesday" +%y.%-m) + versionNum="v$dateInfo.1" + + 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: + OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} + CODEX_QUIET_MODE: 1 + run: | + codex -a auto-edit -q \ + """ + 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: + + 1. First, identify the Pull Requests of last month 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 as maintainer's info): + + quark-engine (YY.M.1-0kali1) kali-dev; urgency=medium + + * TAG + + - DESCRIPTION + + -- Zin Wong RELEASE_TIME + + 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 Tue, 01 Jan 2025 20:00:00 +0800 + + """ + rm ISSUE_BODY.md + + - name: Update version information + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} + CODEX_QUIET_MODE: 1 + run: | + 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 + 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 + git commit -m "Update version information for ${{ steps.gen_issue.outputs.version }}" || 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 }}. diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml deleted file mode 100644 index 64000339..00000000 --- a/.github/workflows/github-release.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Monthly Codex CI - -on: - push: - branches: [ master ] - schedule: - # Runs at 00:00 UTC on the first day of each month - - cron: '45 6 1 * *' - -jobs: - release: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - 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.1.2505172129 - - - name: Generate commit summary issue - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} - CODEX_QUIET_MODE: 1 - GH_TOKEN: ${{ github.token }} - run: | - # Create a file listing all commits in the last month - codex --version - codex -a auto-edit -q \ - "create ISSUE_BODY.md listing all commits since one month ago in markdown format" - # Open a GitHub issue with that body - gh issue create \ - --title "Monthly Commits for $(date '+%B %Y')" \ - --body-file ISSUE_BODY.md - - - name: Update CHANGELOG - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} - CODEX_QUIET_MODE: 1 - run: | - codex -a auto-edit -q \ - "update CHANGELOG.md by adding a new section for $(date '+%B %Y') summarizing commits from the last month" - - - name: Commit CHANGELOG updates - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - # git add CHANGELOG.md - # git commit -m "docs: update CHANGELOG for $(date '+%B %Y')" || echo "No changes to commit" - - - name: Bump version info - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} - CODEX_QUIET_MODE: 1 - run: | - codex -a auto-edit -q \ - "Update version information in the following files for next release: - 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: Create pull request for version bump - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "chore: bump version for next release" - title: "chore: bump version and update CHANGELOG for $(date '+%B %Y')" - body: | - This PR updates the version information and CHANGELOG for the upcoming release. From 99b3366b8ce9717d8478d6219b9cb07710f26f42 Mon Sep 17 00:00:00 2001 From: zinwang Date: Tue, 5 Aug 2025 19:07:33 +0800 Subject: [PATCH 3/8] Set trigger time at first wednesday of the month --- .github/workflows/github-release-issue-pr.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index d7bcbf6b..65e4dd3c 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -4,21 +4,14 @@ on: push: branches: [ master ] schedule: - # Runs at 00:00 UTC on the Monday within the first 7 days of each month - - cron: '0 0 1-7 * 1' + # Runs at 00:00 UTC on the Wednesday within the first 7 days of each month + - cron: '0 14 1-7 * 3' jobs: release: runs-on: ubuntu-latest steps: - - name: Check if this Wednesday is the first of a 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: @@ -50,9 +43,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 "$(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')" codex -a auto-edit -q \ """ @@ -63,7 +56,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) + dateInfo=$(date +%y.%-m) versionNum="v$dateInfo.1" issueNum=$(gh issue create \ From 267169be64db03538ac8cf753eafe1a77ff8e10e Mon Sep 17 00:00:00 2001 From: zinwang Date: Tue, 5 Aug 2025 19:36:51 +0800 Subject: [PATCH 4/8] Fix wrong ci step name --- .github/workflows/github-release-draft.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-release-draft.yml b/.github/workflows/github-release-draft.yml index e6b41ee5..326101f0 100644 --- a/.github/workflows/github-release-draft.yml +++ b/.github/workflows/github-release-draft.yml @@ -26,7 +26,7 @@ jobs: run: | sudo npm install -g @openai/codex@0.1.2505172129 - - name: Generate PR summary issue + - name: Collect changelog from PR id: gen_issue env: OPENAI_API_KEY: ${{ secrets.OPENAI_KEY }} From 2807b9c1c26dd7aae9af03f9df35e335bf29f40b Mon Sep 17 00:00:00 2001 From: zinwang Date: Tue, 5 Aug 2025 19:49:33 +0800 Subject: [PATCH 5/8] Prettify yaml --- .github/workflows/github-release-issue-pr.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index 65e4dd3c..f948925c 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -145,5 +145,4 @@ jobs: 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 }}. + body: "Resolves #${{ steps.gen_issue.outputs.issue }}." From 8290962d843179fe6e6252eadbff372cb4f33759 Mon Sep 17 00:00:00 2001 From: zinwang Date: Tue, 5 Aug 2025 19:46:40 +0800 Subject: [PATCH 6/8] Remove on push trigger --- .github/workflows/github-release-issue-pr.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index f948925c..257ed7ff 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -1,10 +1,8 @@ name: Generate GitHub Release Issue/PR on: - push: - branches: [ master ] schedule: - # Runs at 00:00 UTC on the Wednesday within the first 7 days of each month + # Runs at 14:00 UTC on the Wednesday within the first 7 days of each month - cron: '0 14 1-7 * 3' jobs: From 2de3d7612bdf450efd0dc8a810ac6eff5c06b02f Mon Sep 17 00:00:00 2001 From: zinwang Date: Wed, 6 Aug 2025 12:40:32 +0800 Subject: [PATCH 7/8] Fix time zone issue of trigger time --- .github/workflows/github-release-issue-pr.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index 257ed7ff..f614a060 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -2,8 +2,9 @@ name: Generate GitHub Release Issue/PR on: schedule: - # Runs at 14:00 UTC on the Wednesday within the first 7 days of each month - - cron: '0 14 1-7 * 3' + # Runs at 14:00 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:00 UTC) + - cron: '0 6 1-7 * 3' jobs: release: From 2b24dee02004924910a98f34b98519e994a0e502 Mon Sep 17 00:00:00 2001 From: zinwang Date: Wed, 6 Aug 2025 14:04:53 +0800 Subject: [PATCH 8/8] Add manual trigger --- .github/workflows/github-release-issue-pr.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-release-issue-pr.yml b/.github/workflows/github-release-issue-pr.yml index f614a060..1decedb7 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -1,10 +1,11 @@ name: Generate GitHub Release Issue/PR on: + workflow_dispatch: {} schedule: - # Runs at 14:00 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:00 UTC) - - cron: '0 6 1-7 * 3' + # 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' jobs: release: