Skip to content

Update vars dict and publish Python package (pre-release) #11

Update vars dict and publish Python package (pre-release)

Update vars dict and publish Python package (pre-release) #11

Workflow file for this run

on:
workflow_dispatch:
inputs:
environment:
type: choice
description: Deployment environment
options:
- test
- prod
- skip
default: test
release:
types:
- released
- prereleased
name: pypi-publish
env:
PYTHONUNBUFFERED: "1"
jobs:
pypi-publish:
name: pypi-publish
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Build Python dist
working-directory: python
run: |
# Copy over any necessary data files
mkdir -p ccao/data/
cp ../data-raw/vars_dict.csv ccao/data/vars_dict.csv
# Build the package
uv build
- name: Publish package distribution to test PyPI
if: ${{ github.event.action == 'prereleased' || inputs.environment == 'test' }}
env:
url: https://test.pypi.org/legacy/p/ccao
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# The build step builds the package distribution in the `python/`
# subdirectory, but the `gh-action-pypi-publish` action expects the
# package to be located in a `dist/` subdirectory in the root of the
# repo by default. Since third-party actions can't use the
# `working-directory` attribute, we need to specify the location of
# the package distribution here instead
packages-dir: python/dist/
- name: Publish package distribution to PyPI
if: ${{ github.event.action == 'released' || inputs.environment == 'prod' }}
env:
url: https://pypi.org/p/ccao
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: python/dist/