-
Notifications
You must be signed in to change notification settings - Fork 42
118 lines (104 loc) · 3.53 KB
/
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
name: Build and publish Java artifact
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
target:
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-gnu
- aarch64-apple-darwin
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: aarch64-unknown-linux-gnu
os: ubuntu-20.04
buildfile: 'libminify_html_java.so'
resfile: 'linux-aarch64.nativelib'
- target: x86_64-unknown-linux-gnu
os: ubuntu-20.04
buildfile: 'libminify_html_java.so'
resfile: 'linux-x64.nativelib'
- target: aarch64-apple-darwin
os: macos-11.0
buildfile: 'libminify_html_java.dylib'
resfile: 'mac-aarch64.nativelib'
- target: x86_64-apple-darwin
os: macos-11.0
buildfile: 'libminify_html_java.dylib'
resfile: 'mac-x64.nativelib'
- target: x86_64-pc-windows-msvc
os: windows-2019
buildfile: 'minify_html_java.dll'
resfile: 'win-x64.nativelib'
steps:
- uses: actions/checkout@v1
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Set up cross compiler
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: sudo apt install -y gcc-aarch64-linux-gnu
- name: Build Java native library
working-directory: ./minify-html-java
shell: bash
run: |
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc
cargo build --release --target ${{ matrix.target }}
# upload-artifact does not rename the file, so when we download if we don't rename all files will have the same name.
mv -v ../target/${{ matrix.target }}/release/${{ matrix.buildfile }} ${{ matrix.resfile }}
- name: Upload built library
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.resfile }}
path: minify-html-java/${{ matrix.resfile }}
package:
runs-on: ubuntu-20.04
needs: build
steps:
- uses: actions/checkout@v1
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: '1.7'
java-package: jdk
architecture: x64
- uses: actions/download-artifact@v4
with:
path: 'minify-html-java/src/main/resources/'
merge-multiple: true
- name: Build, pack, and publish JAR
working-directory: ./minify-html-java
env:
SONATYPE_GPG_PRIVATE_KEY: ${{ secrets.SONATYPE_GPG_PRIVATE_KEY }}
run: |
echo "$SONATYPE_GPG_PRIVATE_KEY" | gpg --allow-secret-key-import --import
mkdir -p "$HOME/.m2"
cat << 'EOF' > "$HOME/.m2/settings.xml"
<settings>
<servers>
<server>
<id>ossrh</id>
<username>wilsonzlin</username>
<password>${{ secrets.SONATYPE_PASSWORD }}</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</settings>
EOF
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
mvn clean deploy
fi