@@ -16,51 +16,69 @@ jobs:
1616 timeout-minutes : 240
1717 if : github.repository_owner == 'ballerina-platform'
1818 steps :
19- - name : Checkout Repository
20- uses : actions/checkout@v4
21- with :
22- ref : ${{ matrix.branch }}
19+ - name : Checkout Repository
20+ uses : actions/checkout@v4
21+ with :
22+ ref : ${{ matrix.branch }}
23+ fetch-depth : 0
2324
24- - name : Set up JDK 21
25- uses : actions/setup-java@v4
26- with :
27- distribution : ' temurin'
28- java-version : ' 21.0.3'
25+ - name : Set up JDK 21
26+ uses : actions/setup-java@v4
27+ with :
28+ distribution : ' temurin'
29+ java-version : ' 21.0.3'
2930
30- - name : Initialize Sub Modules
31- run : git submodule update --init
31+ - id : check_recent_commits
32+ name : Check for commits in last 24 hours
33+ run : |
34+ # Count commits in the current checked-out branch within the last 24 hours
35+ count=$(git rev-list --count --since="24 hours ago" HEAD || echo 0)
36+ if [ "$count" -eq 0 ]; then
37+ echo "No commits in the last 24 hours. Skipping the rest of the job."
38+ echo "recent_commits=false" >> $GITHUB_OUTPUT
39+ else
40+ echo "Found $count commit(s) in the last 24 hours."
41+ echo "recent_commits=true" >> $GITHUB_OUTPUT
42+ fi
3243
33- - name : Change to Timestamped Version
34- run : |
35- startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00')
36- latestCommit=$(git log -n 1 --pretty=format:"%h")
37- VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)
38- updatedVersion=$VERSION-$startTime-$latestCommit
39- echo $updatedVersion
40- echo TIMESTAMPED_VERSION=$updatedVersion >> $GITHUB_ENV
41- sed -i "s/version=\(.*\)/version=$updatedVersion/g" gradle.properties
44+ - name : Initialize Sub Modules
45+ if : ${{ steps.check_recent_commits.outputs.recent_commits == 'true' }}
46+ run : git submodule update --init
4247
43- - name : Build and Publish
44- env :
45- publishUser : ${{ secrets.BALLERINA_BOT_USERNAME }}
46- publishPAT : ${{ secrets.BALLERINA_BOT_TOKEN }}
47- run : |
48- ./gradlew clean build -x javadoc --scan --continue --rerun-tasks -x test
49- ./gradlew publish
50- ./gradlew createCodeCoverageReport
51- curl -X POST \
52- 'https://api.github.com/repos/ballerina-platform/ballerina-release/dispatches' \
53- -H 'Accept: application/vnd.github.v3+json' \
54- -H 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \
55- --data "{
56- \"event_type\": \"update_timestamped_version\",
57- \"client_payload\": {
58- \"branch\": \"${{ matrix.branch }}\",
59- \"timestamped_version\": \"${TIMESTAMPED_VERSION}\"
60- }
61- }"
48+ - name : Change to Timestamped Version
49+ if : ${{ steps.check_recent_commits.outputs.recent_commits == 'true' }}
50+ run : |
51+ startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00')
52+ latestCommit=$(git log -n 1 --pretty=format:"%h")
53+ VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)
54+ updatedVersion=$VERSION-$startTime-$latestCommit
55+ echo $updatedVersion
56+ echo TIMESTAMPED_VERSION=$updatedVersion >> $GITHUB_ENV
57+ sed -i "s/version=\(.*\)/version=$updatedVersion/g" gradle.properties
6258
63- - name : Generate Codecov Report
64- uses : codecov/codecov-action@v4
65- with :
66- files : ./.jacoco/reports/jacoco/report.xml
59+ - name : Build and Publish
60+ if : ${{ steps.check_recent_commits.outputs.recent_commits == 'true' }}
61+ env :
62+ publishUser : ${{ secrets.BALLERINA_BOT_USERNAME }}
63+ publishPAT : ${{ secrets.BALLERINA_BOT_TOKEN }}
64+ run : |
65+ ./gradlew clean build -x javadoc --scan --continue --rerun-tasks -x test
66+ ./gradlew publish
67+ ./gradlew createCodeCoverageReport
68+ curl -X POST \
69+ 'https://api.github.com/repos/ballerina-platform/ballerina-release/dispatches' \
70+ -H 'Accept: application/vnd.github.v3+json' \
71+ -H 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \
72+ --data "{
73+ \"event_type\": \"update_timestamped_version\",
74+ \"client_payload\": {
75+ \"branch\": \"${{ matrix.branch }}\",
76+ \"timestamped_version\": \"${TIMESTAMPED_VERSION}\"
77+ }
78+ }"
79+
80+ - name : Generate Codecov Report
81+ if : ${{ steps.check_recent_commits.outputs.recent_commits == 'true' }}
82+ uses : codecov/codecov-action@v4
83+ with :
84+ files : ./.jacoco/reports/jacoco/report.xml
0 commit comments