Skip to content

Commit 61bedea

Browse files
committed
Modularize GitHub workflows and streamline release process.
Reorganized and consolidated workflows for clarity and efficiency. Deprecated unnecessary workflows like `bumpversion.yaml` and `release.yaml`, introduced modular workflows (e.g., `build-python.yaml`, `release-pypi.yaml`), and ensured consistent dependency and Python setup across jobs. Enhanced documentation and test workflows for better alignment with project needs.
1 parent fc64f9b commit 61bedea

11 files changed

Lines changed: 240 additions & 194 deletions
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Build Python Package
2+
3+
on: workflow_call
4+
5+
jobs:
6+
build-package:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Package
10+
uses: hynek/build-and-inspect-python-package@v2

.github/workflows/bumpversion-pr.yaml renamed to .github/workflows/bump-version-preview.yaml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,44 @@ on:
55
branches: [master]
66

77
jobs:
8-
release-hint:
8+
preview-version:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
1212
name: Checkout the repository
1313
with:
1414
fetch-depth: 0
1515
ref: ${{ github.event.pull_request.head.sha }}
16-
token: ${{ secrets.PAT }}
1716

18-
- name: Setup Python and Git
19-
uses: ./.github/actions/setup-python-and-git
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
2019
with:
21-
python-version: '3.11'
20+
python-version: "3.12"
21+
22+
- name: Setup Git
23+
uses: .github/actions/setup-git
2224

2325
- name: Install requirements
2426
run: |
25-
python -m pip install . bump-my-version
27+
python -m pip install bump-my-version
2628
27-
- name: Generate release hint if merged
29+
- name: Get the release hint
2830
id: changelog
29-
# uses: callowayproject/generate-changelog@v0
3031
uses: ./
31-
with:
32-
branch_override: ${{ github.base_ref }}
33-
skip_output_pipeline: True
3432

35-
- name: Set release information
36-
if: ${{ steps.changelog.outputs.release_hint != 'no-release' }}
37-
shell: bash
33+
- name: Get Metadata
34+
id: get-metadata
3835
run: |
39-
PR_NUMBER=$(gh pr view --json number -q .number || echo "")
36+
PR_NUMBER=$(gh pr view --json number -q .number || echo "${{ github.event.number }}")
4037
REVISION=$(git describe --tags --long | awk -F- '{print $2}')
41-
RELEASE_KIND="${{ steps.changelog.outputs.release_hint }}"
42-
export PR_NUMBER REVISION RELEASE_KIND
38+
echo "RELEASE_KIND=${{ steps.changelog.outputs.release_hint }}" >> $GITHUB_ENV
39+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
40+
echo "REVISION=$REVISION" >> $GITHUB_ENV
4341
42+
- name: Bump version dry run
43+
if: ${{ env.RELEASE_KIND != 'no-release' }}
44+
shell: bash
45+
run: |
4446
# This will display a full log of what would happen if we were to bump the version.
4547
bump-my-version bump --dry-run --verbose "$RELEASE_KIND"
4648
@@ -50,7 +52,7 @@ jobs:
5052
echo "NEW_VERSION=$(echo $VERSION_INFO | jq -r .new_version)" >> $GITHUB_ENV
5153
5254
- name: Set no-release information
53-
if: ${{ steps.changelog.outputs.release_hint == 'no-release' }}
55+
if: ${{ env.RELEASE_KIND == 'no-release' }}
5456
run: |
5557
echo "CURRENT_VERSION=$(bump-my-version show current_version)" >> $GITHUB_ENV
5658
echo "NEW_VERSION=$(bump-my-version show current_version)" >> $GITHUB_ENV
@@ -59,6 +61,6 @@ jobs:
5961
uses: s-gehring/singleton-comment@v1
6062
with:
6163
comment-body: |
62-
**Version hint:** ${{ steps.changelog.outputs.release_hint }}
64+
**Version hint:** ${{ env.RELEASE_KIND }}
6365
**Current version:** ${{ env.CURRENT_VERSION }}
6466
**New version (when merged):** ${{ env.NEW_VERSION }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Bump the version on merge and build the artifacts
2+
on:
3+
pull_request:
4+
types: [closed]
5+
branches: [master]
6+
7+
jobs:
8+
bump-version:
9+
runs-on: ubuntu-latest
10+
if: github.event.pull_request.merged == true
11+
outputs:
12+
build_package: ${{ steps.bump-version.outputs.build_package }}
13+
steps:
14+
- uses: actions/checkout@v4
15+
name: Checkout the repository
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Setup Git
25+
uses: .github/actions/setup-git
26+
27+
- name: Install requirements
28+
run: |
29+
python -m pip install bump-my-version
30+
31+
- name: Generate changelog and release hint
32+
id: changelog
33+
uses: ./
34+
35+
- name: Bump version
36+
id: bump-version
37+
shell: bash
38+
run: |
39+
PR_NUMBER=$(gh pr view --json number -q .number || echo "")
40+
REVISION=$(git describe --tags --long | awk -F- '{print $2}')
41+
RELEASE_KIND=${{ steps.changelog.outputs.release_hint }}
42+
export PR_NUMBER REVISION RELEASE_KIND
43+
case "$RELEASE_KIND" in
44+
major|minor|patch)
45+
bump-my-version bump --allow-dirty --verbose "$RELEASE_KIND"
46+
git push
47+
git push --tags
48+
echo "build_package=false" >> $GITHUB_OUTPUTS
49+
;;
50+
dev)
51+
echo "Intentionally not bumping version for dev release"
52+
echo "build_package=false" >> $GITHUB_OUTPUTS
53+
# to build a dev release
54+
# bump-my-python bump --allow-dirty --verbose --no-commit --no-tag
55+
# echo "build_package=true" >> $GITHUB_OUTPUTS
56+
;;
57+
no-release)
58+
echo "build_package=false" >> $GITHUB_OUTPUTS
59+
;;
60+
*)
61+
echo "build_package=false" >> $GITHUB_OUTPUTS
62+
;;
63+
esac
64+
65+
call-build-python:
66+
needs: bump-version
67+
if: ${{ needs.bump-version.outputs.build_package == 'true' }}
68+
uses: .github/workflows/build-python.yaml

