Deploy triggered by montesmariana #3
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 workflow will upload a Python Package using Twine when a release is created | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# Lots taken from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
# Copied from kuleuven/mango-mdschema | |
name: Upload Python Package | |
run-name: Deploy triggered by ${{ github.actor }} | |
on: | |
release: | |
types: [published] | |
push: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest # only build this distribution for now | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
run: python -m build | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package-distribution | |
path: dist/ | |
pypi-publish: | |
name: Upload release to PyPI | |
# only upload to PyPI on releases and tagged branches | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/mango-mdconverter | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
- name: Download dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: package-distribution | |
path: dist/ | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
testpypi-publish: | |
name: Upload release to TestPyPI | |
# upload to TestPyPI on every push to main, not with tags | |
if: (!startsWith(github.ref, 'refs/tags/')) | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/mango-mdconverter | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
- name: Download dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: package-distribution | |
path: dist/ | |
- name: Publish package distributions to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ |