-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (51 loc) · 1.84 KB
/
build.yml
File metadata and controls
53 lines (51 loc) · 1.84 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: "Build and Test"
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
build:
name: "Build"
runs-on:
- ubuntu-latest
env:
GRADLE_OPTS: "-Djava.security.egd=file:/dev/./urandom -Dorg.gradle.parallel=true"
container:
image: azul/zulu-openjdk:11
steps:
- name: "Install packages"
run: apt-get update && apt-get install -y git
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-tags: true
- name: "Validate version tag doesn't exist"
run: |
VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2)
TAG="v${VERSION}"
REPO_URL="https://github.com/${{ github.repository }}"
if git ls-remote --tags "${REPO_URL}" | grep -q "refs/tags/${TAG}$"; then
echo "============================================="
echo "ERROR: Tag ${TAG} already exists!"
echo ""
echo "Please bump the version in gradle.properties"
echo "============================================="
exit 1
fi
echo "✓ Version ${VERSION} is valid (tag ${TAG} does not exist yet)"
- name: "Gradle cache"
uses: actions/cache@v4
with:
path: |
~/.gradle
key: gradle-v1-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', '**/*.gradle*') }}
- name: "Assemble jar"
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew assemble --console=plain --no-daemon
- name: "Test if publishing works"
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew publishToMavenLocal --console=plain --no-daemon --stacktrace
- name: "Tag release"
if: github.ref == 'refs/heads/main'
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew tagRelease --console=plain --no-daemon