From e21504aba5c196e32a47a7fabcf25975a591f5df Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 12:25:19 +0000 Subject: [PATCH 01/10] chore(release): 0.1.0 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..4c59b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +## v0.1.0 (2026-07-08) + +### Feat + +- add base project From 8279dee9dfb5327db673851cb80e00db230013e6 Mon Sep 17 00:00:00 2001 From: Mathieu BARLEON Date: Wed, 8 Jul 2026 14:29:43 +0200 Subject: [PATCH 02/10] fix: dependabot crash and enforce release --- .github/README.md | 4 ++-- .github/workflows/release.yml | 4 ++++ pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/README.md b/.github/README.md index f418489..592a997 100644 --- a/.github/README.md +++ b/.github/README.md @@ -58,7 +58,7 @@ pipx install "$(ls dist/*.whl | head -n 1)" Install a published release artifact with `pipx`: ```bash -pipx install https://github.com//StyleCheck/releases/download/vX.Y.Z/splinter3d_style-X.Y.Z-py3-none-any.whl +pipx install https://github.com/Splinter3D/StyleCheck/releases/download/vX.Y.Z/splinter3d_style-X.Y.Z-py3-none-any.whl splinter3d_style ``` @@ -68,7 +68,7 @@ Add this repository and a release tag to your `.pre-commit-config.yaml`: ```yaml repos: - - repo: https://github.com//StyleCheck + - repo: https://github.com/Splinter3D/StyleCheck rev: vX.Y.Z hooks: - id: splinter3d-style diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16f6be4..8d05b17 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,6 +51,8 @@ jobs: - name: Create GitHub prerelease uses: softprops/action-gh-release@v3 with: + tag_name: ${{ github.ref_name }} + name: ${{ github.ref_name }} files: dist/* generate_release_notes: true prerelease: true @@ -72,5 +74,7 @@ jobs: - name: Create GitHub release uses: softprops/action-gh-release@v3 with: + tag_name: ${{ github.ref_name }} + name: ${{ github.ref_name }} files: dist/* generate_release_notes: true diff --git a/pyproject.toml b/pyproject.toml index 733b350..d8e7940 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "splinter3d_style" version = "0.1.0" description = "A style checker for Splinter3D projects." readme = ".github/README.md" -requires-python = ">=3.10" +requires-python = ">=3.10,<4.0" [[project.authors]] name = "Mathieu BARLEON" email = "mathieu.barleon@splinter3d.com" From fdf1bc67c4c89af2e552a71b4b7769e059c49b0e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 12:30:55 +0000 Subject: [PATCH 03/10] chore(release): 0.1.1 --- CHANGELOG.md | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c59b27..5c679d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v0.1.1 (2026-07-08) + +### Fix + +- dependabot crash and enforce release + ## v0.1.0 (2026-07-08) ### Feat diff --git a/pyproject.toml b/pyproject.toml index d8e7940..547043c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "splinter3d_style" -version = "0.1.0" +version = "0.1.1" description = "A style checker for Splinter3D projects." readme = ".github/README.md" requires-python = ">=3.10,<4.0" From d3196aa143d73909f908b5ff424306ee38759158 Mon Sep 17 00:00:00 2001 From: Mathieu BARLEON Date: Wed, 8 Jul 2026 14:38:14 +0200 Subject: [PATCH 04/10] fix: use reusable workflow to release --- .github/workflows/release.yml | 113 ++++++++++++++++++++--------- .github/workflows/tag-on-merge.yml | 38 +++++++++- 2 files changed, 113 insertions(+), 38 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d05b17..3cdb622 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,22 +4,88 @@ on: push: tags: - "v*" + workflow_call: + inputs: + tag_name: + required: true + type: string + prerelease: + required: true + type: boolean + environment_name: + required: true + type: string + workflow_dispatch: + inputs: + tag_name: + description: "Tag to release" + required: true + type: string + prerelease: + description: "Publish as prerelease" + required: true + type: boolean + environment_name: + description: "GitHub environment to use" + required: true + type: choice + options: + - release + - release-rc permissions: contents: write jobs: + prepare: + runs-on: ubuntu-latest + outputs: + tag_name: ${{ steps.vars.outputs.tag_name }} + prerelease: ${{ steps.vars.outputs.prerelease }} + environment_name: ${{ steps.vars.outputs.environment_name }} + + steps: + - name: Resolve release parameters + id: vars + run: | + if [[ "${{ github.event_name }}" == "workflow_call" ]]; then + echo "tag_name=${{ inputs.tag_name }}" >> "$GITHUB_OUTPUT" + echo "prerelease=${{ inputs.prerelease }}" >> "$GITHUB_OUTPUT" + echo "environment_name=${{ inputs.environment_name }}" >> "$GITHUB_OUTPUT" + exit 0 + fi + + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + echo "tag_name=${{ inputs.tag_name }}" >> "$GITHUB_OUTPUT" + echo "prerelease=${{ inputs.prerelease }}" >> "$GITHUB_OUTPUT" + echo "environment_name=${{ inputs.environment_name }}" >> "$GITHUB_OUTPUT" + exit 0 + fi + + tag_name="${GITHUB_REF_NAME}" + if [[ "$tag_name" == *-rc.* ]]; then + echo "tag_name=$tag_name" >> "$GITHUB_OUTPUT" + echo "prerelease=true" >> "$GITHUB_OUTPUT" + echo "environment_name=release-rc" >> "$GITHUB_OUTPUT" + else + echo "tag_name=$tag_name" >> "$GITHUB_OUTPUT" + echo "prerelease=false" >> "$GITHUB_OUTPUT" + echo "environment_name=release" >> "$GITHUB_OUTPUT" + fi + build: runs-on: ubuntu-latest + needs: prepare steps: - name: Check out repository - uses: actions/checkout@v7 + uses: actions/checkout@v4 with: + ref: refs/tags/${{ needs.prepare.outputs.tag_name }} fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v5 with: python-version: "3.12" @@ -29,52 +95,31 @@ jobs: python -m build - name: Upload build artifacts - uses: actions/upload-artifact@v7 + uses: actions/upload-artifact@v4 with: name: dist path: dist/* - publish-prerelease: - if: contains(github.ref_name, '-rc.') - runs-on: ubuntu-latest - environment: - name: release-rc - needs: build - - steps: - - name: Download build artifacts - uses: actions/download-artifact@v7 - with: - name: dist - path: dist - - - name: Create GitHub prerelease - uses: softprops/action-gh-release@v3 - with: - tag_name: ${{ github.ref_name }} - name: ${{ github.ref_name }} - files: dist/* - generate_release_notes: true - prerelease: true - - publish-release: - if: ${{ !contains(github.ref_name, '-rc.') }} + publish: runs-on: ubuntu-latest - needs: build environment: - name: release + name: ${{ needs.prepare.outputs.environment_name }} + needs: + - prepare + - build steps: - name: Download build artifacts - uses: actions/download-artifact@v7 + uses: actions/download-artifact@v4 with: name: dist path: dist - name: Create GitHub release - uses: softprops/action-gh-release@v3 + uses: softprops/action-gh-release@v2 with: - tag_name: ${{ github.ref_name }} - name: ${{ github.ref_name }} + tag_name: ${{ needs.prepare.outputs.tag_name }} + name: "Release: ${{ needs.prepare.outputs.tag_name }}" files: dist/* generate_release_notes: true + prerelease: ${{ needs.prepare.outputs.prerelease == 'true' }} diff --git a/.github/workflows/tag-on-merge.yml b/.github/workflows/tag-on-merge.yml index dd8c731..cf5d99b 100644 --- a/.github/workflows/tag-on-merge.yml +++ b/.github/workflows/tag-on-merge.yml @@ -25,9 +25,12 @@ jobs: environment: name: release-rc + outputs: + tag_name: ${{ steps.version.outputs.tag }} + steps: - name: Check out base branch - uses: actions/checkout@v7 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.merge_commit_sha || github.event.pull_request.base.ref }} fetch-depth: 0 @@ -36,7 +39,7 @@ jobs: run: git fetch --force --tags origin - name: Set up Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v5 with: python-version: "3.12" @@ -85,6 +88,18 @@ jobs: git tag -a "$tag" -m "Release candidate $tag" git push origin "$tag" + release-dev: + if: >- + github.event.pull_request.merged == true && + github.event.pull_request.base.ref == 'dev' + needs: tag-dev + uses: ./.github/workflows/release.yml + secrets: inherit + with: + tag_name: ${{ needs.tag-dev.outputs.tag_name }} + prerelease: true + environment_name: release-rc + tag-main: if: >- github.event.pull_request.merged == true && @@ -93,9 +108,12 @@ jobs: environment: name: release + outputs: + tag_name: ${{ steps.version.outputs.tag }} + steps: - name: Check out base branch - uses: actions/checkout@v7 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.merge_commit_sha || github.event.pull_request.base.ref }} fetch-depth: 0 @@ -104,7 +122,7 @@ jobs: run: git fetch --force --tags origin - name: Set up Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v5 with: python-version: "3.12" @@ -152,3 +170,15 @@ jobs: git fetch origin main --tags git tag -a "$tag" -m "Release $tag" git push origin "$tag" + + release-main: + if: >- + github.event.pull_request.merged == true && + github.event.pull_request.base.ref == 'main' + needs: tag-main + uses: ./.github/workflows/release.yml + secrets: inherit + with: + tag_name: ${{ needs.tag-main.outputs.tag_name }} + prerelease: false + environment_name: release From 9b95565f1a9cfb93815e975ff5761fadb802919c Mon Sep 17 00:00:00 2001 From: Mathieu BARLEON Date: Wed, 8 Jul 2026 14:42:24 +0200 Subject: [PATCH 05/10] fix: bump action versions --- .github/workflows/release.yml | 10 +++++----- .github/workflows/tag-on-merge.yml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3cdb622..0b9412b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,13 +79,13 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: ref: refs/tags/${{ needs.prepare.outputs.tag_name }} fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.12" @@ -95,7 +95,7 @@ jobs: python -m build - name: Upload build artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: dist path: dist/* @@ -110,13 +110,13 @@ jobs: steps: - name: Download build artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: dist path: dist - name: Create GitHub release - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@v3 with: tag_name: ${{ needs.prepare.outputs.tag_name }} name: "Release: ${{ needs.prepare.outputs.tag_name }}" diff --git a/.github/workflows/tag-on-merge.yml b/.github/workflows/tag-on-merge.yml index cf5d99b..a72cfe5 100644 --- a/.github/workflows/tag-on-merge.yml +++ b/.github/workflows/tag-on-merge.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Check out base branch - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: ref: ${{ github.event.pull_request.merge_commit_sha || github.event.pull_request.base.ref }} fetch-depth: 0 @@ -39,7 +39,7 @@ jobs: run: git fetch --force --tags origin - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.12" @@ -113,7 +113,7 @@ jobs: steps: - name: Check out base branch - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: ref: ${{ github.event.pull_request.merge_commit_sha || github.event.pull_request.base.ref }} fetch-depth: 0 @@ -122,7 +122,7 @@ jobs: run: git fetch --force --tags origin - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.12" From 7da483b012a6a642b713f1f685d1ac31f29a16b5 Mon Sep 17 00:00:00 2001 From: Mathieu BARLEON Date: Wed, 8 Jul 2026 14:44:42 +0200 Subject: [PATCH 06/10] fix: force ci run --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b9412b..79dd493 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,7 +76,6 @@ jobs: build: runs-on: ubuntu-latest needs: prepare - steps: - name: Check out repository uses: actions/checkout@v7 From e7c6a6df90bb6b1a39288d8480ad489c745f8792 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 12:45:49 +0000 Subject: [PATCH 07/10] chore(release): 0.1.2 --- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c679d1..66c812e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## v0.1.2 (2026-07-08) + +### Fix + +- force ci run +- bump action versions +- use reusable workflow to release + ## v0.1.1 (2026-07-08) ### Fix diff --git a/pyproject.toml b/pyproject.toml index 547043c..a68dc4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "splinter3d_style" -version = "0.1.1" +version = "0.1.2" description = "A style checker for Splinter3D projects." readme = ".github/README.md" requires-python = ">=3.10,<4.0" From 18212a519b1af68c14a7e6d4d38be3223352c280 Mon Sep 17 00:00:00 2001 From: Mathieu BARLEON Date: Wed, 8 Jul 2026 14:47:55 +0200 Subject: [PATCH 08/10] fix: use tag name instead of branch for release --- .github/workflows/release.yml | 39 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 79dd493..f0dd196 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,31 +48,30 @@ jobs: - name: Resolve release parameters id: vars run: | - if [[ "${{ github.event_name }}" == "workflow_call" ]]; then - echo "tag_name=${{ inputs.tag_name }}" >> "$GITHUB_OUTPUT" - echo "prerelease=${{ inputs.prerelease }}" >> "$GITHUB_OUTPUT" - echo "environment_name=${{ inputs.environment_name }}" >> "$GITHUB_OUTPUT" - exit 0 - fi + tag_name="${{ inputs.tag_name || github.ref_name }}" + prerelease="${{ inputs.prerelease }}" + environment_name="${{ inputs.environment_name }}" - if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then - echo "tag_name=${{ inputs.tag_name }}" >> "$GITHUB_OUTPUT" - echo "prerelease=${{ inputs.prerelease }}" >> "$GITHUB_OUTPUT" - echo "environment_name=${{ inputs.environment_name }}" >> "$GITHUB_OUTPUT" - exit 0 + if [[ -z "$prerelease" ]]; then + if [[ "$tag_name" == *-rc.* ]]; then + prerelease=true + else + prerelease=false + fi fi - tag_name="${GITHUB_REF_NAME}" - if [[ "$tag_name" == *-rc.* ]]; then - echo "tag_name=$tag_name" >> "$GITHUB_OUTPUT" - echo "prerelease=true" >> "$GITHUB_OUTPUT" - echo "environment_name=release-rc" >> "$GITHUB_OUTPUT" - else - echo "tag_name=$tag_name" >> "$GITHUB_OUTPUT" - echo "prerelease=false" >> "$GITHUB_OUTPUT" - echo "environment_name=release" >> "$GITHUB_OUTPUT" + if [[ -z "$environment_name" ]]; then + if [[ "$tag_name" == *-rc.* ]]; then + environment_name=release-rc + else + environment_name=release + fi fi + echo "tag_name=$tag_name" >> "$GITHUB_OUTPUT" + echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT" + echo "environment_name=$environment_name" >> "$GITHUB_OUTPUT" + build: runs-on: ubuntu-latest needs: prepare From 78710d4404382ab44e23dc3a8745220bc35a910d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 12:49:11 +0000 Subject: [PATCH 09/10] chore(release): 0.1.3 --- CHANGELOG.md | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66c812e..b56cbb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v0.1.3 (2026-07-08) + +### Fix + +- use tag name instead of branch for release + ## v0.1.2 (2026-07-08) ### Fix diff --git a/pyproject.toml b/pyproject.toml index a68dc4c..b87d356 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "splinter3d_style" -version = "0.1.2" +version = "0.1.3" description = "A style checker for Splinter3D projects." readme = ".github/README.md" requires-python = ">=3.10,<4.0" From 2db9cd82727e4366f9ae0a85cc98d2045bf64af0 Mon Sep 17 00:00:00 2001 From: Mathieu BARLEON Date: Wed, 8 Jul 2026 15:05:29 +0200 Subject: [PATCH 10/10] fix: avoid direct push on protected branches --- .github/workflows/backmerge-main-to-dev.yml | 60 ++++++ .github/workflows/prepare-release-pr.yml | 208 ++++++++++++++++++++ .github/workflows/tag-on-merge.yml | 82 ++------ 3 files changed, 288 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/backmerge-main-to-dev.yml create mode 100644 .github/workflows/prepare-release-pr.yml diff --git a/.github/workflows/backmerge-main-to-dev.yml b/.github/workflows/backmerge-main-to-dev.yml new file mode 100644 index 0000000..ed554ac --- /dev/null +++ b/.github/workflows/backmerge-main-to-dev.yml @@ -0,0 +1,60 @@ +name: backmerge-main-to-dev + +on: + pull_request_target: + branches: + - main + types: + - closed + +permissions: + contents: read + pull-requests: write + +jobs: + open-backmerge-pr: + if: >- + github.event.pull_request.merged == true && + startsWith(github.event.pull_request.head.ref, 'hotfix/') && + github.event.pull_request.head.ref != 'hotfix/release-main' + runs-on: ubuntu-latest + + steps: + - name: Open back-merge pull request + run: | + repo="${{ github.repository }}" + api_url="https://api.github.com/repos/${repo}/pulls" + title="chore(backmerge): main into dev after ${{ github.event.pull_request.head.ref }}" + head_branch="main" + base_branch="dev" + + existing_pr="$(curl --silent \ + --url "${api_url}?state=open&head=${{ github.repository_owner }}:${head_branch}&base=${base_branch}" \ + --header "Authorization: Bearer ${GITHUB_TOKEN}" \ + --header "Accept: application/vnd.github+json" \ + --header "X-GitHub-Api-Version: 2022-11-28")" + + if echo "$existing_pr" | grep -q '"number":'; then + echo "An open back-merge PR from main to dev already exists." + exit 0 + fi + + payload="$(cat <- + github.event.pull_request.merged == true && + github.event.pull_request.base.ref == 'dev' && + github.event.pull_request.head.ref != 'release/dev' + runs-on: ubuntu-latest + environment: + name: release-rc + + steps: + - name: Check out dev + uses: actions/checkout@v4 + with: + ref: dev + fetch-depth: 0 + + - name: Fetch tags + run: git fetch --force --tags origin + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install release tooling + run: python -m pip install --upgrade pip commitizen tomlkit + + - name: Prepare release branch + id: prepare + run: | + tag="$(./scripts/next-tag.sh rc)" + python_version="$(./scripts/tag-to-python-version.sh "$tag")" + release_branch="release/dev" + + cz changelog --unreleased-version="$tag" + ./scripts/check-versions.sh --fix "$tag" + git add CHANGELOG.md pyproject.toml + + if git diff --cached --quiet; then + echo "has_changes=false" >> "$GITHUB_OUTPUT" + echo "release_branch=$release_branch" >> "$GITHUB_OUTPUT" + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -B "$release_branch" + git commit -m "chore(release): ${python_version}" + git push --force-with-lease origin HEAD:"$release_branch" + + echo "has_changes=true" >> "$GITHUB_OUTPUT" + echo "release_branch=$release_branch" >> "$GITHUB_OUTPUT" + echo "python_version=$python_version" >> "$GITHUB_OUTPUT" + + - name: Open or update release PR + if: steps.prepare.outputs.has_changes == 'true' + run: | + repo="${{ github.repository }}" + head_branch="${{ steps.prepare.outputs.release_branch }}" + base_branch="dev" + title="chore(release): ${{ steps.prepare.outputs.python_version }}" + body="Automated release preparation PR for \`dev\`." + api_url="https://api.github.com/repos/${repo}/pulls" + + existing_pr="$(curl --silent \ + --url "${api_url}?state=open&head=${{ github.repository_owner }}:${head_branch}&base=${base_branch}" \ + --header "Authorization: Bearer ${GITHUB_TOKEN}" \ + --header "Accept: application/vnd.github+json" \ + --header "X-GitHub-Api-Version: 2022-11-28")" + + if echo "$existing_pr" | grep -q '"number":'; then + echo "Release PR from ${head_branch} to ${base_branch} already exists." + exit 0 + fi + + payload="$(cat <- + github.event.pull_request.merged == true && + github.event.pull_request.base.ref == 'main' && + github.event.pull_request.head.ref != 'hotfix/release-main' + runs-on: ubuntu-latest + environment: + name: release + + steps: + - name: Check out main + uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + + - name: Fetch tags + run: git fetch --force --tags origin + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install release tooling + run: python -m pip install --upgrade pip commitizen tomlkit + + - name: Prepare release branch + id: prepare + run: | + tag="$(./scripts/next-tag.sh stable)" + python_version="$(./scripts/tag-to-python-version.sh "$tag")" + release_branch="hotfix/release-main" + + cz changelog --unreleased-version="$tag" + ./scripts/check-versions.sh --fix "$tag" + git add CHANGELOG.md pyproject.toml + + if git diff --cached --quiet; then + echo "has_changes=false" >> "$GITHUB_OUTPUT" + echo "release_branch=$release_branch" >> "$GITHUB_OUTPUT" + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -B "$release_branch" + git commit -m "chore(release): ${python_version}" + git push --force-with-lease origin HEAD:"$release_branch" + + echo "has_changes=true" >> "$GITHUB_OUTPUT" + echo "release_branch=$release_branch" >> "$GITHUB_OUTPUT" + echo "python_version=$python_version" >> "$GITHUB_OUTPUT" + + - name: Open or update release PR + if: steps.prepare.outputs.has_changes == 'true' + run: | + repo="${{ github.repository }}" + head_branch="${{ steps.prepare.outputs.release_branch }}" + base_branch="main" + title="chore(release): ${{ steps.prepare.outputs.python_version }}" + body="Automated release preparation PR for \`main\`." + api_url="https://api.github.com/repos/${repo}/pulls" + + existing_pr="$(curl --silent \ + --url "${api_url}?state=open&head=${{ github.repository_owner }}:${head_branch}&base=${base_branch}" \ + --header "Authorization: Bearer ${GITHUB_TOKEN}" \ + --header "Accept: application/vnd.github+json" \ + --header "X-GitHub-Api-Version: 2022-11-28")" + + if echo "$existing_pr" | grep -q '"number":'; then + echo "Release PR from ${head_branch} to ${base_branch} already exists." + exit 0 + fi + + payload="$(cat <- github.event.pull_request.merged == true && - github.event.pull_request.base.ref == 'dev' + github.event.pull_request.base.ref == 'dev' && + github.event.pull_request.head.ref == 'release/dev' runs-on: ubuntu-latest environment: name: release-rc - outputs: tag_name: ${{ steps.version.outputs.tag }} steps: - - name: Check out base branch - uses: actions/checkout@v7 + - name: Check out dev + uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.merge_commit_sha || github.event.pull_request.base.ref }} + ref: dev fetch-depth: 0 - name: Fetch tags run: git fetch --force --tags origin - name: Set up Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v5 with: python-version: "3.12" - - name: Install Commitizen - run: python -m pip install --upgrade pip commitizen tomlkit + - name: Install release tooling + run: python -m pip install --upgrade pip commitizen - name: Compute release candidate tag id: version run: | tag="$(./scripts/next-tag.sh rc)" - python_version="$(./scripts/tag-to-python-version.sh "$tag")" echo "tag=$tag" >> "$GITHUB_OUTPUT" - echo "python_version=$python_version" >> "$GITHUB_OUTPUT" - - - name: Update changelog and project version - run: | - tag="${{ steps.version.outputs.tag }}" - python_version="${{ steps.version.outputs.python_version }}" - - cz changelog --unreleased-version="$tag" - ./scripts/check-versions.sh --fix "$tag" - git add CHANGELOG.md pyproject.toml - - if git diff --cached --quiet; then - echo "No release file changes detected." - exit 0 - fi - - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git commit -m "chore(release): ${python_version}" - git push origin HEAD:dev - name: Create tag run: | @@ -84,14 +63,14 @@ jobs: git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git fetch origin dev --tags git tag -a "$tag" -m "Release candidate $tag" git push origin "$tag" release-dev: if: >- github.event.pull_request.merged == true && - github.event.pull_request.base.ref == 'dev' + github.event.pull_request.base.ref == 'dev' && + github.event.pull_request.head.ref == 'release/dev' needs: tag-dev uses: ./.github/workflows/release.yml secrets: inherit @@ -103,58 +82,37 @@ jobs: tag-main: if: >- github.event.pull_request.merged == true && - github.event.pull_request.base.ref == 'main' + github.event.pull_request.base.ref == 'main' && + github.event.pull_request.head.ref == 'hotfix/release-main' runs-on: ubuntu-latest environment: name: release - outputs: tag_name: ${{ steps.version.outputs.tag }} steps: - - name: Check out base branch - uses: actions/checkout@v7 + - name: Check out main + uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.merge_commit_sha || github.event.pull_request.base.ref }} + ref: main fetch-depth: 0 - name: Fetch tags run: git fetch --force --tags origin - name: Set up Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v5 with: python-version: "3.12" - - name: Install Commitizen - run: python -m pip install --upgrade pip commitizen tomlkit + - name: Install release tooling + run: python -m pip install --upgrade pip commitizen - name: Compute stable tag id: version run: | tag="$(./scripts/next-tag.sh stable)" - python_version="$(./scripts/tag-to-python-version.sh "$tag")" echo "tag=$tag" >> "$GITHUB_OUTPUT" - echo "python_version=$python_version" >> "$GITHUB_OUTPUT" - - - name: Update changelog and project version - run: | - tag="${{ steps.version.outputs.tag }}" - python_version="${{ steps.version.outputs.python_version }}" - - cz changelog --unreleased-version="$tag" - ./scripts/check-versions.sh --fix "$tag" - git add CHANGELOG.md pyproject.toml - - if git diff --cached --quiet; then - echo "No release file changes detected." - exit 0 - fi - - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git commit -m "chore(release): ${python_version}" - git push origin HEAD:main - name: Create tag run: | @@ -167,14 +125,14 @@ jobs: git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git fetch origin main --tags git tag -a "$tag" -m "Release $tag" git push origin "$tag" release-main: if: >- github.event.pull_request.merged == true && - github.event.pull_request.base.ref == 'main' + github.event.pull_request.base.ref == 'main' && + github.event.pull_request.head.ref == 'hotfix/release-main' needs: tag-main uses: ./.github/workflows/release.yml secrets: inherit