1
+ name : Nightly Pre-Release
2
+
3
+ on :
4
+ schedule :
5
+ - cron : ' 0 0 * * *'
6
+ workflow_dispatch :
7
+
8
+ jobs :
9
+ prerelease :
10
+ runs-on : ubuntu-latest
11
+
12
+ steps :
13
+ - name : 📦 Checkout Code
14
+ uses : actions/checkout@v4
15
+
16
+ - name : Get latest nightly pre-release commit SHA
17
+ id : get_latest_nightly_commit
18
+ run : |
19
+ latest_nightly_commit=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases | jq -r '[.[] | select(.prerelease == true)] | first | .target_commitish')
20
+ echo "latest_nightly_commit=${latest_nightly_commit}" >> $GITHUB_ENV
21
+
22
+ - name : Check for changes with previous nightly pre-release
23
+ id : check_changes
24
+ run : |
25
+ git fetch --tags
26
+ if git diff --quiet ${{ env.latest_nightly_commit }}..HEAD; then
27
+ echo "No changes detected"
28
+ echo "changes=false" >> $GITHUB_ENV
29
+ else
30
+ echo "Changes detected"
31
+ echo "changes=true" >> $GITHUB_ENV
32
+ fi
33
+
34
+ - name : 🚀 Set up JDK 17
35
+ if : env.changes == 'true'
36
+ uses : actions/setup-java@v4
37
+ with :
38
+ java-version : ' 17'
39
+ distribution : ' temurin'
40
+ cache : maven
41
+
42
+ - name : Get current version from pom.xml
43
+ if : env.changes == 'true'
44
+ id : get_version
45
+ run : |
46
+ current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
47
+ echo "current_version=${current_version}" >> $GITHUB_ENV
48
+
49
+ - name : Set nightly version variable
50
+ if : env.changes == 'true'
51
+ run : |
52
+ nightly_version=${{ env.current_version }}+nightly.$(date +'%Y%m%d').$(git rev-parse --short HEAD)
53
+ echo "nightly_version=${nightly_version}" >> $GITHUB_ENV
54
+
55
+ - name : Set nightly version
56
+ if : env.changes == 'true'
57
+ run : |
58
+ mvn versions:set -DnewVersion=${{ env.nightly_version }} -DgenerateBackupPoms=false
59
+
60
+ - name : 🛠 Build with Maven
61
+ if : env.changes == 'true'
62
+ run : mvn -B package --file pom.xml
63
+
64
+ - name : Get latest release tag
65
+ if : env.changes == 'true'
66
+ id : get_latest_release
67
+ run : |
68
+ latest_release=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
69
+ echo "latest_release=${latest_release}" >> $GITHUB_ENV
70
+
71
+ - name : Generate changelog since last release
72
+ if : env.changes == 'true'
73
+ id : changelog
74
+ uses : requarks/changelog-action@v1
75
+ with :
76
+ token : ${{ github.token }}
77
+ fromTag : ${{ github.ref_name }}
78
+ toTag : ${{ steps.get_latest_release.outputs.latest_release }}
79
+ includeInvalidCommits : true
80
+
81
+ - name : 🚀 Create pre-release
82
+ if : env.changes == 'true'
83
+ uses : softprops/action-gh-release@v2
84
+ with :
85
+ files : |
86
+ target/*.jar
87
+ target/*.deb
88
+ tag_name : nightly-$(date +'%Y%m%d')
89
+ name : Nightly Pre-Release ${{ env.nightly_version }}
90
+ prerelease : true
91
+ body : ${{ steps.changelog.outputs.changes }}
0 commit comments