publish python packages to pypi in ci #35
Workflow file for this run
This file contains 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: Test, visualize, and build calitp-data-analysis | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- '.github/workflows/build-calitp-data-analysis.yml' | |
- 'packages/calitp-data-analysis/calitp_data_analysis/**' | |
pull_request: | |
paths: | |
- '.github/workflows/build-calitp-data-analysis.yml' | |
- 'packages/calitp-data-analysis/calitp_data_analysis/**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
jobs: | |
check_and_build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: packages/calitp-data-analysis | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- uses: google-github-actions/setup-gcloud@v0 | |
with: | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
export_default_credentials: true | |
- name: Run checks | |
run: | | |
curl -sSL https://install.python-poetry.org | python - | |
poetry install | |
poetry run mypy . | |
poetry run pytest | |
poetry build | |
- if: ${{ github.ref != 'refs/heads/main' }} | |
run: | | |
poetry config repositories.test-pypi https://test.pypi.org/legacy/ | |
poetry config pypi-token.test-pypi $POETRY_TEST_PYPI_TOKEN_PYPI | |
poetry publish -r test-pypi --skip-existing | |
env: | |
POETRY_TEST_PYPI_TOKEN_PYPI: ${{ secrets.TEST_PYPI_CALITP_DATA_ANALYSIS_TOKEN }} | |
- if: ${{ github.ref == 'refs/heads/main' }} | |
run: poetry publish --skip-existing | |
env: | |
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_CALITP_DATA_ANALYSIS_TOKEN }} |