PRISM ADRIO and Devlogs (#159) #21
Workflow file for this run
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 releases to Github whenever a "v" tag is added. | |
# Useful docs: | |
# https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases | |
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
# https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28 | |
# https://cli.github.com/manual/gh_release_create | |
# https://docs.astral.sh/uv/guides/integration/github/ | |
# https://docs.astral.sh/ruff/integrations/#github-actions | |
name: Build and release to Github | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
name: Build and release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: '.python-version' | |
- name: Install uv | |
run: curl -LsSf https://astral.sh/uv/0.4.5/install.sh | sh | |
- name: Cache uv and python | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.uv-cache | |
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} | |
restore-keys: | | |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} | |
uv-${{ runner.os }} | |
- name: Install dependencies | |
run: uv sync --frozen --all-extras --dev | |
- name: Run unit tests | |
run: uv run python -m unittest discover -v -s "./epymorph" -p "*_test.py" | |
- name: Update pyproject.toml version | |
run: | | |
version="${GITHUB_REF#refs/tags/v}" | |
sed -i "s/version = .*/version = \"${version}\"/" pyproject.toml | |
- name: Build project | |
run: uv build | |
- name: Create release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
version="${GITHUB_REF#refs/tags/v}" | |
# release assets | |
wheel_file="./dist/epymorph-${version}-py3-none-any.whl" | |
source_file="./dist/epymorph-${version}.tar.gz" | |
gh release create "v${version}" --generate-notes $wheel_file $source_file | |
- name: Minimize uv cache | |
run: uv cache prune --ci |