From aebf1f5ea5eaf9ffe5e8df11cfef8bf6d85d9b0e Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 20 Nov 2024 20:29:26 +0100 Subject: [PATCH 1/5] Update `publish.yaml` with latest PyPI recommendations --- .github/workflows/publish.yml | 103 +++++++++++++++++++++++++++++----- 1 file changed, 88 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7ecef5559..e473b9f0a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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" + + - 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 From 8fe0cd312056c1bb87e522a54438d945bfc133c6 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 20 Nov 2024 20:29:53 +0100 Subject: [PATCH 2/5] Update .github/workflows/publish.yml --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e473b9f0a..01cc41e5b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.12" - name: Install dependencies run: scripts/install From a55284c12dbae97ab9dde6058de96005bbd930fe Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 20 Nov 2024 20:32:08 +0100 Subject: [PATCH 3/5] Simplify pipeline --- .github/workflows/publish.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e473b9f0a..fcb514bde 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,8 +8,6 @@ on: jobs: build: runs-on: ubuntu-latest - outputs: - version: ${{ steps.inspect_package.outputs.version }} steps: - uses: actions/checkout@v4 @@ -24,21 +22,6 @@ jobs: - 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: From 6088f064d9bd1091a897cf8a0743e3a0d409c436 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 20 Nov 2024 20:32:51 +0100 Subject: [PATCH 4/5] Simplify pipeline --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bd2884b62..8e3da71ac 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -43,7 +43,7 @@ jobs: environment: name: pypi - url: https://pypi.org/project/uvicorn/${{ needs.build.outputs.version }} + url: https://pypi.org/project/uvicorn steps: - name: Download artifacts From 07627c84bdf57d1e59f8644b9ef5fe99737106f7 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 20 Nov 2024 20:34:19 +0100 Subject: [PATCH 5/5] Use Python 3.12 --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8e3da71ac..c97c1acac 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -76,7 +76,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.12" - name: Install dependencies run: scripts/install