Skip to content

Only trigger test gate when publishing #6

Only trigger test gate when publishing

Only trigger test gate when publishing #6

Workflow file for this run

# This workflow is triggered two ways:
#
# 1. When a tag is created, the workflow will upload the package to
# test.pypi.org.
# 2. When a release is made, the workflow will upload the package to pypi.org.
#
# It is done this way until PyPI has draft reviews, to allow for a two-stage
# upload with a chance for manual intervention before the final publication.
name: Upload package
on:
push:
pull_request:
release:
types:
- published
workflow_dispatch:
permissions:
contents: read
env:
FORCE_COLOR: 1
jobs:
build-package:
name: Build & verify package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: hynek/build-and-inspect-python-package@fe0a0fb1925ca263d076ca4f2c13e93a6e92a33e # v2.17.0
test-package:
name: Test package
if: |
github.repository_owner == 'python'
&& (
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|| github.event.action == 'published'
)
needs: build-package
uses: ./.github/workflows/tests.yml
# Publish to Test PyPI for every tag.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
if: |
github.repository_owner == 'python'
&& github.event_name == 'push'
&& startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: test-package
permissions:
id-token: write
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages
path: dist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
with:
repository-url: https://test.pypi.org/legacy/
release-pypi:
name: Publish to PyPI
# Only run for published releases.
if: |
github.repository_owner == 'python'
&& github.event.action == 'published'
runs-on: ubuntu-latest
needs: test-package
environment:
name: release
url: >-
https://pypi.org/project/tzdata/${{
github.event.release.tag_name
}}
permissions:
id-token: write
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0