Skip to content

chore: update all ci files to latest template #468

chore: update all ci files to latest template

chore: update all ci files to latest template #468

Workflow file for this run

# see https://github.com/karlicoss/pymplate for up-to-date reference
name: CI
on:
push:
branches: '*'
tags: 'v[0-9]+.*' # only trigger on 'release' tags for PyPi
# Ideally I would put this in the pypi job... but github syntax doesn't allow for regexes there :shrug:
# Needed to trigger on others' PRs.
# Note that people who fork it need to go to "Actions" tab on their fork and click "I understand my workflows, go ahead and enable them".
pull_request:
# Needed to trigger workflows manually.
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
schedule:
- cron: '31 18 * * 5' # run every Friday
jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest] # windows-latest
python-version: ['3.12', '3.13', '3.14']
# vvv just an example of excluding stuff from matrix
# exclude: [{platform: macos-latest, python-version: '3.6'}]
runs-on: ${{ matrix.platform }}
# useful for 'optional' pipelines
# continue-on-error: ${{ matrix.platform == 'windows-latest' }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0 # nicer to have all git history when debugging/for tests
- uses: astral-sh/setup-uv@v8.1.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: false # we don't have lock files during initial CI checkout, so can't use them as cache key
- uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true # restrict to the user who kicked off pipeline
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
# explicit bash command is necessary for Windows CI runner, otherwise it thinks it's cmd...
- run: bash .ci/run
pypi:
# Do not run it for PRs/cron schedule etc.
# NOTE: release tags are guarded by on: push: tags on the top.
if: github.event_name == 'push' && (github.ref_type == 'tag' || github.ref_name == github.event.repository.master_branch)
# Ugh, I tried using matrix or something to explicitly generate only test pypi or prod pypi pipelines.
# But github actions is so shit, it's impossible to do any logic at all, e.g. doesn't support conditional matrix, if/else statements for variables etc.
needs: [build] # add all other jobs here
runs-on: ubuntu-latest
permissions:
# necessary for Trusted Publishing
id-token: write
env:
# always deploy merged master to test pypi
# always deploy tags to release pypi
TARGET: ${{ github.ref_type == 'tag' && 'pypi' || 'testpypi' }}
environment:
# for "deployments" tab on github
# sadly can't reuse env.TARGET here...
name: ${{ github.ref_type == 'tag' && 'pypi' || 'testpypi' }}
url: https://${{ github.ref_type == 'tag' && 'pypi.org' || 'test.pypi.org' }}/project/${{ steps.meta.outputs.pypi_name }}/
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0 # pull all commits to correctly infer vcs version
- uses: astral-sh/setup-uv@v8.1.0
with:
python-version: '3.12'
enable-cache: false # we don't have lock files during initial CI checkout, so can't use them as cache key
- name: 'release ${{ steps.meta.outputs.pypi_name }} to ${{ env.TARGET }}'
run: .ci/release ${{ env.TARGET == 'testpypi' && '--use-test-pypi' || '' }}
- id: meta
shell: bash
run: |
pypi_name=$(unzip -p dist/*.whl '*.dist-info/METADATA' | awk '/^Name:/ {print $2; exit}')
echo "pypi_name=$pypi_name" >> "$GITHUB_OUTPUT"