-
Notifications
You must be signed in to change notification settings - Fork 1
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
4 changed files
with
74 additions
and
153 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,71 @@ | ||
name: Auto Tag | ||
|
||
on: | ||
repository_dispatch: | ||
types: [ trigger-tag ] | ||
pull_request: | ||
types: [ closed ] | ||
|
||
jobs: | ||
auto-tag: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
if: github.event_name == 'repository_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout repository | ||
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 | ||
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/}" | ||
fi | ||
# Determine branch type prefix | ||
if [[ $BRANCH_NAME == "develop" ]]; then | ||
PREFIX="dev" | ||
elif [[ $BRANCH_NAME == "main" ]]; then | ||
PREFIX="main" | ||
elif [[ $BRANCH_NAME == feature/* ]]; then | ||
PREFIX="feat" | ||
elif [[ $BRANCH_NAME == hotfix/* ]]; then | ||
PREFIX="fix" | ||
elif [[ $BRANCH_NAME == release/* ]]; then | ||
PREFIX="rel" | ||
else | ||
PREFIX="build" | ||
fi | ||
# Get version from build.gradle.kts | ||
GRADLE_VERSION=$(grep 'version = ' build.gradle.kts | sed 's/.*version = "\(.*\)".*/\1/') | ||
GRADLE_VERSION=${GRADLE_VERSION%-SNAPSHOT} # Remove -SNAPSHOT suffix if present | ||
COMMIT_SHA=$(git rev-parse --short HEAD) | ||
PR_NUMBER=${{ github.event.pull_request.number }} | ||
# Create tag version | ||
if [[ -n $PR_NUMBER ]]; then | ||
NEW_VERSION="v${GRADLE_VERSION}-${PREFIX}.pr${PR_NUMBER}.${COMMIT_SHA}" | ||
else | ||
NEW_VERSION="v${GRADLE_VERSION}-${PREFIX}.${COMMIT_SHA}" | ||
fi | ||
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT | ||
# Create tag for version tracking | ||
git tag -a ${NEW_VERSION} -m "Release ${NEW_VERSION}" | ||
git push origin ${NEW_VERSION} |
This file was deleted.
Oops, something went wrong.
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
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