Skip to content

Commit dbbaee4

Browse files
authored
Merge pull request containers#627 from inknos/automate-releases
Add release PR workflow
2 parents 4ae67dd + c0159aa commit dbbaee4

7 files changed

Lines changed: 152 additions & 8 deletions

File tree

.github/scripts/update-version.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
VERSION="${1:-}"
6+
7+
if [[ -z "$VERSION" ]]; then
8+
echo "Error: Version argument is required"
9+
echo "Usage: $0 <version>"
10+
echo "Example: $0 5.8.0"
11+
exit 1
12+
fi
13+
14+
# Update:
15+
# - podman/version.py (single source of truth for package version)
16+
# - podman/tests/__init__.py (URL contains /vX.Y.Z/libpod)
17+
# - plans/main.fmf (ref: "vX.Y.Z")
18+
#
19+
# pyproject.toml, setup.cfg, and Makefile derive the version dynamically
20+
# from podman/version.py and do not need manual updates.
21+
22+
sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/" podman/version.py
23+
echo " - Updated podman/version.py"
24+
25+
sed -i "s|/v[0-9.]*[0-9]/libpod|/v$VERSION/libpod|" podman/tests/__init__.py
26+
echo " - Updated podman/tests/__init__.py"
27+
28+
sed -i "s/ref: \"v[0-9.]*[0-9]\"/ref: \"v$VERSION\"/" plans/main.fmf
29+
echo " - Updated plans/main.fmf"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Create GitHub Release
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
8+
jobs:
9+
create-release:
10+
# Only run if PR was merged and title starts with "Bump release to"
11+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Bump release to')
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v5
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Extract version from PR title
23+
id: version
24+
run: |
25+
PR_TITLE="${{ github.event.pull_request.title }}"
26+
# Extract version number from "Bump release to X.Y.Z"
27+
VERSION_NUMBER=$(echo "$PR_TITLE" | sed 's/Bump release to //')
28+
VERSION_TAG="v$VERSION_NUMBER"
29+
30+
echo "version_number=$VERSION_NUMBER" >> $GITHUB_OUTPUT
31+
echo "version_tag=$VERSION_TAG" >> $GITHUB_OUTPUT
32+
echo "Extracted version: $VERSION_TAG"
33+
34+
- name: Configure git
35+
run: |
36+
git config user.name "github-actions[bot]"
37+
git config user.email "github-actions[bot]@users.noreply.github.com"
38+
39+
- name: Create and push tag
40+
run: |
41+
VERSION_TAG="${{ steps.version.outputs.version_tag }}"
42+
git tag "$VERSION_TAG"
43+
git push origin "$VERSION_TAG"
44+
echo "Created and pushed tag: $VERSION_TAG"
45+
46+
- name: Create GitHub Release
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: |
50+
VERSION_TAG="${{ steps.version.outputs.version_tag }}"
51+
52+
gh release create "$VERSION_TAG" \
53+
--title "$VERSION_TAG" \
54+
--generate-notes \
55+
--draft
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Create Release PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version (e.g., v5.8.0)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
create-release-pr:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
18+
steps:
19+
- name: Validate and extract version
20+
id: version
21+
run: |
22+
VERSION="${{ github.event.inputs.version }}"
23+
if [[ ! "$VERSION" =~ ^v[0-9]+(\.[0-9]+){2,}$ ]]; then
24+
echo "Error: Version must start with 'v' followed by numbers and dots (e.g., v5.8.0)"
25+
echo "Provided version: $VERSION"
26+
exit 1
27+
fi
28+
echo "Version format is valid: $VERSION"
29+
# Remove 'v' prefix for file updates
30+
VERSION_NUMBER="${VERSION#v}"
31+
echo "version_number=$VERSION_NUMBER" >> $GITHUB_OUTPUT
32+
echo "version_tag=$VERSION" >> $GITHUB_OUTPUT
33+
34+
- name: Checkout repository
35+
uses: actions/checkout@v5
36+
37+
- name: Update version files
38+
run: |
39+
chmod +x .github/scripts/update-version.sh
40+
./.github/scripts/update-version.sh "${{ steps.version.outputs.version_number }}"
41+
42+
- name: Create Pull Request
43+
uses: peter-evans/create-pull-request@v8
44+
with:
45+
branch: release/${{ steps.version.outputs.version_tag }}
46+
delete-branch: true
47+
title: "Bump release to ${{ steps.version.outputs.version_number }}"
48+
commit-message: |
49+
Bump release to ${{ steps.version.outputs.version_number }}
50+
51+
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
52+
body: |
53+
## Release ${{ steps.version.outputs.version_tag }}
54+
55+
This PR bumps the version to ${{ steps.version.outputs.version_number }} in:
56+
- `podman/version.py`
57+
- `podman/tests/__init__.py`
58+
- `plans/main.fmf`
59+
60+
Other files (`pyproject.toml`, `setup.cfg`, `Makefile`) derive the version dynamically from `podman/version.py`.
61+
62+
Once merged, a GitHub release will be automatically created with tag `${{ steps.version.outputs.version_tag }}`, which will trigger the [PyPI publish workflow](.github/workflows/publish-to-pypi.yml).

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DESTDIR ?=
88
EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-main} HEAD)
99
HEAD ?= HEAD
1010

11-
export PODMAN_VERSION ?= "5.7.0"
11+
export PODMAN_VERSION ?= $(shell $(PYTHON) -c "exec(open('podman/version.py').read()); print(__version__)")
1212

1313
.PHONY: podman
1414
podman:

plans/main.fmf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ summary: Run Python Podman Tests
22

33
discover:
44
how: fmf
5+
url: https://github.com/containers/podman-py
6+
ref: "v5.7.0"
57
execute:
68
how: tmt
79
prepare:

pyproject.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "podman"
7-
# TODO: remove the line version = ... on podman-py > 5.4.0 releases
8-
# dynamic = ["version"]
9-
version = "5.7.0"
7+
dynamic = ["version"]
108
description = "Bindings for Podman RESTful API"
119
readme = "README.md"
1210
license = {file = "LICENSE"}
@@ -75,9 +73,8 @@ testpaths = [
7573
where = ["."]
7674
include = ["podman*"]
7775

78-
# TODO: remove the line version = ... on podman-py > 5.4.0 releases
79-
# [tool.setuptools.dynamic]
80-
# version = {attr = "podman.version.__version__"}
76+
[tool.setuptools.dynamic]
77+
version = {attr = "podman.version.__version__"}
8178

8279
[tool.ruff]
8380
line-length = 100

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[metadata]
22
name = podman
3-
version = 5.7.0
43
author = Brent Baude, Jhon Honce, Urvashi Mohnani, Nicola Sella
54
author_email = jhonce@redhat.com
65
description = Bindings for Podman RESTful API

0 commit comments

Comments
 (0)