Skip to content

Commit fb5d158

Browse files
committed
New apporach
1 parent f8b23b3 commit fb5d158

2 files changed

Lines changed: 126 additions & 110 deletions

File tree

.github/workflows/update-version.yml

Lines changed: 0 additions & 110 deletions
This file was deleted.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Version Bump - Prelim
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v.*'
7+
- 'v[0-9]+.[0-9]+.[0-9]+.[0-9]+-[0-9]+'
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
bump-version-prelim:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
ref: v2.4.8-windows-support
22+
fetch-depth: 0
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Check current version and process
26+
id: process_version
27+
run: |
28+
# Get the tag that triggered this workflow
29+
TAG_NAME="${GITHUB_REF#refs/tags/}"
30+
echo "Tag created: $TAG_NAME"
31+
32+
# Extract current version from configure.ac line 39
33+
CURRENT_VERSION=$(sed -n '39p' configure.ac | sed -E 's/.*\[LTFS\], \[([^]]+)\].*/\1/')
34+
echo "Current version in configure.ac: $CURRENT_VERSION"
35+
36+
# Check if current version already contains "(Prelim)"
37+
if [[ "$CURRENT_VERSION" == *"(Prelim)"* ]]; then
38+
echo "Current version already has (Prelim) - no action needed"
39+
echo "needs_update=false" >> $GITHUB_OUTPUT
40+
exit 0
41+
fi
42+
43+
# If we reach here, we need to update
44+
echo "needs_update=true" >> $GITHUB_OUTPUT
45+
46+
# Extract version numbers from tag (e.g., v.2.4.8.2-10520 -> 2.4.8.2)
47+
VERSION_NUM=$(echo "$TAG_NAME" | sed -E 's/^v\.?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/')
48+
echo "Extracted version from tag: $VERSION_NUM"
49+
50+
# Split version into parts
51+
IFS='.' read -r -a VERSION_PARTS <<< "$VERSION_NUM"
52+
MAJOR="${VERSION_PARTS[0]}"
53+
MINOR="${VERSION_PARTS[1]}"
54+
PATCH="${VERSION_PARTS[2]}"
55+
BUILD="${VERSION_PARTS[3]}"
56+
57+
# Increment the last number (build)
58+
NEW_BUILD=$((BUILD + 1))
59+
NEW_VERSION="$MAJOR.$MINOR.$PATCH.$NEW_BUILD"
60+
61+
echo "New version: $NEW_VERSION"
62+
63+
# Create version with Prelim label
64+
FINAL_VERSION="$NEW_VERSION (Prelim)"
65+
echo "Final version string: $FINAL_VERSION"
66+
67+
# Store in output
68+
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
69+
echo "version=$FINAL_VERSION" >> $GITHUB_OUTPUT
70+
echo "version_num=$NEW_VERSION" >> $GITHUB_OUTPUT
71+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
72+
73+
- name: Update configure.ac
74+
if: steps.process_version.outputs.needs_update == 'true'
75+
id: update_file
76+
run: |
77+
VERSION="${{ steps.process_version.outputs.version }}"
78+
79+
# Update line 39 with the new version
80+
sed -i "39s/\[LTFS\], \[[^]]*\]/[LTFS], [$VERSION]/" configure.ac
81+
82+
echo "File updated successfully"
83+
echo "Updated line 39:"
84+
sed -n '39p' configure.ac
85+
86+
- name: Create Pull Request
87+
if: steps.process_version.outputs.needs_update == 'true'
88+
uses: peter-evans/create-pull-request@v5
89+
with:
90+
token: ${{ secrets.GITHUB_TOKEN }}
91+
commit-message: "chore: bump version to ${{ steps.process_version.outputs.version }}"
92+
branch: version-bump-prelim-${{ steps.process_version.outputs.version_num }}
93+
base: v2.4.8-windows-support
94+
title: "Version Bump: ${{ steps.process_version.outputs.version }}"
95+
body: |
96+
## Version Bump - Prelim
97+
98+
This PR was automatically created after tag creation to update the version for the next development cycle.
99+
100+
- **Created Tag**: ${{ steps.process_version.outputs.tag }}
101+
- **Previous Version**: ${{ steps.process_version.outputs.current_version }}
102+
- **New Version**: ${{ steps.process_version.outputs.version }}
103+
104+
### Changes
105+
- Updated configure.ac line 39 with new version
106+
- Version label: Prelim (preliminary/development)
107+
108+
This PR prepares the repository for the next development iteration.
109+
labels: prelim, version-bump, automated
110+
111+
- name: Summary
112+
run: |
113+
echo "## Version Bump Summary - Prelim" >> $GITHUB_STEP_SUMMARY
114+
echo "" >> $GITHUB_STEP_SUMMARY
115+
echo "- **Triggered by Tag**: ${{ steps.process_version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
116+
echo "- **Current Version**: ${{ steps.process_version.outputs.current_version }}" >> $GITHUB_STEP_SUMMARY
117+
118+
if [ "${{ steps.process_version.outputs.needs_update }}" == "true" ]; then
119+
echo "- **New Version**: ${{ steps.process_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
120+
echo "- **Target Branch**: v2.4.8-windows-support" >> $GITHUB_STEP_SUMMARY
121+
echo "" >> $GITHUB_STEP_SUMMARY
122+
echo "**Pull Request Created** - Automatically created for next development cycle." >> $GITHUB_STEP_SUMMARY
123+
else
124+
echo "" >> $GITHUB_STEP_SUMMARY
125+
echo "**No Action Taken** - Version already has (Prelim) label." >> $GITHUB_STEP_SUMMARY
126+
fi

0 commit comments

Comments
 (0)