Skip to content

Commit

Permalink
Use proper publish workflow (#328)
Browse files Browse the repository at this point in the history
* Use proper publish workflow

* Push

* Update flow

* Test output

* Beautiful

* Cute
  • Loading branch information
Kludex authored Sep 20, 2024
1 parent 276b43a commit e4f2a16
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 29 deletions.
79 changes: 51 additions & 28 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,59 @@
name: Publish Python Package

on:
release:
types: [created]
push:
tags:
- "**"

jobs:
deploy:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.inspect_package.outputs.version }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- uses: actions/cache@v2
name: Configure pip caching
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "0.4.12"
enable-cache: true

- name: Set up Python
run: uv python install 3.12

- name: Build package
run: uv build

- name: Inspect package version
id: inspect_package
run: |
version=$(uvx hatchling version)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: package-distributions
path: dist/

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

permissions:
id-token: write

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

steps:
- name: Download package
uses: actions/download-artifact@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-publish-pip-
- name: Install dependencies
run: |
pip install -U -r requirements.txt
pip install setuptools wheel twine
- name: Run tests
run: scripts/test
- name: Publish
if: success()
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
name: package-distributions
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 0 additions & 1 deletion docs/CNAME

This file was deleted.

0 comments on commit e4f2a16

Please sign in to comment.