chore: improvements to generate 2401 data release (#436) #30
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: Release | |
"on": | |
push: | |
branches: ["main", "release/**"] | |
concurrency: | |
group: deploy | |
cancel-in-progress: false # prevent hickups with semantic-release | |
env: | |
PYTHON_VERSION_DEFAULT: "3.10.8" | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
concurrency: release | |
permissions: | |
# NOTE: this enables trusted publishing. | |
# See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1#trusted-publishing | |
# and https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/ | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
repository: opentargets/gentropy | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Python Semantic Release | |
id: semrelease | |
uses: python-semantic-release/python-semantic-release@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish package to GitHub Release | |
uses: python-semantic-release/upload-to-gh-release@main | |
if: ${{ steps.semrelease.outputs.released }} == 'true' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ steps.semrelease.outputs.tag }} | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
needs: release | |
name: >- | |
Publish 📦 in PyPI | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/gentropy | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
publish-to-testpypi: | |
name: Publish 📦 in TestPyPI | |
needs: release | |
if: github.ref != 'refs/heads/main' | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/gentropy | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution 📦 to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
documentation: | |
needs: release | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION_DEFAULT }} | |
- name: Install and configure Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: | | |
venv-${{ runner.os }}-\ | |
${{ env.PYTHON_VERSION_DEFAULT }}-\ | |
${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
- name: Install library | |
run: poetry install --without tests --no-interaction | |
- name: Publish docs | |
run: poetry run mkdocs gh-deploy --force |