diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a174274..b7bb2d1b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -150,10 +150,61 @@ jobs: path: packages/cli/dist if-no-files-found: error + release-django-cf: + runs-on: ubuntu-latest + needs: release-cli + # django-cf depends on neither of the other packages, but every PSR job pushes + # a version bump to main, so the jobs are serialized to avoid racing on push. + if: always() && (needs.release-cli.result == 'success') + concurrency: + group: ${{ github.workflow }}-release-django-cf-${{ github.ref_name }} + cancel-in-progress: false + + outputs: + released: ${{ steps.release.outputs.released }} + tag: ${{ steps.release.outputs.tag }} + + permissions: + contents: write + + steps: + # Checkout latest ref (may include the preceding jobs' version commits) + - name: Setup | Checkout Repository on Release Branch + uses: actions/checkout@v4 + with: + token: ${{ secrets.DEVPROD_PAT }} + ref: main + fetch-depth: 0 + + - name: Action | Semantic Version Release + id: release + uses: python-semantic-release/python-semantic-release@v10.5.3 + with: + github_token: ${{ secrets.DEVPROD_PAT }} + git_committer_name: "Workers DevProd" + git_committer_email: "workers-devprod@cloudflare.com" + directory: packages/django-cf + + - name: Publish | Upload to GitHub Release Assets + uses: python-semantic-release/publish-action@v10.5.3 + if: steps.release.outputs.released == 'true' + with: + github_token: ${{ secrets.DEVPROD_PAT }} + tag: ${{ steps.release.outputs.tag }} + directory: packages/django-cf + + - name: Upload | Distribution Artifacts + uses: actions/upload-artifact@v4 + if: steps.release.outputs.released == 'true' + with: + name: distribution-artifacts-django-cf + path: packages/django-cf/dist + if-no-files-found: error + deploy: runs-on: ubuntu-latest - needs: [release-runtime-sdk, release-cli] - if: always() && (needs.release-runtime-sdk.outputs.released == 'true' || needs.release-cli.outputs.released == 'true') + needs: [release-runtime-sdk, release-cli, release-django-cf] + if: always() && (needs.release-runtime-sdk.outputs.released == 'true' || needs.release-cli.outputs.released == 'true' || needs.release-django-cf.outputs.released == 'true') permissions: contents: read diff --git a/packages/django-cf/CHANGELOG.md b/packages/django-cf/CHANGELOG.md index 9fb89eda..9f674aca 100644 --- a/packages/django-cf/CHANGELOG.md +++ b/packages/django-cf/CHANGELOG.md @@ -1,7 +1,10 @@ -# django-cf +# CHANGELOG -## 0.2.10 + -### Patch Changes +## v0.2.10 and earlier -- [#47](https://github.com/G4brym/django-cf/pull/47) [`14b101a`](https://github.com/G4brym/django-cf/commit/14b101a5c1f01d6565f8cec222f3bdeabac50a98) Thanks [@G4brym](https://github.com/G4brym)! - Test changeset flow +Releases up to and including `0.2.10` were made from +[G4brym/django-cf](https://github.com/G4brym/django-cf) with Changesets. See that +repository for those entries. Everything from the next release onwards is generated by +python-semantic-release and inserted directly above this section. diff --git a/packages/django-cf/package.json b/packages/django-cf/package.json index a6d666b6..76696c8d 100644 --- a/packages/django-cf/package.json +++ b/packages/django-cf/package.json @@ -14,8 +14,7 @@ "scripts": { "test": "uv run pytest", "upgrade-templates": "cd templates/durable-objects && uv add django-cf --upgrade && cd ../d1 && uv add django-cf --upgrade", - "build": "rm -rf dist/ && python3 -m build", - "publish": "python3 -m twine upload dist/*" + "build": "rm -rf dist/ && uv build" }, "devDependencies": { "@changesets/changelog-github": "^0.6.0", diff --git a/packages/django-cf/pyproject.toml b/packages/django-cf/pyproject.toml index c5b76274..7fdc3224 100644 --- a/packages/django-cf/pyproject.toml +++ b/packages/django-cf/pyproject.toml @@ -110,3 +110,89 @@ exclude_lines = [ "raise NotImplementedError", "if TYPE_CHECKING:", ] + +[tool.semantic_release] +assets = [] +build_command_env = [] +commit_message = """\ +Release django-cf {version} + +Automatically generated by python-semantic-release +""" +commit_parser = "conventional-monorepo" +logging_use_named_masks = false +# django-cf is still on a 0.x version, unlike the two 1.x sibling packages, so a +# feat bumps the minor rather than forcing 1.0.0. +major_on_zero = false +allow_zero_version = true +no_git_verify = false +tag_format = "django-cf-v{version}" +version_toml = ["pyproject.toml:project.version"] +build_command = """ + pip install uv + uv lock --upgrade-package "$PACKAGE_NAME" + git add uv.lock + uv build +""" + +[tool.semantic_release.branches.main] +match = "(main|master)" +prerelease_token = "rc" +prerelease = false + +[tool.semantic_release.changelog] +exclude_commit_patterns = [ + '''chore(?:\([^)]*?\))?: .+''', + '''ci(?:\([^)]*?\))?: .+''', + '''refactor(?:\([^)]*?\))?: .+''', + '''style(?:\([^)]*?\))?: .+''', + '''test(?:\([^)]*?\))?: .+''', + '''build\((?!deps\): .+)''', + '''Initial [Cc]ommit.*''', +] +mode = "update" +insertion_flag = "" + +[tool.semantic_release.changelog.default_templates] +changelog_file = "CHANGELOG.md" +output_format = "md" +mask_initial_release = true + +[tool.semantic_release.changelog.environment] +block_start_string = "{%" +block_end_string = "%}" +variable_start_string = "{{" +variable_end_string = "}}" +comment_start_string = "{#" +comment_end_string = "#}" +trim_blocks = false +lstrip_blocks = false +newline_sequence = "\n" +keep_trailing_newline = false +extensions = [] +autoescape = false + +[tool.semantic_release.commit_author] +env = "GIT_COMMIT_AUTHOR" +default = "semantic-release " + +[tool.semantic_release.commit_parser_options] +path_filters = [".", "!tests/**", "!templates/**"] +scope_prefix = "django-cf" +minor_tags = ["feat"] +patch_tags = ["fix", "perf"] +other_allowed_tags = ["build", "chore", "ci", "docs", "style", "refactor", "test"] +allowed_tags = ["feat", "fix", "perf", "build", "chore", "ci", "docs", "style", "refactor", "test"] +default_bump_level = 0 +parse_squash_commits = true +ignore_merge_commits = true + +[tool.semantic_release.remote] +name = "origin" +type = "github" +ignore_token_for_push = false +insecure = false + +[tool.semantic_release.publish] +dist_glob_patterns = ["dist/*"] +upload_to_vcs_release = true diff --git a/packages/django-cf/scripts/version.sh b/packages/django-cf/scripts/version.sh deleted file mode 100755 index 3377345b..00000000 --- a/packages/django-cf/scripts/version.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Run changeset version to bump package.json and generate CHANGELOG.md -npx changeset version - -# Sync the version from package.json into pyproject.toml -VERSION=$(jq -r .version package.json) -sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" pyproject.toml