build(github): Bump the gha group with 3 updates (#270) #48
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
# Builds and publishes to testpypi on every push to main | |
# On release, publishes to pypi | |
name: publish | |
on: | |
push: | |
branches: | |
- main | |
release: | |
types: [published] | |
env: | |
PYTHON_VERSION: 3.11 | |
POETRY_VERSION: 1.5.1 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install Poetry ${{ env.POETRY_VERSION }} | |
run: python -m pip install poetry==${{ env.POETRY_VERSION }} | |
- name: Set version with dunamai | |
uses: mtkennerly/dunamai-action@v1 | |
id: version | |
with: | |
command: dunamai from git | |
args: --no-metadata --style semver | |
- run: echo ${{ steps.version.outputs.version }} | |
- run: poetry version ${{ steps.version.outputs.version }} | |
- name: poetry build | |
run: poetry build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: poetry_build | |
path: dist/ | |
publish_test_pypi: | |
if: github.repository_owner == 'ryankanno' | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- uses: actions/download-artifact@v4 | |
with: | |
name: poetry_build | |
path: dist/ | |
- name: Install Poetry ${{ env.POETRY_VERSION }} | |
run: python -m pip install poetry==${{ env.POETRY_VERSION }} | |
- run: poetry version ${{ needs.build.outputs.version }} | |
- name: poetry configure TestPyPI Repo | |
run: poetry config repositories.test-pypi https://test.pypi.org/legacy/ | |
- name: poetry configure TestPyPI Token | |
run: poetry config pypi-token.test-pypi ${{ secrets.TEST_PYPI_API_TOKEN }} | |
- name: poetry publish TestPyPi | |
run: poetry publish -r test-pypi | |
publish_pypi: | |
if: github.repository_owner == 'ryankanno' && github.event_name == 'release' && github.event.action == 'published' | |
runs-on: ubuntu-latest | |
needs: [build, publish_test_pypi] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- uses: actions/download-artifact@v4 | |
with: | |
name: poetry_build | |
path: dist/ | |
- name: Install Poetry ${{ env.POETRY_VERSION }} | |
run: python -m pip install poetry==${{ env.POETRY_VERSION }} | |
- run: poetry version ${{ needs.build.outputs.version }} | |
- name: poetry configure PyPI Token | |
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} | |
- name: poetry publish PyPi | |
run: poetry publish |