Skip to content

Commit 8efe9b2

Browse files
committed
Complete Snyk fix with automated fallback version management
1 parent 4b24a65 commit 8efe9b2

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

.github/workflows/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@ jobs:
2525
- name: Get Release Version
2626
id: get_version
2727
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo ::set-output name=VERSION::$VERSION
28+
- name: Update Fallback Version in Main Branch
29+
run: |
30+
# Create a temporary branch from main to update the fallback version
31+
git fetch origin main
32+
git checkout main
33+
git pull origin main
34+
35+
echo "Updating fallback version to ${{ steps.get_version.outputs.VERSION }}"
36+
echo "# Fallback version for CI environments where Git history is not available" > gradle.properties
37+
echo "# This is automatically updated during the release process" >> gradle.properties
38+
echo "fallback.version=${{ steps.get_version.outputs.VERSION }}" >> gradle.properties
39+
40+
# Check if there are changes to commit
41+
if ! git diff --quiet gradle.properties; then
42+
git config --local user.email "[email protected]"
43+
git config --local user.name "GitHub Action"
44+
git add gradle.properties
45+
git commit -m "Update fallback version to ${{ steps.get_version.outputs.VERSION }} [skip ci]"
46+
git push origin main
47+
echo "Updated fallback version in main branch"
48+
else
49+
echo "No changes needed to gradle.properties"
50+
fi
51+
52+
# Switch back to the tag for the rest of the release process
53+
git checkout ${{ github.ref_name }}
2854
- name: Create Release
2955
id: create_release
3056
run: |

build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ scmVersion {
3636
}
3737
}
3838

39-
project.version = scmVersion.version
39+
// Use a fixed version in CI environments where Git history may be incomplete
40+
if (System.getenv("CI") || System.getenv("GITHUB_ACTIONS")) {
41+
project.version = project.property('fallback.version')
42+
println "CI environment detected, using fallback version: ${project.version}"
43+
} else {
44+
project.version = scmVersion.version
45+
}
4046

4147
/**
4248
* Set this to a comma-separated list of full classnames of your implemented Rundeck

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Fallback version for CI environments where Git history is not available
2+
# This should be updated automatically during the release process
3+
fallback.version=1.1.5

0 commit comments

Comments
 (0)