Skip to content

deploy

deploy #12

Workflow file for this run

name: deploy
on:
release:
types: [published]
workflow_dispatch:
inputs:
package:
description: 'Package to deploy'
required: true
default: 'core'
type: choice
options:
- core
- public_health
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Set package variables
run: |
# Determine package name from release tag or workflow dispatch input
if [ "${{ github.event_name }}" = "release" ]; then
if [[ "${{ github.event.release.tag_name }}" == *"core-v"* ]]; then
PACKAGE_NAME="core"
PACKAGE_PATH="libs/core"
TAG_PATTERN="core-v"
elif [[ "${{ github.event.release.tag_name }}" == *"public-health-v"* ]]; then
PACKAGE_NAME="public_health"
PACKAGE_PATH="libs/public_health"
TAG_PATTERN="public-health-v"
fi
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
PACKAGE_NAME="${{ github.event.inputs.package }}"
if [ "$PACKAGE_NAME" = "core" ]; then
PACKAGE_PATH="libs/core"
TAG_PATTERN="core-v"
elif [ "$PACKAGE_NAME" = "public_health" ]; then
PACKAGE_PATH="libs/public_health"
TAG_PATTERN="public-health-v"
fi
fi
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
echo "PACKAGE_PATH=$PACKAGE_PATH" >> $GITHUB_ENV
echo "TAG_PATTERN=$TAG_PATTERN" >> $GITHUB_ENV
echo "Deploying package: $PACKAGE_NAME from path: $PACKAGE_PATH"
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for setuptools_scm
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Fetch git tags for ${PACKAGE_NAME}
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
echo "Available ${PACKAGE_NAME} tags:"
git tag --list "${TAG_PATTERN}*" | head -10
echo "Current git describe for ${PACKAGE_NAME} tags:"
git describe --tags --match "${TAG_PATTERN}*" || echo "No ${PACKAGE_NAME} tags found"
echo "Git log --oneline (last 5):"
git log --oneline -5
- name: Install dependencies
run: |
python --version
uv pip install --system setuptools wheel build
- name: Build ${PACKAGE_NAME}
run: |
cd ${PACKAGE_PATH}
python -m build
- name: Publish ${PACKAGE_NAME} to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ env.PACKAGE_PATH }}/dist/