Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add packaging without publish to CI #692

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}