Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 91 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ on:
required: true
type: string

permissions:
contents: write
permissions: {}

concurrency:
group: release-${{ github.repository }}-${{ inputs.tag || github.ref_name }}
Expand All @@ -46,11 +45,19 @@ jobs:
release:
if: github.repository == 'apache/casbin-pycasbin' && (github.event_name == 'push' || github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
is_rc: ${{ steps.meta.outputs.is_rc }}
name: ${{ steps.meta.outputs.name }}
python_dist: ${{ steps.python-dist.outputs.artifact-id }}
github_release_files: ${{ steps.github-release-files.outputs.artifact-id }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.12'
Expand Down Expand Up @@ -105,13 +112,6 @@ jobs:
for package in "$GITHUB_WORKSPACE"/python-dist/*; do
python "$GITHUB_WORKSPACE/.github/scripts/release.py" python-check "$package"
done
- name: Publish approved-source Python distributions
if: steps.meta.outputs.is_rc == 'false'
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: python-dist/

- name: Write release notes
env:
IS_RC: ${{ steps.meta.outputs.is_rc }}
Expand All @@ -127,13 +127,89 @@ jobs:
printf '\n\nProject result: %s\nIPMC result: %s\nSource assets are the approved ASF originals.\n' "$PROJECT_RESULT" "$INCUBATOR_RESULT" >> release-notes.md
printf '\nSource: https://downloads.apache.org/incubator/casbin/pycasbin-%s-incubating/\nKEYS: https://downloads.apache.org/incubator/casbin/KEYS\nVerification: https://www.apache.org/info/verification.html\n' "$VERSION" >> release-notes.md
fi
- name: Create unsigned GitHub prerelease
if: steps.meta.outputs.is_rc == 'true'
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
NAME: ${{ steps.meta.outputs.name }}
run: |
set -euo pipefail
gh release create "$TAG" --verify-tag --prerelease --latest=false \
--title "$TAG (Apache Casbin Incubating)" --notes-file release-notes.md \
"dist-release/$NAME.tar.gz" "dist-release/$NAME.tar.gz.sha512"

- name: Collect the verified GitHub release files
if: steps.meta.outputs.is_rc == 'false'
env:
NAME: ${{ steps.meta.outputs.name }}
run: |
set -euo pipefail
archive="$NAME.tar.gz"
mkdir github-release-files
cp -- "dist-release/$archive" "dist-release/$archive.sha512" "dist-release/$archive.asc" release-notes.md github-release-files/
cd github-release-files
sha256sum -- "$archive" "$archive.sha512" "$archive.asc" release-notes.md > payload.sha256

- name: Retain checked Python distributions
if: steps.meta.outputs.is_rc == 'false'
id: python-dist
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: python-dist-${{ github.run_attempt }}
path: python-dist/
if-no-files-found: error

- name: Retain promoted ASF source and release notes
if: steps.meta.outputs.is_rc == 'false'
id: github-release-files
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: github-release-files-${{ github.run_attempt }}
path: github-release-files/
if-no-files-found: error

publish-pypi:
needs: release
if: github.event_name == 'workflow_dispatch' && needs.release.outputs.is_rc == 'false'
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download checked Python distributions from this run
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
artifact-ids: ${{ needs.release.outputs.python_dist }}
merge-multiple: true
path: python-dist/
- name: Publish approved-source Python distributions
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
with:
packages-dir: python-dist/

publish-github:
needs: [release, publish-pypi]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download the promoted ASF source and release notes from this run
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
artifact-ids: ${{ needs.release.outputs.github_release_files }}
merge-multiple: true
path: github-release-files/
- name: Create GitHub release without replacing assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag || github.ref_name }}
IS_RC: ${{ steps.meta.outputs.is_rc }}
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
NAME: ${{ needs.release.outputs.name }}
run: |
set -euo pipefail
kind=(--latest)
if [[ "$IS_RC" == true ]]; then kind=(--prerelease --latest=false); fi
gh release create "$TAG" --title "$TAG (Apache Casbin Incubating)" --notes-file release-notes.md "${kind[@]}" dist-release/*.tar.gz dist-release/*.sha512 $(find dist-release -maxdepth 1 -name '*.asc' -print)
cd github-release-files
archive="$NAME.tar.gz"
sha256sum --strict --check payload.sha256
gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --verify-tag --latest \
--title "$TAG (Apache Casbin Incubating)" --notes-file release-notes.md \
"$archive" "$archive.sha512" "$archive.asc"
8 changes: 5 additions & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ Apache source packages are the release artifacts. PyPI wheels and sdists are con

The Apache distribution is `apache-casbin` and the import package remains `casbin`. The package identity is separate from registry ownership and release approval. Avoid co-installing legacy `casbin`/`pycasbin`, which contain overlapping import files. Adapter dependency migrations are separate components and do not silently substitute an old core in candidate verification.

The synchronized enforcer uses the separately installed MIT-licensed `readerwriterlock` dependency. A small Casbin wrapper retains the context/direct API and gives each acquisition a separate handle, including when several threads share the same read context. It replaces the historical implementation carrying an unresolved Wikipedia-adaptation notice rather than re-licensing that code. The dependency is not bundled in the Apache source or Python distributions; inspect its resolved version/license separately.
The synchronized enforcer uses the in-tree lock in `casbin/util/rwlock.py`. Review the provenance and terms for the adaptation identified in that file before signing a candidate.

## Prepare and test

Use Python 3.9 or newer for the library, and Python 3.12 for release tooling. The dependency requirements already require Python 3.9. Prepare the committed version, all scoped fixes, ASF headers, legal files, metadata, distributions and workflow changes together in one preparation PR. Retain origin notices and resolve third-party licensing before submission.
Use Python 3.9 or newer for the library, and Python 3.12 for release tooling. The dependency requirements already require Python 3.9. Prepare the committed version, scoped fixes, ASF headers, legal files, metadata, distributions and workflow changes for review. Retain origin notices and resolve third-party licensing before submission.

```sh
python -m pip install -r requirements_dev.txt coverage build twine
Expand Down Expand Up @@ -67,7 +67,9 @@ https://downloads.apache.org/incubator/casbin/pycasbin-X.Y.Z-incubating/

Create the final `vX.Y.Z` tag at the approved candidate commit. A final-tag push performs no publication. After the approvals and ASF promotion, dispatch `release.yml` **from master** with that existing tag and the actual public project and IPMC result-thread URLs. The URLs are auditable references; a URL-shaped string does not prove that a vote passed. The release manager must validate their scope, votes and candidate binding before dispatch.

The workflow refuses an existing GitHub release, verifies committed version and strict tag syntax, downloads the promoted ASF originals, validates SHA-512 and GPG against downloaded KEYS, and compares every archived file's bytes and permissions with the tag. Only then does it build convenience packages from the extracted approved source, run tests, inspect Python contents and use `PYPI_TOKEN_CASBIN` to publish. Source assets are reused unchanged; the final archive is never regenerated. GitHub notes include the disclaimer, result links and verification instructions.
Before the first upload of `apache-casbin`, have a project-designated PyPI maintainer configure a pending Trusted Publisher for owner `apache`, repository `casbin-pycasbin`, workflow `release.yml`, and environment `pypi`. Use the same publisher configuration on the PyPI project if it already exists. Configure the matching GitHub Actions environment. A pending publisher does not reserve the name. Record who administers the PyPI project and the GitHub environment.

The workflow refuses an existing GitHub release, validates the tag and committed version, and verifies the promoted ASF originals against the tag, KEYS and SHA-512. The build job tests and packages the extracted approved source. A dedicated job in the `pypi` environment downloads the checked distributions from that run and uses Trusted Publishing. After that upload succeeds, a separate GitHub job uses the same run's verified source assets and release notes. The final source bytes are carried forward from ASF distribution.

Record registry administration and credential access for the PPMC separately from GitHub/tag and ASF SVN permissions. Never test the release by performing a real registry upload. Inspect the actual installed PyPI package, official downloads, website and announcements after approved publication.

Expand Down