Skip to content

Commit 16178f1

Browse files
Merge pull request #1029 from VWS-Python/gha-release
Change release process to use GitHub actions
2 parents 7d899c9 + 874c712 commit 16178f1

File tree

7 files changed

+64
-87
lines changed

7 files changed

+64
-87
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
3+
name: Release
4+
5+
on: workflow_dispatch
6+
7+
jobs:
8+
build:
9+
name: Publish a release
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
python-version: ["3.10"]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: "Set up Python"
20+
uses: actions/setup-python@v1
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- uses: actions/cache@v2
25+
with:
26+
path: ~/.cache/pip
27+
# This is like the example but we use ``*requirements.txt`` rather
28+
# than ``requirements.txt`` because we have multiple requirements
29+
# files.
30+
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }}
31+
restore-keys: |
32+
${{ runner.os }}-pip-
33+
34+
- name: "Install dependencies"
35+
run: |
36+
python -m pip install --upgrade pip setuptools wheel
37+
# We use '--ignore-installed' to avoid GitHub's cache which can cause
38+
# issues - we have seen packages from this cache cause trouble with
39+
# pip-extra-reqs.
40+
python -m pip install --ignore-installed --upgrade --editable .[dev]
41+
42+
- name: "Publish a release"
43+
env:
44+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
45+
run: |
46+
python admin/release.py
47+
48+
- name: Build a binary wheel and a source tarball
49+
run: |
50+
# Checkout the latest tag - the one we just created.
51+
git fetch --tags
52+
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
53+
python -m build --sdist --wheel --outdir dist/ .
54+
55+
- name: Publish distribution 📦 to PyPI
56+
uses: pypa/gh-action-pypi-publish@master
57+
with:
58+
password: ${{ secrets.PYPI_API_TOKEN }}
59+
verbose: true

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ lint: \
2222
pip-extra-reqs \
2323
pip-missing-reqs \
2424
pyroma \
25-
shellcheck \
2625
spelling \
2726
vulture \
2827
pylint \

admin/release.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ def main() -> None:
6262
Perform a release.
6363
"""
6464
github_token = os.environ['GITHUB_TOKEN']
65-
github_owner = os.environ['GITHUB_OWNER']
66-
github_repository_name = os.environ['GITHUB_REPOSITORY_NAME']
65+
github_repository_name = os.environ['GITHUB_REPOSITORY']
6766
github_client = Github(github_token)
6867
github_repository = github_client.get_repo(
69-
full_name_or_id=f'{github_owner}/{github_repository_name}',
68+
full_name_or_id=github_repository_name,
7069
)
7170
version_str = get_version(github_repository=github_repository)
7271
update_changelog(version=version_str, github_repository=github_repository)

admin/release.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/source/release-process.rst

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,15 @@ Outcomes
77
* A new ``git`` tag available to install.
88
* A new package on PyPI.
99

10-
Prerequisites
11-
~~~~~~~~~~~~~
12-
13-
* ``python3`` on your ``PATH`` set to Python |python-minumum-version|\+.
14-
* ``virtualenv``.
15-
* Push access to this repository.
16-
* Trust that ``master`` is ready and high enough quality for release.
17-
1810
Perform a Release
1911
~~~~~~~~~~~~~~~~~
2012

21-
#. Get a GitHub access token:
22-
23-
Follow the `GitHub access token instructions`_ for getting an access token.
24-
25-
#. Set environment variables to GitHub credentials, e.g.:
26-
27-
.. prompt:: bash
28-
29-
export GITHUB_TOKEN=75c72ad718d9c346c13d30ce762f121647b502414
13+
#. `Install GitHub CLI`_.
3014

3115
#. Perform a release:
3216

3317
.. prompt:: bash
34-
:substitutions:
3518

36-
export GITHUB_OWNER=|github-owner|
37-
export GITHUB_REPOSITORY_NAME=|github-repository|
38-
curl https://raw.githubusercontent.com/"$GITHUB_OWNER"/"$GITHUB_REPOSITORY_NAME"/master/admin/release.sh | bash
19+
$ gh workflow run release.yml
3920

40-
.. _GitHub access token instructions: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line/
21+
.. _Install GitHub CLI: https://cli.github.com/manual/installation

lint.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ linkcheck:
6868
spelling:
6969
$(MAKE) -C docs/ spelling SPHINXOPTS=$(SPHINXOPTS)
7070

71-
.PHONY: shellcheck
72-
shellcheck:
73-
shellcheck --exclude SC2164,SC1091 */*.sh
74-
7571
.PHONY: autoflake
7672
autoflake:
7773
autoflake \

0 commit comments

Comments
 (0)