Skip to content

Commit 0279f22

Browse files
committed
Improve deploy workflow and testing
* Create the package first, and test on all platforms using it. * Deploy is now manually triggered, and requires approvals.
1 parent 21b6f66 commit 0279f22

File tree

3 files changed

+54
-26
lines changed

3 files changed

+54
-26
lines changed

.github/workflows/deploy.yml

+28-8
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,49 @@
11
name: deploy
22

33
on:
4-
push:
5-
tags:
6-
- "[0-9]+.[0-9]+.[0-9]+"
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version'
8+
required: true
9+
default: '1.2.3'
710

811
jobs:
9-
deploy:
10-
if: github.repository == 'pytest-dev/pytest-subtests'
1112

13+
package:
1214
runs-on: ubuntu-latest
15+
env:
16+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
1317

1418
steps:
1519
- uses: actions/checkout@v3
1620

1721
- name: Build and Check Package
1822
uses: hynek/build-and-inspect-python-package@v1.5
1923

24+
deploy:
25+
needs: package
26+
runs-on: ubuntu-latest
27+
environment: deploy
28+
permissions:
29+
id-token: write # For PyPI trusted publishers.
30+
contents: write # For tag.
31+
32+
steps:
33+
- uses: actions/checkout@v3
34+
2035
- name: Download Package
2136
uses: actions/download-artifact@v3
2237
with:
2338
name: Packages
2439
path: dist
2540

2641
- name: Publish package to PyPI
27-
uses: pypa/gh-action-pypi-publish@release/v1
28-
with:
29-
password: ${{ secrets.pypi_token }}
42+
uses: pypa/gh-action-pypi-publish@v1.8.5
43+
44+
- name: Push tag
45+
run: |
46+
git config user.name "pytest bot"
47+
git config user.email "pytestbot@gmail.com"
48+
git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
49+
git push origin v${{ github.event.inputs.version }}

.github/workflows/test.yml

+22-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ name: test
33
on:
44
push:
55
branches:
6+
- main
7+
- "test-me-*"
8+
69
pull_request:
10+
branches:
11+
- "*"
712

813

914
# Cancel running jobs for the same workflow and branch.
@@ -12,10 +17,17 @@ concurrency:
1217
cancel-in-progress: true
1318

1419
jobs:
15-
test:
1620

17-
runs-on: ${{ matrix.os }}
21+
package:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Build and Check Package
26+
uses: hynek/build-and-inspect-python-package@v1.5
1827

28+
test:
29+
needs: [package]
30+
runs-on: ${{ matrix.os }}
1931
strategy:
2032
fail-fast: false
2133
matrix:
@@ -79,6 +91,12 @@ jobs:
7991
steps:
8092
- uses: actions/checkout@v3
8193

94+
- name: Download Package
95+
uses: actions/download-artifact@v3
96+
with:
97+
name: Packages
98+
path: dist
99+
82100
- name: Set up Python
83101
uses: actions/setup-python@v4
84102
with:
@@ -90,12 +108,6 @@ jobs:
90108
python -m pip install --upgrade tox
91109
92110
- name: Test
111+
shell: bash
93112
run: |
94-
tox -e ${{ matrix.tox_env }}
95-
96-
check-package:
97-
runs-on: ubuntu-latest
98-
steps:
99-
- uses: actions/checkout@v3
100-
- name: Build and Check Package
101-
uses: hynek/build-and-inspect-python-package@v1.5
113+
tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`

RELEASING.rst

+4-8
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ Steps
2222

2323
To publish a new release ``X.Y.Z``, the steps are as follows:
2424

25-
#. Create a new branch named ``release-X.Y.Z`` from the latest ``master``.
25+
#. Create a new branch named ``release-X.Y.Z`` from the latest ``main``.
2626

2727
#. Update the ``CHANGELOG.rst`` file with the new release information.
2828

29-
#. Commit and push the branch for review.
29+
#. Commit and push the branch to ``upstream`` and open a PR.
3030

31-
#. Once PR is **green** and **approved**, create and push a tag::
31+
#. Once the PR is **green** and **approved**, start the ``deploy`` workflow manually from the branch ``release-VERSION``, passing ``VERSION`` as parameter.
3232

33-
$ export VERSION=X.Y.Z
34-
$ git tag v$VERSION release-$VERSION
35-
$ git push git@github.com:pytest-dev/pytest-subtests.git v$VERSION
36-
37-
That will build the package and publish it on ``PyPI`` automatically.
33+
#. Merge the release PR to ``main``.

0 commit comments

Comments
 (0)