Skip to content

Commit

Permalink
ci: detect java version from version catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
imkiva committed Sep 26, 2023
1 parent f00597c commit a9fb251
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 19 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/extract-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
workflow_call:
outputs:
projectVersion:
description: "The version of this project"
value: ${{ jobs.extract-version.outputs.projectVersion }}
isSnapshot:
description: "Whether this is a snapshot build"
value: ${{ jobs.extract-version.outputs.isSnapshot }}
javaVersion:
description: "The Java version required to build this project"
value: ${{ jobs.extract-version.outputs.javaVersion }}

jobs:
extract-version:
runs-on: ubuntu-latest
outputs:
projectVersion: ${{ steps.check.outputs.ayaVersion }}
isSnapshot: ${{ steps.check.outputs.isSnapshot }}
javaVersion: ${{ steps.check.outputs.javaVersion }}
steps:
- uses: actions/checkout@v3
- name: Extract versions from Gradle's libs.versions.toml
id: check
shell: bash
run: |
# We use `head -n1` to select the first line matching the regex,
# so be sure to put these versions in the very beginning of the file.
projectVersion=$(cat ./gradle/libs.versions.toml | grep -Po 'project(\s*)=(\s*)"\K.*?(?=")' | head -n1)
javaVersion=$(cat ./gradle/libs.versions.toml | grep -Po 'java(\s*)=(\s*)"\K.*?(?=")' | head -n1)
isSnapshot="$(echo "$projectVersion" | grep -q "SNAPSHOT" && echo true || echo false)"
echo "Detected Project Version: $projectVersion, is snapshot: $isSnapshot"
echo "::set-output name=projectVersion::${projectVersion}"
echo "::set-output name=isSnapshot::${isSnapshot}"
echo "::set-output name=javaVersion::${javaVersion}"
6 changes: 5 additions & 1 deletion .github/workflows/gradle-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ on:
merge_group:
types: [checks_requested]
jobs:
check-aya-version:
uses: aya-prover/aya-dev/.github/workflows/extract-version.yml

gradle-check:
needs: [check-aya-version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Java 20
uses: actions/setup-java@v3
with:
distribution: 'liberica'
java-version: '20'
java-version: ${{ needs.check-aya-version.outputs.javaVersion }}
- uses: gradle/gradle-build-action@v2
with:
arguments: testCodeCoverageReport --no-daemon --stacktrace --warning-mode all
Expand Down
22 changes: 5 additions & 17 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,7 @@ jobs:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

check-aya-version:
runs-on: ubuntu-latest
outputs:
isSnapshot: ${{ steps.check.outputs.isSnapshot }}
steps:
- uses: actions/checkout@v3
- name: Check snapshot version
id: check
run: |
ver="$(cat ./gradle/deps.properties | grep "version.project" | cut -d'=' -f2)"
isSnapshot="$(echo "$ver" | grep -q "SNAPSHOT" && echo true || echo false)"
echo "Detected Project Version: $ver"
echo "Detected Project Version is a SNAPSHOT: $isSnapshot"
echo "::set-output name=isSnapshot::${isSnapshot}"
uses: aya-prover/aya-dev/.github/workflows/extract-version.yml

publish-snapshot:
needs: [check-aya-version]
Expand All @@ -44,14 +32,14 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'liberica'
java-version: '20'
java-version: ${{ needs.check-aya-version.outputs.javaVersion }}
- name: gradle publish
uses: gradle/gradle-build-action@v2
with:
arguments: publish --info --no-daemon --stacktrace --warning-mode all

nightly-build:
needs: [move-tag]
needs: [move-tag, check-aya-version]
runs-on: ${{ matrix.os }}
env:
nativeName: aya-prover_native_${{ matrix.platform }}${{ matrix.binaryExt }}
Expand All @@ -76,7 +64,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'liberica'
java-version: '20'
java-version: ${{ needs.check-aya-version.outputs.javaVersion }}

- name: Run task jlinkAyaZip
uses: gradle/gradle-build-action@v2
Expand All @@ -93,7 +81,7 @@ jobs:
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '20'
java-version: ${{ needs.check-aya-version.outputs.javaVersion }}
distribution: 'graalvm-community'
components: 'native-image'
set-java-home: 'false'
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# After that, increase the version number and add "-SNAPSHOT" suffix back for next cycle.
project = "0.30-SNAPSHOT"

# Remember to update .github/workflows/{nightly-build.yml, gradle-check.yml}
# https://openjdk.org/
java = "20"

# https://github.com/JetBrains/java-annotations
annotations = "24.0.1"
kala = "0.67.0"
Expand Down

0 comments on commit a9fb251

Please sign in to comment.