deploy #11
This file contains hidden or 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
| 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: | |
| - 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/ | |
| 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: Build public health | |
| run: | | |
| cd libs/public_health | |
| python -m build | |
| - name: Publish public health to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: libs/public_health/dist/ |