Skip to content

Formulae 0.5.3

Formulae 0.5.3 #20

Workflow file for this run

name: Publish tagged releases to PyPI
on:
release:
types:
- created
jobs:
build:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install dependencies
run: python3 -m pip install --upgrade build
- name: Build
run: python3 -m build
- name: Upload source distribution artifact
uses: actions/upload-artifact@v3
with:
name: artifact
path: dist/*
test:
name: Upload release to test PyPI
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download source distribution artifact
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install twine
run: python3 -m pip install --upgrade twine
- name: Publish library
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: python3 -m twine upload --skip-existing --repository testpypi dist/*
- name: Test pip install from test.pypi
run: |
python -m venv venv-test-pypi
venv-test-pypi/bin/python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple formulae
venv-test-pypi/bin/python -c "import formulae; assert formulae.__version__ == '${{ github.ref_name }}'"
publish:
name: Upload release to PyPI
needs: [build, test]
runs-on: ubuntu-latest
steps:
- name: Download source distribution artifact
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install twine
run: python3 -m pip install --upgrade twine
- name: Publish library
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN_FORMULAE }}
run: python3 -m twine upload dist/*
# See documentation on accesing the tag from the release
# Look for 'github.ref' and 'github.ref_name' in https://docs.github.com/en/actions/learn-github-actions/contexts
# On October, 2023 it says "For workflows triggered by release, this is the release tag created"
# So 'github.ref_name' should be the version number of the release we're making.