Skip to content

Commit 53d4844

Browse files
Add version input parameter to release workflow with auto-deduction fallback (#218)
* Initial plan * Update release-autowrap.yaml to allow entering version number Co-authored-by: timosachsenberg <5803621+timosachsenberg@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: timosachsenberg <5803621+timosachsenberg@users.noreply.github.com>
1 parent c534140 commit 53d4844

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

.github/workflows/release-autowrap.yaml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
name: release autowrap
22

3-
###########################################################################
4-
# please make sure that autowrap version numbers have been properly updated
5-
###########################################################################
6-
73
on:
84
workflow_dispatch: # manual trigger
95
inputs:
6+
version:
7+
description: 'Version to release (empty = use version from autowrap/version.py)'
8+
default: ''
109
next_version:
11-
description: 'Next version (empty = minor bump)'
10+
description: 'Next development version (empty = minor bump from release version)'
1211
default: ''
1312

1413
jobs:
@@ -22,6 +21,29 @@ jobs:
2221
with:
2322
python-version: "3.11"
2423

24+
- name: Determine release version
25+
id: version
26+
run: |
27+
INPUT_VER="${{ github.event.inputs.version }}"
28+
if [ -z "$INPUT_VER" ]; then
29+
# Deduce version from autowrap/version.py
30+
RELEASE_VER=$(python3 -c 'from autowrap.version import __version__; print(__version__)')
31+
echo "Using version from autowrap/version.py: $RELEASE_VER"
32+
else
33+
# Validate version format (only allow digits and dots)
34+
if ! echo "$INPUT_VER" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
35+
echo "Error: Invalid version format. Expected format: X.Y.Z (e.g., 1.2.3)"
36+
exit 1
37+
fi
38+
RELEASE_VER="$INPUT_VER"
39+
echo "Using input version: $RELEASE_VER"
40+
# Update version.py with the specified version
41+
sed -i -e "s/^__version__ = \".*\"/__version__ = \"$RELEASE_VER\"/g" autowrap/version.py
42+
TUPLE_VER=$(echo $RELEASE_VER | sed 's/\./, /g')
43+
sed -i -e "s/^__version_tuple__ = (.*)/__version_tuple__ = ($TUPLE_VER)/g" autowrap/version.py
44+
fi
45+
echo "version=$RELEASE_VER" >> $GITHUB_OUTPUT
46+
2547
- name: Install build dependencies
2648
run: |
2749
python -m pip install -U pip build
@@ -36,10 +58,6 @@ jobs:
3658
user: __token__
3759
password: ${{ secrets.PYPI_RELEASE_AUTOWRAP }}
3860
packages_dir: ${{ github.workspace }}/dist
39-
40-
- name: Parse version
41-
run: echo "version=$(python3 -c 'from autowrap.version import __version__; print(__version__)')" >> $GITHUB_OUTPUT
42-
id: version
4361

4462
- name: Create github release
4563
uses: softprops/action-gh-release@v2
@@ -56,9 +74,17 @@ jobs:
5674
- name: Setup things for new cycle
5775
id: setup_new
5876
run: |
59-
NEXT_VER=${{ github.event.inputs.next_version }}
60-
OLD_VER=${{ steps.version.outputs.version }}
61-
[ -z "$NEXT_VER" ] && NEXT_VER=$(echo $OLD_VER | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') || true
77+
NEXT_VER="${{ github.event.inputs.next_version }}"
78+
RELEASE_VER="${{ steps.version.outputs.version }}"
79+
if [ -z "$NEXT_VER" ]; then
80+
NEXT_VER=$(echo $RELEASE_VER | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
81+
else
82+
# Validate version format (only allow digits and dots)
83+
if ! echo "$NEXT_VER" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
84+
echo "Error: Invalid next version format. Expected format: X.Y.Z (e.g., 1.2.3)"
85+
exit 1
86+
fi
87+
fi
6288
echo >> HISTORY.md
6389
cat CHANGELOG.md >> HISTORY.md
6490
echo >> HISTORY.md

0 commit comments

Comments
 (0)