Skip to content

Fetch tags in workflow. (#26) #6

Fetch tags in workflow. (#26)

Fetch tags in workflow. (#26) #6

Workflow file for this run

name: push_tag
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
permissions:
contents: read
jobs:
release:
name: Release to GitHub
runs-on: ubuntu-latest
environment: dev
permissions:
contents: write
discussions: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-tags: true
ref: ${{ github.ref_name}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ">=3.10 <3.13"
- name: Set Poetry Version
id: set-poetry-version
run: echo "POETRY_VERSION=$(cat .poetry-version)" >> $GITHUB_OUTPUT
- name: Install Poetry
id: install-poetry-version
uses: snok/install-poetry@v1
with:
version: ${{ steps.set-poetry-version.outputs.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install project
run: poetry install --no-interaction
- name: Build project
run: poetry build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
- name: Create release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*
publish:
needs:
- release
permissions:
id-token: write
name: Publish to PyPI
runs-on: ubuntu-latest
environment:
name: dev
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-tags: true
ref: ${{ github.ref_name}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ">=3.10 <3.13"
- name: Set Poetry Version
id: set-poetry-version
run: echo "POETRY_VERSION=$(cat .poetry-version)" >> $GITHUB_OUTPUT
- name: Install Poetry
id: install-poetry-version
uses: snok/install-poetry@v1
with:
version: ${{ steps.set-poetry-version.outputs.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install project
run: poetry install --no-interaction
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish project
run: poetry publish
env:
POETRY_PYPI_TOKEN_PYENSEMBLREST: ${{ secrets.POETRY_PYPI_TOKEN_PYENSEMBLREST }}