Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update publish.yaml with latest PyPI recommendations #2516

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 88 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,97 @@ on:
- '*'

jobs:
publish:
name: "Publish release"
runs-on: "ubuntu-latest"
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.inspect_package.outputs.version }}

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.8"
Kludex marked this conversation as resolved.
Show resolved Hide resolved

- name: Install dependencies
run: scripts/install

- name: Build package & docs
run: scripts/build

- name: Inspect package version
id: inspect_package
run: |
version=$(uvx hatchling version)
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Check tag matches package version
run: |
version=$(cat "$GITHUB_OUTPUT" | grep -oP 'version=\K.*')
tag=$(echo "${GITHUB_REF#refs/tags/}")
if [ "$version" != "$tag" ]; then
echo "Tag '$tag' does not match package version '$version'"
exit 1
fi

- name: Upload package distributions
uses: actions/upload-artifact@v2
with:
name: package-distributions
path: dist/

- name: Upload documentation
uses: actions/upload-artifact@v2
with:
name: documentation
path: site/

pypi-publish:
runs-on: ubuntu-latest
needs: build

permissions:
id-token: write

environment:
name: deploy
name: pypi
url: https://pypi.org/project/uvicorn/${{ needs.build.outputs.version }}

steps:
- uses: "actions/checkout@v4"
- uses: "actions/setup-python@v5"
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: package-distributions
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

docs-publish:
runs-on: ubuntu-latest
needs: build

permissions:
contents: write

steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: documentation
path: site/

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com

- uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: "Install dependencies"
run: "scripts/install"
- name: "Build package & docs"
run: "scripts/build"
- name: "Publish to PyPI & deploy docs"
run: "scripts/publish"
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

- name: Install dependencies
run: scripts/install

- name: Publish documentation 📚 to GitHub Pages
run: mkdocs gh-deploy --force
Loading