-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created separate test release action
This required dynamic versioning so that we could read in an environment variable to suffix the version with a dev tag. This allows us to create dev distributions of the package to test the release process more thoroughly.
- Loading branch information
1 parent
aaa5544
commit bed66ed
Showing
4 changed files
with
105 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Test Python 🐍 distribution 📦 to TestPyPI | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
iteration: | ||
description: 'A unique iteration for the run. The tag will be prefixed with test.yyyymmdd.' | ||
type: string | ||
required: true | ||
default: "0" | ||
|
||
env: | ||
# Change these for your project's URLs | ||
PYPI_TEST_URL: https://test.pypi.org/p/django-commons-best-practices | ||
# The environment key that overrides the version number | ||
DEV_VERSION_ENV_KEY: BEST_PRACTICES_VERSION | ||
|
||
jobs: | ||
|
||
create-dev-version: | ||
# Generate the dev version suffix based on the current date. | ||
# Tag name: | ||
# <version>.dev<yyyymmdd><iteration> | ||
name: Create dev version string | ||
runs-on: ubuntu-latest | ||
outputs: | ||
dev_version: ${{ steps.output-dev-version.outputs.dev_version }} | ||
steps: | ||
- name: Set date suffix | ||
id: set-date | ||
run: echo "suffix=dev$(date +%Y%m%d)${{ github.event.inputs.iteration }}" >> $GITHUB_ENV | ||
- name: Output dev version | ||
id: output-dev-version | ||
run: echo "dev_version=${{ env.suffix }}" >> "$GITHUB_OUTPUT" | ||
|
||
build: | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
- name: Install pypa/build | ||
run: | ||
python3 -m pip install build --user | ||
- name: Build a binary wheel and a source tarball | ||
env: | ||
DEV_VERSION: ${{needs.create-dev-version.outputs.dev_version}} | ||
run: ${{ env.DEV_VERSION_ENV_KEY }}="${{ env.DEV_VERSION }}" python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-testpypi: | ||
name: Publish Python 🐍 distribution 📦 to TestPyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: testpypi | ||
url: ${{ env.PYPI_TEST_URL }} | ||
|
||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1.10 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
skip-existing: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,11 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "django-commons-best-practices" | ||
version = "1.1.0" | ||
dynamic = ["version", "readme"] | ||
authors = [ | ||
{ name="Tim Schilling", email="[email protected]" }, | ||
] | ||
description = "A place to test things out" | ||
readme = "README.md" | ||
requires-python = ">=3.11" | ||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
|
@@ -21,6 +20,10 @@ keywords = [ | |
"django commons", | ||
] | ||
|
||
[tool.setuptools.dynamic] | ||
version = {attr = "django_commons_best_practices.__version__"} | ||
readme = {file = ["README.md"]} | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/django-commons/best-practices" | ||
Issues = "https://github.com/django-commons/best-practices/issues" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
__all__ = ["VERSION"] | ||
import os | ||
|
||
# Support suffixing the version with a dev segment. | ||
# This allows for building dev distributions to test | ||
# the release process. | ||
# See .github/workflows/test_release.yml | ||
__version__ = VERSION = "1.1.0" + os.environ.get("BEST_PRACTICES_VERSION_DEV", "") |