-
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.
- Loading branch information
Showing
1 changed file
with
23 additions
and
10 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 |
---|---|---|
|
@@ -25,16 +25,21 @@ jobs: | |
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get version info | ||
id: get_version_info | ||
run: | | ||
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
git config --local user.name "${GITHUB_ACTOR}" | ||
# Handle both PR and push events for branch name | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
EVENT_NAME="${{ github.event_name }}" | ||
if [[ "$EVENT_NAME" == "pull_request" ]]; then | ||
BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | ||
else | ||
BRANCH_NAME=${GITHUB_REF#refs/heads/} | ||
BRANCH_NAME="${GITHUB_REF#refs/heads/}" | ||
fi | ||
# Determine branch type prefix first | ||
|
@@ -51,9 +56,19 @@ jobs: | |
else | ||
PREFIX="build" | ||
fi | ||
# Get latest version tag globally, ignoring branch prefixes | ||
LATEST_TAG=$(git tag --sort=-v:refname | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" | head -n1 || echo "v0.0.0") | ||
echo "Available tags:" | ||
if ! git tag --list | grep -q "^v"; then | ||
echo "No version tags found, creating initial tag v0.0.1" | ||
git tag -a "v0.0.1" -m "Initial version" | ||
git push origin v0.0.1 | ||
LATEST_TAG="v0.0.1" | ||
else | ||
git tag --sort=-v:refname | ||
echo "Filtered tags:" | ||
git tag --sort=-v:refname | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" || echo "No matching tags" | ||
LATEST_TAG=$(git tag --sort=-v:refname | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" | head -n1 || echo "v0.0.1") | ||
fi | ||
COMMIT_SHA=$(git rev-parse --short HEAD) | ||
PR_NUMBER=${{ github.event.pull_request.number }} | ||
COMMIT_MSG=$(git log -1 --pretty=%B) | ||
|
@@ -86,6 +101,8 @@ jobs: | |
VERSION=${LATEST_TAG#v} | ||
IFS='.' read -ra VERSION_PARTS <<< "$VERSION" | ||
echo "current_version=${VERSION}" >> $GITHUB_OUTPUT | ||
# Version increment logic | ||
case $BUMP_TYPE in | ||
"major") | ||
|
@@ -119,12 +136,8 @@ jobs: | |
fi | ||
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT | ||
# Configure git | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
# Update version in build.gradle.kts | ||
# Update version in build.gradle.kts | ||
VERSION_WITHOUT_V=${NEW_VERSION#v} | ||
BASE_VERSION=$(echo $VERSION_WITHOUT_V | cut -d'-' -f1) | ||
sed -i "s/version = \".*\"/version = \"$BASE_VERSION\"/" build.gradle.kts | ||
|