From 31df8825290967b0623aa5afa624c8762d42e375 Mon Sep 17 00:00:00 2001 From: Petter Friberg Date: Tue, 19 Mar 2024 21:42:09 +0100 Subject: [PATCH] Add GitHub actions release workflow (#1950) --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/test.yml | 20 ++++++++++++++++++++ scripts/release.sh | 18 ------------------ 3 files changed, 48 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..c3277343f --- /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/django-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.8.14 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9675eff0c..14b6cc012 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -133,3 +133,23 @@ jobs: - name: Run django-stubs-ext tests run: PYTHONPATH='.' pytest ext + + 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 . + python3 -m build --sdist --wheel ext/ + - name: Check package metadata + run: | + twine check --strict dist/* + twine check --strict ext/dist/* diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index de8ab2da6..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 build - rm -rf dist/ build/ - python -m build - 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