-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip ci] Add initial prepare-release GitHub action for testing
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Prepare release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
name: | ||
type: choice | ||
description: Version to bump | ||
options: | ||
- minor | ||
- major | ||
jobs: | ||
prepare-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Run bump version script | ||
run: sh ./scripts/bump-version.sh ${{ github.event.inputs.name }} | ||
- name: Echo new version | ||
run: echo $NEW_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Check if a parameter is provided | ||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <major|minor|patch>" | ||
exit 1 | ||
fi | ||
|
||
# File path | ||
file="compose-remember-setting/build.gradle.kts" | ||
|
||
# Read the file and find the version line | ||
while IFS= read -r line; do | ||
if [[ $line =~ [0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT ]]; then | ||
version_line=$line | ||
break | ||
fi | ||
done < "$file" | ||
|
||
# Extract the current version | ||
current_version=$(echo "$version_line" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT') | ||
IFS='.' read -r major minor patch <<< "$(echo "$current_version" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" | ||
|
||
# Determine the new version based on the input parameter | ||
if [ "$1" == "major" ]; then | ||
new_major=$((major + 1)) | ||
new_version="${new_major}.0.0-SNAPSHOT" | ||
elif [ "$1" == "minor" ]; then | ||
new_minor=$((minor + 1)) | ||
new_version="${major}.${new_minor}.0-SNAPSHOT" | ||
elif [ "$1" == "patch" ]; then | ||
new_patch=$((patch + 1)) | ||
new_version="${major}.${minor}.${new_patch}-SNAPSHOT" | ||
else | ||
echo "Invalid parameter. Use 'major', 'minor', or 'patch'." | ||
exit 1 | ||
fi | ||
|
||
# Replace the version in the file | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
# macOS | ||
sed -i '' "s/$current_version/$new_version/" "$file" | ||
else | ||
# Linux and other UNIX systems | ||
sed -i "s/$current_version/$new_version/" "$file" | ||
fi | ||
|
||
# Set the new version as a GitHub Actions output | ||
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV | ||
|
||
echo "Version bumped from $current_version to $new_version" |