Skip to content

Commit

Permalink
👷 ci: better release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
digsim committed Oct 8, 2024
1 parent 1832f6a commit b9b2f06
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 46 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/master-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
jobs:
build:
name: test with ${{ matrix.py }} on linux
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
Expand All @@ -41,7 +41,12 @@ jobs:
- name: Install tox and pex dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pex tox tox-gh
python -m pip install pex tox tox-gh setuptools_scm
- name: Save package version for later
run: |
echo "local_version=$(python -m setuptools_scm)" >> $GITHUB_OUTPUT
id: versioncheck

- name: Build Software
run: |
Expand Down Expand Up @@ -86,7 +91,7 @@ jobs:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

environment:
name: testpypi
Expand All @@ -99,7 +104,7 @@ jobs:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: python-package-distributions-*
pattern: python-package-distributions-3.12
path: dist/
merge-multiple: true
- name: Show downloaded packages
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/pr-build-workflow-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ on:
jobs:
build:
name: test with ${{ matrix.py }} on linux
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
py:
- "3.13.0-rc.3"
- "3.12"
- "3.11"
- "3.10"
Expand All @@ -35,7 +36,12 @@ jobs:
- name: Install tox and pex dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pex tox tox-gh
python -m pip install pex tox tox-gh setuptools_scm
- name: Save package version for later
run: |
echo "local_version=$(python -m setuptools_scm)" >> $GITHUB_OUTPUT
id: versioncheck

- name: Build Software
run: |
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/pr-build-workflow-mac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ jobs:
run: |
python -m pip install --upgrade pip
export PKG_CONFIG_PATH=/usr/local/opt/mysql-client/lib/pkgconfig
python -m pip install pex tox tox-gh
python -m pip install pex tox tox-gh setuptools_scm
- name: Save package version for later
run: |
echo "local_version=$(python -m setuptools_scm)" >> $GITHUB_OUTPUT
id: versioncheck

- name: Build Software
run: |
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/pr-build-workflow-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ jobs:
- name: Install tox and pex dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pex tox tox-gh
python -m pip install pex tox tox-gh setuptools_scm
- name: Save package version for later
run: |
echo "local_version=$(python -m setuptools_scm)" >> $GITHUB_OUTPUT
id: versioncheck

- name: Build Software
run: |
Expand Down
90 changes: 52 additions & 38 deletions .github/workflows/release-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@ permissions:
pull-requests: write

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
inputs:
branch:
description: 'Branch to release'
default: 'master'
tag:
description: tag to create (X.Y.Z)
default: '1.3.0'

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
env:
CI_COMMIT_MESSAGE: Continuous Integration Build Artifacts
CI_COMMIT_AUTHOR: Continuous Integration
outputs:
local_version: ${{ steps.versioncheck.outputs.local_version }}
steps:
- uses: actions/checkout@v4

Expand All @@ -32,23 +40,29 @@ jobs:
with:
python-version: "3.12"

- name: Install tox and pex dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build zest.releaser pex tox tox-gh
python -m pip install build pex tox tox-gh setuptools_scm
- name: Prerelease
- name: Verify package is runnable
run: |
pip install -e .
python scripts/test.py -h
# Commit and push all changed files.
- name: GIT create tag
if: github.event_name == 'workflow_dispatch'
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "username@users.noreply.github.com"
prerelease --no-input
git tag ${{ inputs.tag }}
git push --follow-tags
- name: Check pypi versions
uses: maybe-hello-world/pyproject-check-version@v4
- name: Save package version for later
run: |
echo "local_version=$(python -m setuptools_scm --strip-dev)" >> $GITHUB_OUTPUT
id: versioncheck
with:
pyproject-path: "./pyproject.toml"
test-regex: "[0-9]+.[0-9]+.[0-9]+dev[0-9]+"

- name: Build a binary wheel and a source tarball
run: python3 -m build
Expand All @@ -59,24 +73,16 @@ jobs:
name: python-package-distributions
path: dist/

- name: Build pex package
run: tox -e package
env:
PACKAGE_VERSION: ${{ steps.versioncheck.outputs.local_version }}

# Commit and push all changed files.
- name: GIT create tag
- name: Build documentation
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "username@users.noreply.github.com"
git tag ${{ steps.versioncheck.outputs.local_version }}
git push --follow-tags
tox -e docs
- name: Postrelease
- name: Build distributable packages
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "username@users.noreply.github.com"
postrelease --no-input
tox -e package
env:
PACKAGE_VERSION: ${{ steps.versioncheck.outputs.local_version }}

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
Expand All @@ -90,7 +96,8 @@ jobs:
#if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

environment:
name: pypi
url: https://pypi.org/p/seriesManagementSystem
Expand All @@ -103,9 +110,10 @@ jobs:
with:
name: python-package-distributions
path: dist/
merge-multiple: true

- name: Show downloaded packages
run: ls -R dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@v1.10.3
with:
Expand All @@ -119,20 +127,24 @@ jobs:
and upload them to GitHub Release
needs:
- build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- uses: actions/checkout@v4

- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions-incl-pex
path: dist/

- name: Show downloaded packages
run: ls -R dist/

- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
Expand All @@ -141,16 +153,18 @@ jobs:
./dist/*.whl
./dist/*.pex
- name: Save Tag version
id: version
run: |
echo "TAG_NAME=$(ls dist/ |grep whl |awk -F "-" '{print $2}' | head -n 1 |tr -d -)" >> "$GITHUB_ENV"
# If we want to use setuptools_scm here we would alos need to install the whole
# Python stack for this step. Hence falling back to some bash magic for getting
# the version.
# - name: Save Tag version
# id: version
# run: |
# echo "TAG_NAME=$(ls dist/ |grep whl |awk -F "-" '{print $2}' | head -n 1 |tr -d -)" >> "$GITHUB_ENV"

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create $TAG_NAME --repo '${{ github.repository }}' -F CHANGES.rst
# - name: Save Tag version
# run: |
# echo "TAG_NAME=$(python -m setuptools_scm --strip-dev)" >> "$GITHUB_ENV"
# id: versioncheck

- name: Upload artifact signatures to GitHub Release
env:
Expand All @@ -159,4 +173,4 @@ jobs:
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload $TAG_NAME dist/** --repo '${{ github.repository }}'
gh release create ${{ needs.build.outputs.local_version }} --generate-notes dist/** --repo '${{ github.repository }}'
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ package-data = {'seriesManagementSystem.etc'= ['logging.yaml', 'seriesmgmtsystem
where = ["src"]

[tool.setuptools_scm]
local_scheme = "no-local-version"

[tool.pytest.ini_options]
addopts = [
Expand Down

0 comments on commit b9b2f06

Please sign in to comment.