-
Notifications
You must be signed in to change notification settings - Fork 15
143 lines (137 loc) · 4.92 KB
/
build-java.yml
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
136
137
138
139
140
141
142
143
name: Build java package
on:
pull_request: # Apply to all pull requests
push: # Apply to all branches
env:
GRADLE_VERSION: 7.5.1
RELEASE_VERSION: 0
jobs:
build-java:
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v3
- name: Source dependency versions
working-directory: config
run: |
cat versions.txt >> $GITHUB_ENV
- name: Detect release version
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo RELEASE_VERSION=1 >> $GITHUB_ENV
- name: Install Protoc
run: |
sudo apt-get update && apt-get install -y apt-utils && apt-get install -y unzip
mkdir ${{ runner.temp }}/protoc_install
wget https://github.com/protocolbuffers/protobuf/releases/download/v${{ env.COMMON_PROTOC_VERSION }}/protoc-${{ env.COMMON_PROTOC_VERSION }}-linux-x86_64.zip -P ${{ runner.temp }}/protoc_install
unzip ${{ runner.temp }}/protoc_install/*.zip -d ${{ runner.temp }}/protoc_install/protoc
echo "${{ runner.temp }}/protoc_install/protoc/bin" >> $GITHUB_PATH
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: ${{ env.GRADLE_VERSION }}
- name: Execute build
working-directory: ./java
run: ./gradlew jar
- name: Archive built jars
uses: actions/upload-artifact@v3
with:
name: target_jars
path: java/build/libs/*.jar
run-tests-java11:
runs-on: ubuntu-latest
needs: build-java
steps:
# Run `git checkout`
- uses: actions/checkout@v3
- name: Download t2iapi jar artifact
uses: actions/download-artifact@v3
with:
name: target_jars
path: java/build/libs/
- name: Detect release version
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo RELEASE_VERSION=1 >> $GITHUB_ENV
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: ${{ env.GRADLE_VERSION }}
- name: Execute tests
working-directory: tests/java
run: ./gradlew test
- name: Archive test results
uses: actions/upload-artifact@v3
with:
name: test_results
path: tests/java/build/reports/tests/test/**/*.*
deploy-github-packages:
runs-on: ubuntu-latest
needs: run-tests-java11
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
permissions:
packages: write
contents: write
steps:
- uses: actions/checkout@v3
- name: Source dependency versions
working-directory: config
run: |
cat versions.txt >> $GITHUB_ENV
- name: Download t2iapi test results artifact
uses: actions/download-artifact@v3
with:
name: test_results
path: test_results/
- name: Detect release version
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo RELEASE_VERSION=1 >> $GITHUB_ENV
- name: Install Protoc
run: |
sudo apt-get update && apt-get install -y apt-utils && apt-get install -y unzip
mkdir ${{ runner.temp }}/protoc_install
wget https://github.com/protocolbuffers/protobuf/releases/download/v${{ env.COMMON_PROTOC_VERSION }}/protoc-${{ env.COMMON_PROTOC_VERSION }}-linux-x86_64.zip -P ${{ runner.temp }}/protoc_install
unzip ${{ runner.temp }}/protoc_install/*.zip -d ${{ runner.temp }}/protoc_install/protoc
echo "${{ runner.temp }}/protoc_install/protoc/bin" >> $GITHUB_PATH
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: ${{ env.GRADLE_VERSION }}
- name: Publish package
working-directory: ./java
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install zip
if: startsWith(github.ref, 'refs/tags/')
uses: montudor/action-zip@v1
- name: Zip test results
if: startsWith(github.ref, 'refs/tags/')
run: |
zip -qq -r java-test-results.zip test_results
- name: Attach artifacts to github release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
java/build/libs/*.jar
java/build/publications/maven/pom-default.xml
java-test-results.zip
prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') }}
body_path: CHANGELOG.md