.github/workflows/bumpversion.yaml

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish Preview Documentation
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- closed
10+
11+
concurrency: preview-${{ github.ref }}
12+
13+
jobs:
14+
publish-docs:
15+
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
pages: write
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v5
30+
with:
31+
enable-cache: true
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: "3.12"
37+
38+
- name: Install dependencies
39+
run: uv sync --group docs
40+
41+
- name: Build and publish docs
42+
run: uv run mkdocs gh-deploy --strict
Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
1-
name: Publish Documentation
1+
name: Publish Final Documentation
22

33
on:
44
push:
5-
tags:
6-
- '*'
7-
workflow_dispatch: {}
8-
5+
branches: [$default-branch]
96

107
jobs:
118
publish-docs:
9+
1210
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
pages: write
15+
1316
steps:
14-
- name: Checkout and setup Python
15-
uses: ./.github/actions/checkout-and-setup-python
16-
with:
17-
python-version: '3.11'
18-
- name: Install dependencies
19-
run: |
20-
python -m pip install --upgrade pip
21-
pip install ".[docs]"
22-
- name: Build and publish docs
23-
run: make pubdocs
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
24+
with:
25+
enable-cache: true
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.12"
31+
32+
- name: Set up Git
33+
uses: .github/actions/setup-git
34+
35+
- name: Install dependencies
36+
run: uv sync --group docs
37+
38+
- name: Build and publish docs preview
39+
uses: rossjrw/pr-preview-action@v1
40+
with:
41+
source-dir: ./site/
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
name: Build container
2-
on: [workflow_call, workflow_dispatch]
1+
name: Build and release container
2+
on:
3+
push:
4+
tags: ["*"]
5+
workflow_call: {}
6+
workflow_dispatch: {}
37

48
jobs:
59
build-and-push-image:
@@ -24,9 +28,6 @@ jobs:
2428
registry: ${{ env.REGISTRY }}
2529
username: ${{ github.actor }}
2630
password: ${{ secrets.GITHUB_TOKEN }}
27-
- name: eventname
28-
run: |
29-
echo ${{ github.event_name }}
3031
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to
3132
# extract tags and labels that will be applied to the specified image.
3233
# The `id` "meta" allows the output of this step to be referenced in a subsequent step.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
on:
3+
push:
4+
tags: ["*"]
5+
6+
jobs:
7+
# Create a GitHub release
8+
release:
9+
name: Create a GitHub release
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
name: Checkout the repository
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Setup Git
18+
uses: ./.github/actions/setup-git
19+
20+
- name: release-notes
21+
uses: callowayproject/action-changelog-to-releasenotes@main
22+
with:
23+
target-version: ${GITHUB_REF#refs/tags/}
24+
25+
- name: Download packages built by build-and-inspect-python-package
26+
uses: actions/download-artifact@v4
27+
with:
28+
name: Packages
29+
path: dist
30+
31+
- name: Release
32+
uses: softprops/action-gh-release@v1
33+
with:
34+
files: dist/*
35+
tag_name: ${GITHUB_REF#refs/tags/}
36+
body_path: release-notes.md

0 commit comments

Comments
 (0)