From 7cd0cf339807aa61b432c38dc483bd7441fe99f7 Mon Sep 17 00:00:00 2001 From: Michael van Tellingen Date: Mon, 26 Oct 2026 22:21:33 +0100 Subject: [PATCH] ci: release with changie and changie-release-action v2 Replace bumpversion with changie. A release job in the test workflow maintains a release PR and, once merged, tags the version and creates the GitHub release with the release app token. That triggers the existing python-release.yml, which keeps publishing to PyPI with trusted publishing. Older history stays in CHANGES; CHANGELOG.md starts at 0.1.0. --- .bumpversion.cfg | 11 ----- .changes/0.1.0.md | 5 ++ .changes/header.tpl.md | 8 +++ .changes/unreleased/.gitkeep | 0 .../unreleased/Removed-20261026-222116.yaml | 3 ++ .changie.yaml | 39 +++++++++++++++ .github/workflows/dependabot-changie.yaml | 49 +++++++++++++++++++ .github/workflows/python-test.yml | 40 +++++++++++++++ CHANGELOG.md | 15 ++++++ CHANGES | 2 + README.md | 13 +++++ pyproject.toml | 3 +- 12 files changed, 176 insertions(+), 12 deletions(-) delete mode 100644 .bumpversion.cfg create mode 100644 .changes/0.1.0.md create mode 100644 .changes/header.tpl.md create mode 100644 .changes/unreleased/.gitkeep create mode 100644 .changes/unreleased/Removed-20261026-222116.yaml create mode 100644 .changie.yaml create mode 100644 .github/workflows/dependabot-changie.yaml create mode 100644 CHANGELOG.md diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index 38e56ac..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,11 +0,0 @@ -[bumpversion] -current_version = 0.1.0 -commit = true -tag = true -tag_name = {new_version} - -[bumpversion:file:pyproject.toml] - -[bumpversion:file:docs/conf.py] - -[bumpversion:file:src/django_session_timeout/__init__.py] diff --git a/.changes/0.1.0.md b/.changes/0.1.0.md new file mode 100644 index 0000000..632573a --- /dev/null +++ b/.changes/0.1.0.md @@ -0,0 +1,5 @@ +## 0.1.0 - 2020-03-08 +### Added +* Add SESSION_TIMEOUT_REDIRECT to set a custom URL for redirect users which have an expired session. See #9 +### Changed +* Update GitHub Actions CI/CD diff --git a/.changes/header.tpl.md b/.changes/header.tpl.md new file mode 100644 index 0000000..885ed91 --- /dev/null +++ b/.changes/header.tpl.md @@ -0,0 +1,8 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). + +Older releases are documented in [CHANGES](CHANGES). diff --git a/.changes/unreleased/.gitkeep b/.changes/unreleased/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.changes/unreleased/Removed-20261026-222116.yaml b/.changes/unreleased/Removed-20261026-222116.yaml new file mode 100644 index 0000000..1aca862 --- /dev/null +++ b/.changes/unreleased/Removed-20261026-222116.yaml @@ -0,0 +1,3 @@ +kind: Removed +body: Drop support for Python < 3.11 and Django < 5.2, and drop the six dependency +time: 2026-10-26T22:21:16.768189+01:00 diff --git a/.changie.yaml b/.changie.yaml new file mode 100644 index 0000000..06fdab6 --- /dev/null +++ b/.changie.yaml @@ -0,0 +1,39 @@ +changesDir: .changes +unreleasedDir: unreleased +headerPath: header.tpl.md +changelogPath: CHANGELOG.md +versionExt: md +versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}' +kindFormat: '### {{.Kind}}' +changeFormat: '* {{.Body}}' +kinds: + - label: Added + auto: minor + - label: Changed + auto: major + - label: Deprecated + auto: minor + - label: Removed + auto: major + - label: Fixed + auto: patch + - label: Security + auto: patch + - label: Dependency + auto: patch +# uv.lock also contains the version, the release workflow runs `uv lock` +replacements: + - path: pyproject.toml + find: '^version = ".*"' + replace: 'version = "{{.VersionNoPrefix}}"' + - path: src/django_session_timeout/__init__.py + find: '^__version__ = ".*"' + replace: '__version__ = "{{.VersionNoPrefix}}"' + - path: docs/conf.py + find: "^version = '.*'" + replace: "version = '{{.VersionNoPrefix}}'" +newlines: + afterChangelogHeader: 1 + beforeChangelogVersion: 1 + endOfVersion: 1 +envPrefix: CHANGIE_ diff --git a/.github/workflows/dependabot-changie.yaml b/.github/workflows/dependabot-changie.yaml new file mode 100644 index 0000000..8d22679 --- /dev/null +++ b/.github/workflows/dependabot-changie.yaml @@ -0,0 +1,49 @@ +name: Dependabot add changie file +on: + pull_request: + types: [opened] + +permissions: + pull-requests: write + issues: write + repository-projects: write + contents: write + +jobs: + dependabot-changie: + runs-on: ubuntu-latest + if: github.event.pull_request.user.login == 'dependabot[bot]' + steps: + - name: Create release app token + id: app-token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + app-id: ${{ secrets.RELEASE_APP_ID }} + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + permission-contents: write + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.head_ref }} + token: ${{ steps.app-token.outputs.token }} + # git-auto-commit-action pushes with these credentials + persist-credentials: true + + - name: Fetch Dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Create change file + uses: miniscruff/changie-action@3223cb29b92a0972dedc864ace3da01e04780ae4 # v3.0.1 + with: + version: latest + args: new --body "${{ github.event.pull_request.title }}" --kind Dependency + + - uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0 + with: + commit_message: "chore(deps): add changelog for dependabot updates" + commit_user_name: "dependabot[bot]" + commit_user_email: "dependabot[bot]@users.noreply.github.com" diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index d155e0d..0f9ca8e 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -48,3 +48,43 @@ jobs: env: PYTHON: ${{ matrix.python }} DJANGO: ${{ matrix.django }} + + release: + runs-on: ubuntu-latest + needs: [format, test] + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + permissions: + contents: read + concurrency: + group: release + cancel-in-progress: false + steps: + - name: Create release app token + id: app-token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + app-id: ${{ vars.RELEASE_APP_ID }} + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + permission-contents: write + permission-pull-requests: write + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Install uv + uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 + with: + enable-cache: false + + # Creates or updates the release PR, or tags and releases the version + # once it is merged. The GitHub release is created with the app token, + # so it triggers python-release.yml, which publishes to PyPI. + - name: Release + uses: labd/changie-release-action@059406879b04f6e073547b325fbbff9a573038e3 # v2.0.0 + with: + github-token: ${{ steps.app-token.outputs.token }} + # uv.lock contains the project version as well + version-command: uv lock + create-release: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..46c2418 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). + +Older releases are documented in [CHANGES](CHANGES). + + +## 0.1.0 - 2020-03-08 +### Added +* Add SESSION_TIMEOUT_REDIRECT to set a custom URL for redirect users which have an expired session. See #9 +### Changed +* Update GitHub Actions CI/CD diff --git a/CHANGES b/CHANGES index dcc765e..8cbae0e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +New releases are documented in CHANGELOG.md, which is generated by changie. + 0.1.0 (2020-03-08) ------------------ - Add SESSION_TIMEOUT_REDIRECT to set a custom URL for redirect users which diff --git a/README.md b/README.md index ee1bd60..c5eff9a 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,16 @@ To redirect to a custom URL define the following setting: ```python SESSION_TIMEOUT_REDIRECT = 'your_redirect_url_here/' ``` + +## Releasing + +Changes are tracked with [changie](https://changie.dev/). Add a changelog +entry to every pull request with a user-facing change: + +```shell +changie new +``` + +When entries are merged to the default branch, a release pull request is +opened (or updated) automatically. Merging that pull request tags the release, +creates the GitHub release and publishes the package to PyPI. diff --git a/pyproject.toml b/pyproject.toml index 7b05346..a998a9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ [project.urls] Homepage = "https://github.com/labd/django-session-timeout" Documentation = "https://django-session-timeout.readthedocs.io/" -Changelog = "https://github.com/labd/django-session-timeout/blob/master/CHANGES" +Changelog = "https://github.com/labd/django-session-timeout/blob/master/CHANGELOG.md" [dependency-groups] dev = [ @@ -68,6 +68,7 @@ packages = ["src/django_session_timeout"] include = [ "src/django_session_timeout", "tests", + "CHANGELOG.md", "CHANGES", "LICENSE", "README.md",