Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
41 changes: 7 additions & 34 deletions .github/workflows/on-release-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,28 @@ on:
types: [published]

jobs:
set-version:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Export tag
id: vars
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
if: ${{ github.event_name == 'release' }}

- name: Update project version
run: |
sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
sed -i "s/__version__ .*/__version__ = \"$RELEASE_VERSION\"/" flask_cors/version.py

env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
if: ${{ github.event_name == 'release' }}

- name: Upload updated pyproject.toml
uses: actions/upload-artifact@v4
with:
name: pyproject-toml
path: |
pyproject.toml
flask_cors/version.py

publish:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write # this permission is mandatory for trusted publishing
needs: [set-version]
steps:
- name: Check out
uses: actions/checkout@v4
with:
# Fetch the full history and all tags so that setuptools-scm can
# derive the version from the released git tag.
fetch-depth: 0

- name: Set up the environment
uses: ./.github/actions/setup-python-env

- name: Download updated pyproject.toml
uses: actions/download-artifact@v4
with:
name: pyproject-toml
- name: Cat files
run: cat pyproject.toml && cat flask_cors/version.py
- name: Build package
run: uv build

- name: Show built artifacts
run: ls -l dist/

- name: Publish package
run: uv publish --trusted-publishing always

Expand Down
8 changes: 7 additions & 1 deletion flask_cors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from importlib.metadata import PackageNotFoundError, version

from .decorator import cross_origin
from .extension import CORS
from .version import __version__

try:
__version__ = version("flask-cors")
except PackageNotFoundError: # pragma: no cover - package is not installed
__version__ = "unknown"

__all__ = ["CORS", "__version__", "cross_origin"]

Expand Down
1 change: 0 additions & 1 deletion flask_cors/version.py

This file was deleted.

12 changes: 10 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "flask-cors"
version = "0.0.1"
dynamic = ["version"]
description = "A Flask extension simplifying CORS support"
authors = [{ name = "Cory Dolphin", email = "corydolphin@gmail.com" }]
readme = "README.rst"
Expand Down Expand Up @@ -43,9 +43,17 @@ dev = [
]

[build-system]
requires = ["setuptools"]
requires = ["setuptools>=64", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
# The version is derived from the latest git tag. For source archives
# generated by GitHub (`git archive`), the version is recovered from the
# substituted values in .git_archival.txt (see .gitattributes export-subst).
# fallback_version is only used when building outside of a git checkout and
# without archival metadata.
fallback_version = "0.0.0"

[tool.setuptools]
packages = ["flask_cors"]
# This is a workaround for https://github.com/astral-sh/uv/issues/9513
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading