Skip to content

Commit

Permalink
dynamic versioning plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
darthtrevino committed May 7, 2024
1 parent 6745cad commit c1bc448
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
57 changes: 35 additions & 22 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
name: graspologic Publish
on:
#
# When a release tag is created (e.g. v1.0.0), this workflow will be triggered. The `poetry dynamic-version` plugin will use the correct version tag.
#
release:
types: [created]
#
# On pushes to main and dev, a prerelease version will be cut for the branch. e.g. v1.0.0-pre.10+<hash>
#
push:
paths-ignore:
- '.all-contributorsrc'
Expand All @@ -14,35 +22,40 @@ jobs:
runs-on: ubuntu-latest
needs: build
if: github.ref=='refs/heads/main' || github.ref=='refs/heads/dev'
strategy:
matrix:
python-version: ["3.10"]
poetry-version: ["1.8.2"]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: ${{ matrix.python-version }}
- name: Install Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: ${{ matrix.poetry-version }}
#
# This plugin will append version hashes unless we're on a release tag
#
- name: Add poetry-dynamic-versioning plugin
run: poetry self add "poetry-dynamic-versioning[plugin]"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine
pip install -r requirements.txt
run: poetry install
- name: Create version environment variable
run: |
echo "GRASPOLOGIC_VERSION=`python setup.py --version`" >> $GITHUB_ENV
echo "GRASPOLOGIC_TAG=v`python setup.py --version`" >> $GITHUB_ENV
- name: Build Release with setuptools
if: github.ref=='refs/heads/main'
run: |
python setup.py sdist
- name: Build Prerelease with setuptools
if: github.ref=='refs/heads/dev'
run: |
python setup.py egg_info -b "dev$GITHUB_RUN_ID" sdist
- name: Publish with twine
if: github.ref=='refs/heads/main' || github.ref=='refs/heads/dev'
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
echo "GRASPOLOGIC_VERSION=`poetry version --short`" >> $GITHUB_ENV
echo "GRASPOLOGIC_TAG=v`poetry version --short`" >> $GITHUB_ENV
- name: Build Artifacts
run: poetry build
# Note: need to set up a Trusted Publisher on PyPi
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
skip-existing: true
verbose: true
- name: Download documentation artifact
uses: actions/download-artifact@v2
with:
Expand Down
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ poethepoet = "^0.26.1"
black = "^24.4.2"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"

[tool.poetry-dynamic-versioning]
enable = true
style = "semver"
vcs = "git"
bump = true

[tool.poe.tasks]
_black = "black ./graspologic ./tests"
Expand Down

0 comments on commit c1bc448

Please sign in to comment.