Merge pull request #99 from wimglenn/2023/13 #213
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
name: Publish to PyPI | |
on: | |
push: | |
branches: ["main"] | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.12" | |
architecture: x64 | |
cache: pip | |
cache-dependency-path: pyproject.toml | |
- name: Create release | |
run: | | |
python -VV | |
python -m pip install -q -U wheel setuptools twine luddite build | |
python -m build -n -x -C=--global-option=-q | |
- uses: jannekem/run-python-script-action@v1 | |
with: | |
script: | | |
import sys | |
sys.path.append(".") | |
import aoc_wim, luddite, subprocess | |
v = aoc_wim.__version__ | |
vs = luddite.get_versions_pypi("advent-of-code-wim") | |
if v in vs: | |
print(f"{v} already exists") | |
sys.exit(0) | |
cmd = "twine upload --disable-progress-bar -u __token__ -p ${{secrets.PYPI_TOKEN}} dist/*" | |
subprocess.check_call(cmd.split()) | |
subprocess.check_call(["git", "tag", v]) | |
subprocess.check_call(["git", "push", "--tags"]) |