-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (34 loc) · 1.63 KB
/
extract-version.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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@v4
- 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, Java version: $javaVersion"
echo "projectVersion=${projectVersion}" >> $GITHUB_OUTPUT
echo "isSnapshot=${isSnapshot}" >> $GITHUB_OUTPUT
echo "javaVersion=${javaVersion}" >> $GITHUB_OUTPUT