Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmelati committed Jan 15, 2025
1 parent 5b0efeb commit 4d6f83f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 153 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/auto-tag.yml
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}
150 changes: 0 additions & 150 deletions .github/workflows/auto-version.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
KMS_PROVIDER: local

- name: Trigger Auto Version
- name: Trigger Auto Tag
if: success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/fix/') || startsWith(github.ref, 'refs/heads/release/'))
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: trigger-version
event-type: trigger-tag
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun getNpmVersion(): String {

allprojects {
group = "com.sphereon.oid.fed"
version = "0.2.0-SNAPSHOT"
version = "1.0.0-SNAPSHOT"
val npmVersion by extra { getNpmVersion() }
repositories {
mavenCentral()
Expand Down

0 comments on commit 4d6f83f

Please sign in to comment.