-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (119 loc) · 4.43 KB
/
Copy path_build.yml
File metadata and controls
135 lines (119 loc) · 4.43 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Build
# Reusable build pipeline: compiles and tests the annotations and compiler / `Gradle`
# plugin, and resolves the version channel. Called by ci.yml (every push / PR) and
# release.yml (publishing).
on:
workflow_call:
inputs:
pull_request:
description: When true, this is a PR code-correctness run.
type: boolean
default: false
outputs:
version:
value: ${{ jobs.metadata.outputs.version }}
pretty_version:
value: ${{ jobs.metadata.outputs.pretty_version }}
is_dev:
value: ${{ jobs.metadata.outputs.is_dev }}
is_preview:
value: ${{ jobs.metadata.outputs.is_preview }}
is_release:
value: ${{ jobs.metadata.outputs.is_release }}
is_publishable:
value: ${{ jobs.metadata.outputs.is_publishable }}
permissions:
contents: read
jobs:
metadata:
name: Metadata
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
version: ${{ steps.get_version.outputs.version }}
pretty_version: ${{ steps.get_version.outputs.pretty_version }}
is_dev: ${{ steps.get_version.outputs.is_dev }}
is_preview: ${{ steps.get_version.outputs.is_preview }}
is_release: ${{ steps.get_version.outputs.is_release }}
is_publishable: ${{ steps.get_version.outputs.is_publishable }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get version
id: get_version
run: |
VERSION=$(grep '^version' gradle.properties | cut -d'=' -f2 | tr -d ' ')
echo "version=$VERSION" >> $GITHUB_OUTPUT
if [[ "$VERSION" =~ ^([0-9]+(\.[0-9]+)*)-dev$ ]]; then
echo "is_dev=true" >> $GITHUB_OUTPUT
echo "is_preview=false" >> $GITHUB_OUTPUT
echo "is_release=false" >> $GITHUB_OUTPUT
echo "is_publishable=false" >> $GITHUB_OUTPUT
echo "pretty_version=${BASH_REMATCH[1]} Developer" >> $GITHUB_OUTPUT
elif [[ "$VERSION" =~ ^([0-9]+(\.[0-9]+)*)-preview\.([0-9]+)$ ]]; then
echo "is_dev=false" >> $GITHUB_OUTPUT
echo "is_preview=true" >> $GITHUB_OUTPUT
echo "is_release=false" >> $GITHUB_OUTPUT
echo "is_publishable=true" >> $GITHUB_OUTPUT
echo "pretty_version=${BASH_REMATCH[1]} Preview ${BASH_REMATCH[3]}" >> $GITHUB_OUTPUT
elif [[ "$VERSION" =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
echo "is_dev=false" >> $GITHUB_OUTPUT
echo "is_preview=false" >> $GITHUB_OUTPUT
echo "is_release=true" >> $GITHUB_OUTPUT
echo "is_publishable=true" >> $GITHUB_OUTPUT
echo "pretty_version=$VERSION Release" >> $GITHUB_OUTPUT
else
echo "is_dev=false" >> $GITHUB_OUTPUT
echo "is_preview=false" >> $GITHUB_OUTPUT
echo "is_release=false" >> $GITHUB_OUTPUT
echo "is_publishable=false" >> $GITHUB_OUTPUT
echo "pretty_version=$VERSION" >> $GITHUB_OUTPUT
fi
build:
name: Build
runs-on: ubuntu-latest
needs: metadata
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: ${{ github.event_name == 'pull_request' }}
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Build and test
run: ./gradlew build --no-daemon --parallel --build-cache
env:
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.caching=true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: '**/build/reports/tests/'
- name: Collect artifacts
run: |
mkdir -p artifacts
find . -path '*/build/libs/*.jar' -exec cp {} artifacts/ \;
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-jars
path: artifacts/*.jar
if-no-files-found: error
retention-days: 7