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 Mar 10, 2023
1 parent d0cd9b8 commit 9cf8322
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 51 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/package-without-publish.yml

This file was deleted.

55 changes: 48 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
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
secrets:
TEST_PYPI_API_TOKEN:
required: false
PYPI_API_TOKEN:
required: false
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=${{ inputs.PYTHON_VERSION }}
echo "PYTHON_VERSION=${DEFINED_PYTHON_VERSION:-"${{ env.DEFAULT_TOOLING_PYTHON_VERSION }}"}" >> $GITHUB_OUTPUT
- 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 @@ -29,15 +63,22 @@ jobs:
run: >-
python -m
build
-C--global-option=egg_info
-C--global-option=--tag-build=""
-C--build-option=egg_info
-C--build-option=--tag-build="${{ inputs.TAG_BUILD }}"
--sdist
--wheel
--outdir dist/
.
- name: Publish Kazoo to TestPyPI
if: ${{ inputs.USE_TEST_PYPI }}
uses: pypa/gh-action-pypi-publish@release/v1
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')
uses: pypa/gh-action-pypi-publish@master
if: ${{ github.event_name == 'push' || !inputs.USE_TEST_PYPI }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
24 changes: 22 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,27 @@ on:
- master
- release/*

env:
TOOLING_PYTHON_VERSION: "3.10"

jobs:
validate:
name: Code Validation

runs-on: ubuntu-latest

outputs:
tooling-python-version: ${{ steps.setup-python.outputs.python-version }}

steps:
- name: Handle the code
uses: actions/checkout@v3

- name: "Set up Python 3.10"
- name: "Set up Python"
uses: actions/setup-python@v4
id: setup-python
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 +118,16 @@ jobs:

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

package_and_release:
name: "Package & release"
needs: [validate, test]
uses: ./.github/workflows/release.yml
with:
# https://peps.python.org/pep-0440
TAG_BUILD: -dev0+g${{ github.sha }}.1
USE_TEST_PYPI: true
# cant use ${{ env.STUFF }} here...
PYTHON_VERSION: ${{ needs.validate.outputs.tooling-python-version }}
secrets:
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}

0 comments on commit 9cf8322

Please sign in to comment.