Skip to content

Commit 9cf8322

Browse files
chore: better handle packaging
Upload to TestPyPI after some sucessful tests Only keep 2 GA workflows, with all the funny things it means
1 parent d0cd9b8 commit 9cf8322

File tree

3 files changed

+70
-51
lines changed

3 files changed

+70
-51
lines changed

.github/workflows/package-without-publish.yml

-42
This file was deleted.

.github/workflows/release.yml

+48-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,56 @@
11
name: Kazoo Awesome Release
22

33
on:
4+
workflow_call:
5+
inputs:
6+
TAG_BUILD:
7+
description: 'The egg info tag build (will be appended to `kazoo.version` value)'
8+
default: ""
9+
required: false
10+
type: string
11+
USE_TEST_PYPI:
12+
description: 'Whether to the use the TestPyPI repository or not'
13+
default: false
14+
required: false
15+
type: boolean
16+
PYTHON_VERSION:
17+
description: 'The Python version to use to perform the steps'
18+
default: ""
19+
required: true
20+
type: string
21+
secrets:
22+
TEST_PYPI_API_TOKEN:
23+
required: false
24+
PYPI_API_TOKEN:
25+
required: false
426
push:
527
tags:
628
- '*'
729

30+
env:
31+
DEFAULT_TOOLING_PYTHON_VERSION: "3.10"
32+
833
jobs:
934
build-and-release:
10-
name: Build and release Kazoo to Pypi
35+
name: Build and release Kazoo to PyPI
1136
runs-on: ubuntu-latest
1237
steps:
38+
39+
# this is to handle the on:push:tags case, to which it is not possible to set
40+
# default values
41+
- name: Maybe set default vars
42+
id: thevars
43+
run: |
44+
DEFINED_PYTHON_VERSION=${{ inputs.PYTHON_VERSION }}
45+
echo "PYTHON_VERSION=${DEFINED_PYTHON_VERSION:-"${{ env.DEFAULT_TOOLING_PYTHON_VERSION }}"}" >> $GITHUB_OUTPUT
46+
1347
- name: Handle the code
1448
uses: actions/checkout@v3
1549

16-
- name: Set up Python 3.10
50+
- name: Set up Python
1751
uses: actions/setup-python@v4
1852
with:
19-
python-version: "3.10"
53+
python-version: ${{ steps.thevars.outputs.PYTHON_VERSION }}
2054

2155
- name: Install pypa/build
2256
run: >-
@@ -29,15 +63,22 @@ jobs:
2963
run: >-
3064
python -m
3165
build
32-
-C--global-option=egg_info
33-
-C--global-option=--tag-build=""
66+
-C--build-option=egg_info
67+
-C--build-option=--tag-build="${{ inputs.TAG_BUILD }}"
3468
--sdist
3569
--wheel
3670
--outdir dist/
3771
.
3872
73+
- name: Publish Kazoo to TestPyPI
74+
if: ${{ inputs.USE_TEST_PYPI }}
75+
uses: pypa/gh-action-pypi-publish@release/v1
76+
with:
77+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
78+
repository_url: https://test.pypi.org/legacy/
79+
3980
- name: Publish Kazoo to PyPI
40-
if: startsWith(github.ref, 'refs/tags')
41-
uses: pypa/gh-action-pypi-publish@master
81+
if: ${{ github.event_name == 'push' || !inputs.USE_TEST_PYPI }}
82+
uses: pypa/gh-action-pypi-publish@release/v1
4283
with:
4384
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/testing.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,27 @@ on:
1010
- master
1111
- release/*
1212

13+
env:
14+
TOOLING_PYTHON_VERSION: "3.10"
15+
1316
jobs:
1417
validate:
1518
name: Code Validation
1619

1720
runs-on: ubuntu-latest
1821

22+
outputs:
23+
tooling-python-version: ${{ steps.setup-python.outputs.python-version }}
24+
1925
steps:
2026
- name: Handle the code
2127
uses: actions/checkout@v3
2228

23-
- name: "Set up Python 3.10"
29+
- name: "Set up Python"
2430
uses: actions/setup-python@v4
31+
id: setup-python
2532
with:
26-
python-version: "3.10"
33+
python-version: ${{ env.TOOLING_PYTHON_VERSION }}
2734

2835
- name: Handle pip cache
2936
uses: actions/cache@v3
@@ -111,3 +118,16 @@ jobs:
111118

112119
- name: Publish Codecov report
113120
uses: codecov/codecov-action@v3
121+
122+
package_and_release:
123+
name: "Package & release"
124+
needs: [validate, test]
125+
uses: ./.github/workflows/release.yml
126+
with:
127+
# https://peps.python.org/pep-0440
128+
TAG_BUILD: -dev0+g${{ github.sha }}.1
129+
USE_TEST_PYPI: true
130+
# cant use ${{ env.STUFF }} here...
131+
PYTHON_VERSION: ${{ needs.validate.outputs.tooling-python-version }}
132+
secrets:
133+
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)