Skip to content

Migrate to trusted publishing #77

Migrate to trusted publishing

Migrate to trusted publishing #77

Workflow file for this run

# This workflow is triggered two ways:

Check failure on line 1 in .github/workflows/publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish.yml

Invalid workflow file

(Line: 46, Col: 11): Unexpected symbol: '"release"'. Located at position 22 within expression: github.event_name != "release" && github.event_name == "push" && startsWith(github.ref, "refs/tags"), (Line: 51, Col: 11): Unexpected symbol: '"release"'. Located at position 22 within expression: github.event_name == "release"
#
# 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:
release:
types: [created]
push:
tags:
- '*'
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/tzdata
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U tox
- name: Create tox environments
run: |
tox -p -e py,build,release --notest
- name: Run tests
run: |
tox -e py
- name: Build package
run: |
tox -e build
- name: Publish package (TestPyPI)
if: github.event_name != "release" && github.event_name == "push" && startsWith(github.ref, "refs/tags")
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish package
if: github.event_name == "release"
uses: pypa/gh-action-pypi-publish@release/v1