Skip to content

Commit 736dbe6

Browse files
dnestorofniephaus
andauthored
Add GitHub Action for Scheduled Releases (#537)
* Add github action that creates automatic scheduled releases * Test and generate artifacts before committing changes * Use tag --list to get list of tags * Change a palceholder for repo version in build.gradle * Add comment about fixed snapshot version * Update .github/workflows/create-scheduled-release.yml --------- Co-authored-by: Fabio Niephaus <fabio.niephaus@oracle.com>
1 parent a632276 commit 736dbe6

File tree

3 files changed

+82
-2
lines changed

3 files changed

+82
-2
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: "Create scheduled release"
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 1 * *"
6+
- cron: "0 0 15 * *"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
get-changed-metadata:
14+
name: "📋 Get a list of changed metadata"
15+
runs-on: "ubuntu-20.04"
16+
timeout-minutes: 5
17+
outputs:
18+
matrix: ${{ steps.set-matrix.outputs.matrix }}
19+
none-found: ${{ steps.set-matrix.outputs.none-found }}
20+
steps:
21+
- name: "☁️ Checkout repository"
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: "🔧 Setup java"
26+
uses: actions/setup-java@v4
27+
with:
28+
distribution: 'graalvm'
29+
java-version: '21'
30+
- name: "🕸️ Get changed metadata matrix"
31+
id: set-matrix
32+
run: |
33+
LATEST_TAG=$(git tag --list | sort -V | tail -1)
34+
./gradlew generateMatrixDiffCoordinates -PbaseCommit=$(git show-ref -s $LATEST_TAG) -PnewCommit=$(git rev-parse HEAD)
35+
36+
release:
37+
needs: get-changed-metadata
38+
if: needs.get-changed-metadata.result == 'success' && needs.get-changed-metadata.outputs.none-found != 'true'
39+
name: "🚀 Create a release"
40+
runs-on: "ubuntu-20.04"
41+
env:
42+
GH_TOKEN: ${{ github.token }}
43+
steps:
44+
- name: "☁️ Checkout repository"
45+
uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0
48+
- name: "🔧 Setup java"
49+
uses: actions/setup-java@v4
50+
with:
51+
distribution: 'graalvm'
52+
java-version: '21'
53+
- name: "Get tags"
54+
run: |
55+
PREVIOUS_RELEASE_TAG=$(git tag --list | sort -V | tail -1)
56+
echo "PREVIOUS_RELEASE_TAG=$PREVIOUS_RELEASE_TAG" >> ${GITHUB_ENV}
57+
58+
CURRENT_RELEASE_TAG=$(sed -E 's/^([0-9]+\.)([0-9]+\.)([0-9]+)/echo \1\2$((\3+1))/e' <<< $PREVIOUS_RELEASE_TAG)
59+
echo "CURRENT_RELEASE_TAG=$CURRENT_RELEASE_TAG" >> ${GITHUB_ENV}
60+
- name: "⬆️ Update version"
61+
run: |
62+
sed -i "s/project.version(\"1.0.0-SNAPSHOT\")/project.version(\"${{ env.CURRENT_RELEASE_TAG }}\")/g" build.gradle
63+
- name: "🔍 Run spotless check"
64+
run: |
65+
./gradlew spotlessCheck
66+
- name: "🏭 Generate release artifacts"
67+
run: |
68+
./gradlew package
69+
- name: "📄 Commit changes"
70+
run: |
71+
git config --local user.email "actions@github.com"
72+
git config --local user.name "Github Actions"
73+
git add .
74+
git commit -m "Release version ${{ env.CURRENT_RELEASE_TAG }}"
75+
git tag ${{ env.CURRENT_RELEASE_TAG }}
76+
git push origin ${{ env.CURRENT_RELEASE_TAG }}
77+
- name: "📝 Publish a release"
78+
run: |
79+
gh release create ${{ env.CURRENT_RELEASE_TAG }} build/graalvm-reachability-metadata-*.zip --generate-notes --notes-start-tag ${{ env.PREVIOUS_RELEASE_TAG }}

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ allprojects {
1818
}
1919
}
2020

21-
project.version("0.3.10-SNAPSHOT")
21+
// NOTE: this version serves only as a placeholder and will be overridden by the CI when creating a new release
22+
project.version("1.0.0-SNAPSHOT")
2223

2324
// gradle check
2425
spotless {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)