From 73b11508e7e26fd48fbf1c6ef74b6cd78aaed001 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 07:27:32 +0800 Subject: [PATCH 01/13] ci: apply semantic-release --- .github/workflows/ci.yml | 82 ++++++++++++++++++----- .github/workflows/release.yml | 65 +++++------------- .vscode/settings.json | 1 + package.json | 120 ++++++++++++++++++++++++++++++++++ 4 files changed, 204 insertions(+), 64 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index baf7c703..11d0d2a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,20 @@ name: CI + +on: + pull_request: + types: + - opened + - synchronize + push: + branches: + - main + # NOTE(huxuan): Need to change after test + - xuan.hu/semantic-release + concurrency: cancel-in-progress: true group: ${{ github.workflow }}-${{ github.ref }} + jobs: ci: if: ${{ !cancelled() && ! failure() }} @@ -36,24 +49,24 @@ jobs: # renovate: github-runner - windows-2022 python-version: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" + - '3.8' + - '3.9' + - '3.10' + - '3.11' + - '3.12' # Python 3.8 and 3.9 do not run on macos-14 which is using arm64 hardware. exclude: # renovate: github-runner - os: macos-14 - python-version: "3.8" + python-version: '3.8' # renovate: github-runner - os: macos-14 - python-version: "3.9" + python-version: '3.9' include: - os: macos-13 - python-version: "3.8" + python-version: '3.8' - os: macos-13 - python-version: "3.9" + python-version: '3.9' consistency: if: ${{ !cancelled() && ! failure() }} runs-on: ubuntu-22.04 @@ -69,11 +82,46 @@ jobs: - run: git diff - run: git status --porcelain - run: test -z "$(git status --porcelain)" -on: - pull_request: - types: - - opened - - synchronize - push: - branches: - - main + semantic-release: + name: Semantic Release + runs-on: ubuntu-22.04 + # NOTE(huxuan): Need to change after test + # if: github.event_name != 'pull_request' && github.repository == 'serious-scaffold/ss-python' + # Avoid semantic release for forked repository + if: github.event_name != 'pull_request' && github.repository == 'huxuan/ss-python' + permissions: + contents: write + id-token: write + issues: write + pull-requests: write + steps: + - id: generate-token + name: Generate a token with GitHub App if App ID exists + # NOTE(huxuan): Need to change after test + if: ${{ failure() }} + # if: vars.BOT_APP_ID + uses: actions/create-github-app-token@a0de6af83968303c8c955486bf9739a57d23c7f1 # v1.10.0 + with: + app-id: ${{ vars.BOT_APP_ID }} + private-key: ${{ secrets.BOT_PRIVATE_KEY }} + - name: Warn if use GITHUB_TOKEN + run: | + if [ -z "${{ steps.generate-token.outputs.token || secrets.PAT }}" ]; then + echo "# :warning: GITHUB_TOKEN is used for semantic-release" >> $GITHUB_STEP_SUMMARY + echo "The GITHUB_TOKEN is used instead of a bot token or PAT and will not emit the released publish event for the released workflow." >> $GITHUB_STEP_SUMMARY + fi + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + - name: Semantic Release + env: + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }} + run: | + npx \ + -p conventional-changelog-conventionalcommits@7 \ + -p semantic-release \ + semantic-release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6072c6a2..18e34522 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,14 @@ name: Release + +on: + release: + types: + - published + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: pages-build: runs-on: ubuntu-22.04 @@ -9,7 +19,7 @@ jobs: - uses: pdm-project/setup-pdm@568ddd69406b30de1774ec0044b73ae06e716aa4 # v4 with: cache: true - python-version: "3.12" + python-version: '3.12' version: 2.15.2 - id: pages name: Setup pages @@ -19,42 +29,11 @@ jobs: - run: make doc env: CI_PAGES_URL: ${{ steps.pages.outputs.base_url }} - - name: Generate release notes - run: make release-notes > release-notes.md - - name: Upload release notes - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 - with: - name: release-notes - path: release-notes.md - name: Upload pages artifact uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 with: path: public - release-publish: - needs: pages-build - permissions: - contents: write - runs-on: ubuntu-22.04 - steps: - - name: Download release notes - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 - with: - name: release-notes - - id: prerelease - name: Determine prerelease - run: | - if [[ "${{ github.ref }}" =~ (a|b|rc)(0|[1-9][0-9]*)?$ ]]; then - echo "is_prerelease=true" > $GITHUB_OUTPUT - else - echo "is_prerelease=false" > $GITHUB_OUTPUT - fi - - name: Create GitHub release - uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87 # v2.0.5 - with: - body_path: release-notes.md - prerelease: ${{ steps.prerelease.outputs.is_prerelease }} container-publish: - needs: release-publish permissions: packages: write runs-on: ubuntu-22.04 @@ -90,20 +69,19 @@ jobs: strategy: matrix: python-version: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" + - '3.8' + - '3.9' + - '3.10' + - '3.11' + - '3.12' package-publish: - needs: release-publish runs-on: ubuntu-22.04 steps: - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 - uses: pdm-project/setup-pdm@568ddd69406b30de1774ec0044b73ae06e716aa4 # v4 with: cache: true - python-version: "3.12" + python-version: '3.12' version: 2.15.2 - run: env | sort - env: @@ -111,7 +89,7 @@ jobs: PDM_PUBLISH_USERNAME: ${{ vars.PDM_PUBLISH_USERNAME || '__token__' }} run: make publish pages: - needs: release-publish + needs: pages-build permissions: id-token: write pages: write @@ -120,10 +98,3 @@ jobs: - id: deployment name: Deploy to GitHub Pages uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 -on: - push: - tags: - - v?[0-9]+.[0-9]+.[0-9]+ - - v?[0-9]+.[0-9]+.[0-9]+-?a[0-9]* - - v?[0-9]+.[0-9]+.[0-9]+-?b[0-9]* - - v?[0-9]+.[0-9]+.[0-9]+-?rc[0-9]* diff --git a/.vscode/settings.json b/.vscode/settings.json index eb4be3ee..46051519 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,6 +18,7 @@ "automodule", "cobertura", "commitlint", + "conventionalcommits", "datasource", "deepclean", "deflist", diff --git a/package.json b/package.json index 6e542715..9abbe0cb 100644 --- a/package.json +++ b/package.json @@ -3,5 +3,125 @@ "extends": [ "@commitlint/config-conventional" ] + }, + "release": { + "dryRun": true, + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "type": "build", + "release": false + }, + { + "type": "chore", + "release": false + }, + { + "type": "ci", + "release": false + }, + { + "type": "docs", + "release": false + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "perf", + "release": "patch" + }, + { + "type": "refactor", + "release": "patch" + }, + { + "type": "revert", + "release": "patch" + }, + { + "type": "style", + "release": false + }, + { + "type": "test", + "release": false + }, + { + "scope": "*no-release*", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "presetConfig": { + "types": [ + { + "type": "build", + "section": "Build" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "ci", + "section": "CI" + }, + { + "type": "docs", + "section": "Docs" + }, + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance" + }, + { + "type": "refactor", + "section": "Refactor" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "style", + "section": "Style" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/github" + ], + "preset": "conventionalcommits", + "debug": true } } From b7c66bd0c36f6602830e5d526b1aeb94588b02e7 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 07:31:59 +0800 Subject: [PATCH 02/13] update setup-node actions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11d0d2a3..0419d69f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,7 +114,7 @@ jobs: with: fetch-depth: 0 - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.2 with: node-version: 'lts/*' - name: Semantic Release From a1c28a282902b77acde18f9930463fd5ac2d332e Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 07:34:33 +0800 Subject: [PATCH 03/13] hack the branch name --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 9abbe0cb..09182a52 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,10 @@ ] }, "release": { + // NOTE(huxuan): Need to change the branch name after test + "branches": [ + "xuan.hu/semantic-release" + ], "dryRun": true, "plugins": [ [ From b17231c7ab8f4a8cd642a4c93d4a8b0a32f232d8 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 07:35:14 +0800 Subject: [PATCH 04/13] run semantic release after ci --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0419d69f..e7ec4728 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,6 +94,7 @@ jobs: id-token: write issues: write pull-requests: write + needs: ci steps: - id: generate-token name: Generate a token with GitHub App if App ID exists From e0549ffdc3169c8f552167f00855dd8d4202c81c Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 07:36:35 +0800 Subject: [PATCH 05/13] fix json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 09182a52..018a72e1 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ ] }, "release": { - // NOTE(huxuan): Need to change the branch name after test "branches": [ "xuan.hu/semantic-release" ], From edeb25df7f4552c7c6a17dd05f48c98675196de1 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 07:41:29 +0800 Subject: [PATCH 06/13] disable dry run --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 018a72e1..656fb8c0 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "branches": [ "xuan.hu/semantic-release" ], - "dryRun": true, "plugins": [ [ "@semantic-release/commit-analyzer", From c21b1b3c4c9d59746dd9b9d9692d6898ca455ca6 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 07:50:05 +0800 Subject: [PATCH 07/13] enable github app token --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7ec4728..29f9cdf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,9 +98,7 @@ jobs: steps: - id: generate-token name: Generate a token with GitHub App if App ID exists - # NOTE(huxuan): Need to change after test - if: ${{ failure() }} - # if: vars.BOT_APP_ID + if: vars.BOT_APP_ID uses: actions/create-github-app-token@a0de6af83968303c8c955486bf9739a57d23c7f1 # v1.10.0 with: app-id: ${{ vars.BOT_APP_ID }} From 67cd41b37442671928a4245e00ecb1b1b8e80a04 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 08:12:34 +0800 Subject: [PATCH 08/13] revert test --- .github/workflows/ci.yml | 6 +----- package.json | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29f9cdf5..93397678 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,6 @@ on: push: branches: - main - # NOTE(huxuan): Need to change after test - - xuan.hu/semantic-release concurrency: cancel-in-progress: true @@ -85,10 +83,8 @@ jobs: semantic-release: name: Semantic Release runs-on: ubuntu-22.04 - # NOTE(huxuan): Need to change after test - # if: github.event_name != 'pull_request' && github.repository == 'serious-scaffold/ss-python' # Avoid semantic release for forked repository - if: github.event_name != 'pull_request' && github.repository == 'huxuan/ss-python' + if: github.event_name != 'pull_request' && github.repository == 'serious-scaffold/ss-python' permissions: contents: write id-token: write diff --git a/package.json b/package.json index 656fb8c0..ae89412e 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,6 @@ ] }, "release": { - "branches": [ - "xuan.hu/semantic-release" - ], "plugins": [ [ "@semantic-release/commit-analyzer", @@ -123,7 +120,6 @@ ], "@semantic-release/github" ], - "preset": "conventionalcommits", - "debug": true + "preset": "conventionalcommits" } } From 226c5f03a543fcf4713214d9293786cd513a58b6 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 08:12:43 +0800 Subject: [PATCH 09/13] minor --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ae89412e..71a24212 100644 --- a/package.json +++ b/package.json @@ -80,11 +80,11 @@ }, { "type": "ci", - "section": "CI" + "section": "Continuous Integration" }, { "type": "docs", - "section": "Docs" + "section": "Documentation" }, { "type": "feat", @@ -108,7 +108,7 @@ }, { "type": "style", - "section": "Style" + "section": "Styles" }, { "type": "test", From 2338f91632b5e0dae4b87ff638c656c094c7b104 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 08:23:59 +0800 Subject: [PATCH 10/13] order --- .github/workflows/release.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18e34522..9a93edf7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,8 +6,8 @@ on: - published concurrency: - group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} jobs: pages-build: @@ -33,6 +33,16 @@ jobs: uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 with: path: public + pages: + needs: pages-build + permissions: + id-token: write + pages: write + runs-on: ubuntu-22.04 + steps: + - id: deployment + name: Deploy to GitHub Pages + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 container-publish: permissions: packages: write @@ -88,13 +98,3 @@ jobs: PDM_PUBLISH_PASSWORD: ${{ secrets.PDM_PUBLISH_PASSWORD }} PDM_PUBLISH_USERNAME: ${{ vars.PDM_PUBLISH_USERNAME || '__token__' }} run: make publish - pages: - needs: pages-build - permissions: - id-token: write - pages: write - runs-on: ubuntu-22.04 - steps: - - id: deployment - name: Deploy to GitHub Pages - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 From 9bd6ae0ebd13eadf2e97a9fb8779b5fa5fa44a64 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 08:24:08 +0800 Subject: [PATCH 11/13] update template --- template/.vscode/settings.json | 1 + .../workflows/ci.yml.jinja | 79 +++++++++--- .../workflows/release.yml.jinja | 75 ++++------- template/package.json | 118 ++++++++++++++++++ 4 files changed, 203 insertions(+), 70 deletions(-) diff --git a/template/.vscode/settings.json b/template/.vscode/settings.json index eb4be3ee..46051519 100644 --- a/template/.vscode/settings.json +++ b/template/.vscode/settings.json @@ -18,6 +18,7 @@ "automodule", "cobertura", "commitlint", + "conventionalcommits", "datasource", "deepclean", "deflist", diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja index 2b93a31b..0c9ee442 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja @@ -1,8 +1,19 @@ [% from pathjoin("includes", "version_compare.jinja") import version_between -%] name: CI + +on: + pull_request: + types: + - opened + - synchronize + push: + branches: + - main + concurrency: cancel-in-progress: true group: {{ '${{ github.workflow }}-${{ github.ref }}' }} + jobs: ci: if: {{ '${{ !cancelled() && ! failure() }}' }} @@ -44,44 +55,44 @@ jobs: [%- endif %] python-version: [%- if version_between("3.8", min_py, max_py) %] - - "3.8" + - '3.8' [%- endif %] [%- if version_between("3.9", min_py, max_py) %] - - "3.9" + - '3.9' [%- endif %] [%- if version_between("3.10", min_py, max_py) %] - - "3.10" + - '3.10' [%- endif %] [%- if version_between("3.11", min_py, max_py) %] - - "3.11" + - '3.11' [%- endif %] [%- if version_between("3.12", min_py, max_py) %] - - "3.12" + - '3.12' [%- endif %] -[%- if project_name == "Serious Scaffold Python" %] [%- if "macos" in platforms and (version_between("3.8", min_py, max_py) or version_between("3.9", min_py, max_py)) %] # Python 3.8 and 3.9 do not run on macos-14 which is using arm64 hardware. exclude: [%- if version_between("3.8", min_py, max_py) %] # renovate: github-runner - os: macos-14 - python-version: "3.8" + python-version: '3.8' [%- endif %] [%- if version_between("3.9", min_py, max_py) %] # renovate: github-runner - os: macos-14 - python-version: "3.9" + python-version: '3.9' include: [%- endif %] [%- if version_between("3.8", min_py, max_py) %] - os: macos-13 - python-version: "3.8" + python-version: '3.8' [%- endif %] [%- if version_between("3.9", min_py, max_py) %] - os: macos-13 - python-version: "3.9" + python-version: '3.9' [%- endif %] [%- endif %] +[%- if project_name == "Serious Scaffold Python" %] consistency: if: {{ '${{ !cancelled() && ! failure() }}' }} runs-on: ubuntu-22.04 @@ -98,11 +109,43 @@ jobs: - run: git status --porcelain - run: test -z "$(git status --porcelain)" [%- endif %] -on: - pull_request: - types: - - opened - - synchronize - push: - branches: - - main + semantic-release: + name: Semantic Release + runs-on: ubuntu-22.04 + # Avoid semantic release for forked repository + if: github.event_name != 'pull_request' && github.repository == 'serious-scaffold/ss-python' + permissions: + contents: write + id-token: write + issues: write + pull-requests: write + needs: ci + steps: + - id: generate-token + name: Generate a token with GitHub App if App ID exists + if: vars.BOT_APP_ID + uses: actions/create-github-app-token@a0de6af83968303c8c955486bf9739a57d23c7f1 # v1.10.0 + with: + app-id: {{ '${{ vars.BOT_APP_ID }}' }} + private-key: {{ '${{ secrets.BOT_PRIVATE_KEY }}' }} + - name: Warn if use GITHUB_TOKEN + run: | + if [ -z "{{ '${{ steps.generate-token.outputs.token || secrets.PAT }}' }}" ]; then + echo "# :warning: GITHUB_TOKEN is used for semantic-release" >> $GITHUB_STEP_SUMMARY + echo "The GITHUB_TOKEN is used instead of a bot token or PAT and will not emit the released publish event for the released workflow." >> $GITHUB_STEP_SUMMARY + fi + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v4.0.2 + with: + node-version: 'lts/*' + - name: Semantic Release + env: + GITHUB_TOKEN: {{ '${{ steps.generate-token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}' }} + run: | + npx \ + -p conventional-changelog-conventionalcommits@7 \ + -p semantic-release \ + semantic-release diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja index 10bc7f6e..5a1b7f9c 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja @@ -1,5 +1,15 @@ [% from pathjoin("includes", "version_compare.jinja") import version_between -%] name: Release + +on: + release: + types: + - published + +concurrency: + cancel-in-progress: true + group: {{ '${{ github.workflow }}-${{ github.ref }}' }} + jobs: pages-build: runs-on: ubuntu-22.04 @@ -10,7 +20,7 @@ jobs: - uses: pdm-project/setup-pdm@568ddd69406b30de1774ec0044b73ae06e716aa4 # v4 with: cache: true - python-version: "{{ default_py }}" + python-version: '{{ default_py }}' version: 2.15.2 - id: pages name: Setup pages @@ -20,42 +30,21 @@ jobs: - run: make doc env: CI_PAGES_URL: {{ '${{ steps.pages.outputs.base_url }}' }} - - name: Generate release notes - run: make release-notes > release-notes.md - - name: Upload release notes - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 - with: - name: release-notes - path: release-notes.md - name: Upload pages artifact uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 with: path: public - release-publish: + pages: needs: pages-build permissions: - contents: write + id-token: write + pages: write runs-on: ubuntu-22.04 steps: - - name: Download release notes - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 - with: - name: release-notes - - id: prerelease - name: Determine prerelease - run: | - if [[ {{ '"${{ github.ref }}"' }} =~ (a|b|rc)(0|[1-9][0-9]*)?$ ]]; then - echo "is_prerelease=true" > $GITHUB_OUTPUT - else - echo "is_prerelease=false" > $GITHUB_OUTPUT - fi - - name: Create GitHub release - uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87 # v2.0.5 - with: - body_path: release-notes.md - prerelease: {{ '${{ steps.prerelease.outputs.is_prerelease }}' }} + - id: deployment + name: Deploy to GitHub Pages + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 container-publish: - needs: release-publish permissions: packages: write runs-on: ubuntu-22.04 @@ -92,49 +81,31 @@ jobs: matrix: python-version: [%- if version_between("3.8", min_py, max_py) %] - - "3.8" + - '3.8' [%- endif %] [%- if version_between("3.9", min_py, max_py) %] - - "3.9" + - '3.9' [%- endif %] [%- if version_between("3.10", min_py, max_py) %] - - "3.10" + - '3.10' [%- endif %] [%- if version_between("3.11", min_py, max_py) %] - - "3.11" + - '3.11' [%- endif %] [%- if version_between("3.12", min_py, max_py) %] - - "3.12" + - '3.12' [%- endif %] package-publish: - needs: release-publish runs-on: ubuntu-22.04 steps: - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 - uses: pdm-project/setup-pdm@568ddd69406b30de1774ec0044b73ae06e716aa4 # v4 with: cache: true - python-version: "{{ default_py }}" + python-version: '{{ default_py }}' version: 2.15.2 - run: env | sort - env: PDM_PUBLISH_PASSWORD: {{ '${{ secrets.PDM_PUBLISH_PASSWORD }}' }} PDM_PUBLISH_USERNAME: {{ '${{ vars.PDM_PUBLISH_USERNAME || \'__token__\' }}' }} run: make publish - pages: - needs: release-publish - permissions: - id-token: write - pages: write - runs-on: ubuntu-22.04 - steps: - - id: deployment - name: Deploy to GitHub Pages - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 -on: - push: - tags: - - v?[0-9]+.[0-9]+.[0-9]+ - - v?[0-9]+.[0-9]+.[0-9]+-?a[0-9]* - - v?[0-9]+.[0-9]+.[0-9]+-?b[0-9]* - - v?[0-9]+.[0-9]+.[0-9]+-?rc[0-9]* diff --git a/template/package.json b/template/package.json index 6e542715..71a24212 100644 --- a/template/package.json +++ b/template/package.json @@ -3,5 +3,123 @@ "extends": [ "@commitlint/config-conventional" ] + }, + "release": { + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "type": "build", + "release": false + }, + { + "type": "chore", + "release": false + }, + { + "type": "ci", + "release": false + }, + { + "type": "docs", + "release": false + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "perf", + "release": "patch" + }, + { + "type": "refactor", + "release": "patch" + }, + { + "type": "revert", + "release": "patch" + }, + { + "type": "style", + "release": false + }, + { + "type": "test", + "release": false + }, + { + "scope": "*no-release*", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "presetConfig": { + "types": [ + { + "type": "build", + "section": "Build" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "ci", + "section": "Continuous Integration" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance" + }, + { + "type": "refactor", + "section": "Refactor" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/github" + ], + "preset": "conventionalcommits" } } From 2e48e076d0c31206029a83e9811de3e652cbec48 Mon Sep 17 00:00:00 2001 From: "Xuan (Sean) Hu" Date: Fri, 17 May 2024 10:39:27 +0800 Subject: [PATCH 12/13] Apply suggestions from code review Co-authored-by: msclock Signed-off-by: Xuan (Sean) Hu --- .github/workflows/ci.yml | 8 ++++---- .../workflows/ci.yml.jinja | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93397678..2b7b6305 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,8 +115,8 @@ jobs: - name: Semantic Release env: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }} - run: | - npx \ - -p conventional-changelog-conventionalcommits@7 \ - -p semantic-release \ + run: > + npx + -p conventional-changelog-conventionalcommits@7 + -p semantic-release@23 semantic-release diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja index 0c9ee442..d4ebbf50 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja @@ -144,8 +144,8 @@ jobs: - name: Semantic Release env: GITHUB_TOKEN: {{ '${{ steps.generate-token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}' }} - run: | - npx \ - -p conventional-changelog-conventionalcommits@7 \ - -p semantic-release \ + run: > + npx + -p conventional-changelog-conventionalcommits@7 + -p semantic-release@23 semantic-release From ac55eac1e5c9fc791c80ab58e201b323dda73dba Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 17 May 2024 10:43:25 +0800 Subject: [PATCH 13/13] change needs logic --- .github/workflows/ci.yml | 4 +++- .github/workflows/release.yml | 3 ++- .../workflows/ci.yml.jinja | 6 +++++- .../workflows/release.yml.jinja | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b7b6305..e5c56438 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,9 @@ jobs: id-token: write issues: write pull-requests: write - needs: ci + needs: + - ci + - consistency steps: - id: generate-token name: Generate a token with GitHub App if App ID exists diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a93edf7..560a2228 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,8 @@ jobs: with: path: public pages: - needs: pages-build + needs: + - pages-build permissions: id-token: write pages: write diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja index d4ebbf50..023c55a8 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja @@ -119,7 +119,11 @@ jobs: id-token: write issues: write pull-requests: write - needs: ci + needs: + - ci +[%- if project_name == "Serious Scaffold Python" %] + - consistency +[%- endif %] steps: - id: generate-token name: Generate a token with GitHub App if App ID exists diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja index 5a1b7f9c..d4dccaf6 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja @@ -35,7 +35,8 @@ jobs: with: path: public pages: - needs: pages-build + needs: + - pages-build permissions: id-token: write pages: write