-
Notifications
You must be signed in to change notification settings - Fork 4
161 lines (139 loc) · 4.86 KB
/
build-and-release-package.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: "build-and-release-package"
env:
JAVA_VERSION: "11"
on:
pull_request:
paths:
- ".github/workflows/build-and-release-package.yml"
- ".gitmodules"
- "assembly-lib.xml"
- "assembly-package.xml"
- "CMakeLists.txt"
- "pom.xml"
- "src/**/*"
- "tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh"
push:
paths:
- ".github/workflows/build-and-release-package.yml"
- ".gitmodules"
- "assembly-lib.xml"
- "assembly-package.xml"
- "CMakeLists.txt"
- "pom.xml"
- "src/**/*"
- "tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh"
workflow_dispatch:
# Concurrency group to prevent multiple workflow instances from trying to publish releases
concurrency: "${{github.workflow}}-${{github.ref}}"
jobs:
build-lib-for-linux-aarch64:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
with:
submodules: "recursive"
- uses: "docker/setup-qemu-action@v3"
with:
platforms: "arm64"
- name: "Build native library for Linux aarch64"
run: >-
docker run
--rm
--platform linux/arm64
--mount type=bind,source=${{ github.workspace }},target=/mnt/clp
--workdir /mnt/clp
eclipse-temurin:11-jdk-focal
./tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
- uses: "actions/upload-artifact@v4"
with:
name: "libclp-ffi-java-linux-aarch64"
path: "${{github.workspace}}/target/clp-ffi-*-native-lib/"
if-no-files-found: "error"
retention-days: 1
build-lib-for-macos:
strategy:
matrix:
runner: ["macos-13", "macos-14"]
runs-on: "${{ matrix.runner }}"
steps:
- uses: "actions/checkout@v4"
with:
submodules: "recursive"
- name: "Install requirements"
run: "brew install cmake gcc java${{env.JAVA_VERSION}} maven"
- name: "Build native library for MacOS"
run: "mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir"
- uses: "actions/upload-artifact@v4"
with:
name: >-
${{ matrix.runner == 'macos-13'
&& 'libclp-ffi-java-macos-amd64'
|| 'libclp-ffi-java-macos-aarch64' }}
path: "${{github.workspace}}/target/clp-ffi-*-native-lib/"
if-no-files-found: "error"
retention-days: 1
build-and-release:
needs:
- "build-lib-for-linux-aarch64"
- "build-lib-for-macos"
runs-on: "ubuntu-20.04"
permissions:
contents: "read"
packages: "write"
env:
JAVA_DIST: "temurin"
steps:
- uses: "actions/checkout@v4"
with:
submodules: "recursive"
- uses: "actions/setup-java@v4"
with:
java-version: "${{env.JAVA_VERSION}}"
distribution: "${{env.JAVA_DIST}}"
server-id: "github"
# This will override the setup-java step above
- if: "startsWith(github.ref, 'refs/heads/v') && github.event_name == 'workflow_dispatch'"
uses: "actions/setup-java@v4"
with:
java-version: "${{env.JAVA_VERSION}}"
distribution: "${{env.JAVA_DIST}}"
server-id: "ossrh"
server-username: "MAVEN_USERNAME"
server-password: "MAVEN_PASSWORD"
gpg-private-key: "${{secrets.GPG_PRIVATE_KEY}}"
gpg-passphrase: "MAVEN_GPG_PASSPHRASE"
- name: "Install requirements"
run: |
sudo apt update
sudo apt install -y build-essential cmake
- name: "Build, and run tests"
run: "mvn --batch-mode test"
- uses: "actions/download-artifact@v4"
with:
name: "libclp-ffi-java-linux-aarch64"
path: "./target/."
- uses: "actions/download-artifact@v4"
with:
pattern: "libclp-ffi-java-macos-*"
path: "./target/."
merge-multiple: true
- name: "Build package"
run: "mvn --batch-mode package -DskipTests"
- if: "github.event_name != 'pull_request' && github.ref == 'refs/heads/main'"
name: "Deploy to GitHub Packages"
run: "mvn --batch-mode deploy -DskipTests -Pgithub_release"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "startsWith(github.ref, 'refs/heads/v') && github.event_name == 'workflow_dispatch'"
name: "Deploy to Maven Central"
run: "mvn --batch-mode deploy -DskipTests -Pmaven_release"
env:
MAVEN_USERNAME: "${{secrets.OSSRH_USERNAME}}"
MAVEN_PASSWORD: "${{secrets.OSSRH_TOKEN}}"
MAVEN_GPG_PASSPHRASE: "${{secrets.GPG_PASSPHRASE}}"
- uses: "actions/upload-artifact@v4"
with:
name: "clp-ffi-java"
path: "${{github.workspace}}/target/clp-ffi-*.jar"
if-no-files-found: "error"
retention-days: 1