From 6121726b090760fe79720c7715084dff4864da4a Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Thu, 12 Sep 2024 00:12:03 +0300 Subject: [PATCH] Set up release automation Heavily based on the setup in `django-stubs` --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/test.yml | 18 ++++++++++++++++++ scripts/release.sh | 18 ------------------ 3 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100755 scripts/release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..855aeccab --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +name: Release + +on: + release: + types: [published] + +jobs: + build-and-publish: + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/p/djangorestframework-stubs + permissions: + id-token: write + steps: + - name: Setup python to build package + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install build + run: python -m pip install build + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Build package + run: python -m build + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@v1.10.1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3856d442..3c1085b93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -92,3 +92,21 @@ jobs: - name: Run stubtest run: bash ./scripts/stubtest.sh + + build-and-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-tags: true + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install dependencies + run: python3 -m pip install --upgrade build twine + - name: Build + run: | + python3 -m build --sdist --wheel . + - name: Check package metadata + run: | + twine check --strict dist/* diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index 71281961a..000000000 --- a/scripts/release.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -set -ex - -if [[ -z $(git status -s) ]] -then - if [[ "$VIRTUAL_ENV" != "" ]] - then - pip install --upgrade setuptools wheel twine - rm -rf dist/ build/ - python setup.py sdist bdist_wheel - twine upload dist/* - rm -rf dist/ build/ - else - echo "this script must be executed inside an active virtual env, aborting" - fi -else - echo "git working tree is not clean, aborting" -fi