From 5e7a5968e356507bbf5740293a548818bf5f6940 Mon Sep 17 00:00:00 2001 From: "Eric G. Kratz" Date: Mon, 28 Oct 2024 11:54:37 -0400 Subject: [PATCH] Add release workflow and automatic versioning (#9) --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 45 +++++++++++++++++++++++++++++++++++ ionwizard/version.py | 1 + pyproject.toml | 1 + 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 ionwizard/version.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72ef685..d70d481 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.11"] + python-version: ["3.12"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b75a4dc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Publish to PyPI + +on: + release: + types: [published] + + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + Release: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12"] + permissions: + id-token: write + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Update version + run: | + export RELEASE_VERSION=$(echo ${{ github.ref_name }} | sed -e 's/v//g') + echo "__version__ = \"$RELEASE_VERSION\"" > ionworksmetrics/version.py + - name: Build wheel + run: | + pip wheel . --no-deps -w deploy + + - name: Upload package + uses: actions/upload-artifact@v2 + with: + name: wheels + path: deploy/ + if-no-files-found: error + + - name: Publish on PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: deploy/ diff --git a/ionwizard/version.py b/ionwizard/version.py new file mode 100644 index 0000000..6c8e6b9 --- /dev/null +++ b/ionwizard/version.py @@ -0,0 +1 @@ +__version__ = "0.0.0" diff --git a/pyproject.toml b/pyproject.toml index 23a60e6..713ee3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,4 +27,5 @@ ionwizard-container = "ionwizard.container_wizard:run" include = ["ionwizard"] [tool.setuptools.dynamic] +version = {attr = "ionwizard.version.__version__"} readme = {file = ["README.md"], content-type = "text/markdown"}