-
Notifications
You must be signed in to change notification settings - Fork 11
182 lines (159 loc) · 5.05 KB
/
java-test.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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: java-test
on:
push:
branches:
- main
- master
tags:
- '*'
pull_request:
branches:
- main
paths:
- "java/**"
- ".github/workflows/java-test.yaml"
workflow_dispatch:
jobs:
test-and-build:
permissions:
actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows
contents: read # for actions/checkout to fetch code
name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }} for the classifier ${{ matrix.classifier }}"
strategy:
matrix:
include:
- os: ubuntu-latest
classifier: linux-aarch_64
java: 8
root-pom: 'pom.xml'
- os: windows-latest
classifier: windows-x86_64
java: 8
root-pom: 'pom.xml'
- os: macos-latest
classifier: osx-x86_64
java: 8
root-pom: 'pom.xml'
- os: macos-latest
classifier: osx-aarch_64
java: 8
root-pom: 'pom.xml'
runs-on: ${{ matrix.os }}
env:
ROOT_POM: ${{ matrix.root-pom }}
steps:
- uses: actions/checkout@v4
- name: 'Set up JDK ${{ matrix.java }}'
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
cache: 'maven'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.79
override: true
components: clippy, rustfmt
- name: Setup linux-aarch_64 rust target
if: "contains(matrix.classifier, 'linux-aarch_64')"
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# Setup for cargo
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: 'Test'
shell: bash
working-directory: java
run: make test
- name: 'Build and Deploy'
shell: bash
working-directory: java
run: mvn clean package -DskipTests=true -Djni.classifier=${{ matrix.classifier }} -Dcargo-build.profile=release
- name: 'Upload artifact'
uses: actions/upload-artifact@v3
with:
name: kcl-lib-${{ matrix.classifier }}
path: |
java/target/classes/native
build-centos7:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
needs: [ test-and-build ]
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download windows x86_64 lib
uses: actions/download-artifact@v3
with:
name: kcl-lib-windows-x86_64
path: java/native
- name: Download linux aarch_64 lib
uses: actions/download-artifact@v3
with:
name: kcl-lib-linux-aarch_64
path: java/native
- name: Download darwin x86_64 lib
uses: actions/download-artifact@v3
with:
name: kcl-lib-osx-x86_64
path: java/native
- name: Download darwin aarch_64 lib
uses: actions/download-artifact@v3
with:
name: kcl-lib-osx-aarch_64
path: java/native
- name: Run tests and package in CentOS 7 container
run: |
docker run --rm -v ${{ github.workspace }}/java:/work kcllang/kcl-java-builder-centos7:0.1.0 bash -c "
cd /work &&
rustup default stable &&
mvn package -DskipTests=true -Dcargo-build.profile=release
"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: kcl-lib
path: java/target/*.jar
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [ test-and-build, build-centos7 ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Download Jar
uses: actions/download-artifact@v3
with:
name: kcl-lib
path: java/release
- name: Release to Github Packages
if: "startsWith(github.ref, 'refs/tags/')"
working-directory: java
run: |
JAR_FILE=$(find ./release -name "*.jar" ! -name "*sources.jar")
echo "Deploying $JAR_FILE"
mvn deploy:deploy-file \
-Dfile=$JAR_FILE \
-DpomFile=./pom.xml \
-DrepositoryId=github \
-Durl=https://maven.pkg.github.com/kcl-lang/lib \
-s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}