Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick from #996 #997

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"