Skip to content

deploy

deploy #5

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-core:
if: ${{ (github.event_name == 'release' && contains(github.event.release.tag_name, 'core-v')) || github.event.inputs.package == 'core' }}
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- 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 core
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
echo "Available core tags:"
git tag --list "core-v*" | head -10
echo "Current git describe for core tags:"
git describe --tags --match "core-v*" || echo "No core 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: Debug setuptools_scm for core
run: |
cd libs/core
python -c "
import setuptools_scm
try:
version = setuptools_scm.get_version()
print(f'setuptools_scm detected version: {version}')
except Exception as e:
print(f'setuptools_scm error: {e}')
import traceback
traceback.print_exc()
"
- name: Build core
run: |
cd libs/core
# Try auto-detection first, fall back to tag-based version if needed
if python -c "import setuptools_scm; setuptools_scm.get_version()" > /dev/null 2>&1; then
echo "Using setuptools_scm auto-detected version"
python -m build
elif [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.tag_name }}" == core-v* ]]; then
TAG_NAME="${{ github.event.release.tag_name }}"
VERSION="${TAG_NAME#core-v}"
echo "Auto-detection failed, using explicit version from tag: $VERSION"
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_SIM_SCI_TEST_MONOREPO_CORE="$VERSION" python -m build
else
echo "No version could be determined, trying build anyway"
python -m build
fi
- name: Publish core to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: libs/core/dist/
- name: Send mail on failure
if: failure()
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.NOTIFY_EMAIL }}
password: ${{ secrets.NOTIFY_PASSWORD }}
subject: Core deployment of ${{ github.repository }} has failed
body: Core package deployment in workflow ${{ github.workflow }} of ${{ github.repository }} has failed
to: uw_ihme_simulationscience@uw.edu
from: SimSci Notifications
deploy-public-health:
if: ${{ (github.event_name == 'release' && contains(github.event.release.tag_name, 'public-health-v')) || github.event.inputs.package == 'public_health' }}
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- 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 public health
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
echo "Available public health tags:"
git tag --list "public-health-v*" | head -10
echo "Current git describe for public health tags:"
git describe --tags --match "public-health-v*" || echo "No public health 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: Debug setuptools_scm for public health
run: |
cd libs/public_health
python -c "
import setuptools_scm
try:
version = setuptools_scm.get_version()
print(f'setuptools_scm detected version: {version}')
except Exception as e:
print(f'setuptools_scm error: {e}')
import traceback
traceback.print_exc()
"
- name: Build public health
run: |
cd libs/public_health
# Try auto-detection first, fall back to tag-based version if needed
if python -c "import setuptools_scm; setuptools_scm.get_version()" > /dev/null 2>&1; then
echo "Using setuptools_scm auto-detected version"
python -m build
elif [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.tag_name }}" == public-health-v* ]]; then
TAG_NAME="${{ github.event.release.tag_name }}"
VERSION="${TAG_NAME#public-health-v}"
echo "Auto-detection failed, using explicit version from tag: $VERSION"
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_SIM_SCI_TEST_MONOREPO_PUBLIC_HEALTH="$VERSION" python -m build
else
echo "No version could be determined, trying build anyway"
python -m build
fi
- name: Publish public health to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: libs/public_health/dist/
- name: Send mail on failure
if: failure()
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.NOTIFY_EMAIL }}
password: ${{ secrets.NOTIFY_PASSWORD }}
subject: Public Health deployment of ${{ github.repository }} has failed
body: Public Health package deployment in workflow ${{ github.workflow }} of ${{ github.repository }} has failed
to: uw_ihme_simulationscience@uw.edu
from: SimSci Notifications
notify-success:
if: ${{ always() && (needs.deploy-core.result == 'success' || needs.deploy-public-health.result == 'success') }}
needs: [deploy-core, deploy-public-health]
runs-on: ubuntu-latest
steps:
- name: Send success notification
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.NOTIFY_EMAIL }}
password: ${{ secrets.NOTIFY_PASSWORD }}
subject: Successful deployment of ${{ github.repository }}
body: |
Deployment workflow ${{ github.workflow }} of ${{ github.repository }} completed successfully!
Core deployment: ${{ needs.deploy-core.result }}
Public Health deployment: ${{ needs.deploy-public-health.result }}
Packages are now available on PyPI:
- sim-sci-test-monorepo-core
- sim-sci-test-monorepo-public-health
to: uw_ihme_simulationscience@uw.edu
from: SimSci Notifications