diff --git a/.github/workflows/github-release-draft.yml b/.github/workflows/github-release-draft.yml index 326101f0..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,8 +42,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - dateInfo=$(date +%y.%-m) - versionNum="v$dateInfo.1" + versionNum=$(echo ${{ github.event.pull_request.title }} | awk '{print $NF}') 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 1decedb7..b4630b1a 100644 --- a/.github/workflows/github-release-issue-pr.yml +++ b/.github/workflows/github-release-issue-pr.yml @@ -3,15 +3,27 @@ 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 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: Check if this Wednesday is the first one of the month + 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." + exit 0 + else + echo "Triggered automatically, the week contains the first Wednesday of a month. Continue the process." + fi + - name: Checkout repository uses: actions/checkout@v4 with: @@ -43,21 +55,25 @@ 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')" + 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] """ - dateInfo=$(date +%y.%-m) - versionNum="v$dateInfo.1" + 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" \ @@ -71,13 +87,15 @@ 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')" + versionNum=${{ steps.gen_issue.outputs.version }} 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: + 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.] @@ -88,17 +106,17 @@ 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.1-0kali1) kali-dev; urgency=medium + quark-engine (YY.M.X-0kali1) kali-dev; urgency=medium * TAG - DESCRIPTION - -- Zin Wong RELEASE_TIME + -- Zin Wong RELEASE_TIME_TODAY - 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 @@ -116,17 +134,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 @@ -137,7 +151,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 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: