Skip to content

Commit

Permalink
chore: better handle packaging
Browse files Browse the repository at this point in the history
Upload to TestPyPI after some sucessful tests
Only keep 2 GA workflows, with all the funny things it means
  • Loading branch information
StephenSorriaux committed Feb 6, 2023
1 parent ffd3aac commit 333e05b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 49 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/package-without-publish.yml

This file was deleted.

46 changes: 41 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,51 @@
name: Kazoo Awesome Release

on:
workflow_call:
inputs:
TAG_BUILD:
description: 'The egg info tag build (will be appended to `kazoo.version` value)'
default: ""
required: false
type: string
USE_TEST_PYPI:
description: 'Whether to the use the TestPyPI repository or not'
default: false
required: false
type: boolean
PYTHON_VERSION:
description: 'The Python version to use to perform the steps'
default: ""
required: true
type: string
push:
tags:
- '*'

env:
DEFAULT_TOOLING_PYTHON_VERSION: "3.10"

jobs:
build-and-release:
name: Build and release Kazoo to Pypi
name: Build and release Kazoo to PyPI
runs-on: ubuntu-latest
steps:

# this is to handle the on:push:tags case, to which it is not possible to set
# default values
- name: Maybe set default vars
id: thevars
run: |
DEFINED_PYTHON_VERSION=${{ github.event.inputs.PYTHON_VERSION }}
echo "::set-output name=PYTHON_VERSION::${DEFINED_PYTHON_VERSION:-"${{ env.DEFAULT_TOOLING_PYTHON_VERSION }}"}"
- name: Handle the code
uses: actions/checkout@v3

- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: ${{ steps.thevars.outputs.PYTHON_VERSION }}

- name: Install pypa/build
run: >-
Expand All @@ -30,14 +59,21 @@ jobs:
python -m
build
-C--global-option=egg_info
-C--global-option=--tag-build=""
-C--global-option=--tag-build="${{ inputs.TAG_BUILD }}"
--sdist
--wheel
--outdir dist/
.
- name: Publish Kazoo to TestPyPI
if: inputs.USE_TEST_PYPI == 'true'
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish Kazoo to PyPI
if: startsWith(github.ref, 'refs/tags')
if: inputs.USE_TEST_PYPI == 'false'
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
16 changes: 14 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
- master
- release/*

env:
TOOLING_PYTHON_VERSION: "3.10"
TEST_PYPI_URL: https://test.pypi.org/legacy/

jobs:
validate:
name: Code Validation
Expand All @@ -20,10 +24,10 @@ jobs:
- name: Handle the code
uses: actions/checkout@v3

- name: "Set up Python 3.10"
- name: "Set up Python"
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: ${{ env.TOOLING_PYTHON_VERSION }}

- name: Handle pip cache
uses: actions/cache@v3
Expand Down Expand Up @@ -111,3 +115,11 @@ jobs:

- name: Publish Codecov report
uses: codecov/codecov-action@v3

package_and_release:
needs: [test]
uses: ./.github/workflows/release.yml
with:
TAG_BUILD: dev-${{ github.sha }}
USE_TEST_PYPI: true
PYTHON_VERSION: ${{ env.TOOLING_PYTHON_VERSION }}

0 comments on commit 333e05b

Please sign in to comment.