-
Notifications
You must be signed in to change notification settings - Fork 3
184 lines (157 loc) · 5.21 KB
/
publish.yml
File metadata and controls
184 lines (157 loc) · 5.21 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
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
183
184
name: Publish
# Build, deploy and attach supported artifacts and draft release tag
on:
workflow_dispatch:
push:
tags:
- "v*.*.*"
jobs:
build_and_test:
name: Build and test java code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v1.4.4
with:
java-version: 11
- name: Build
run: mvn --no-transfer-progress clean compile
- name: Unit Test
run: mvn --no-transfer-progress test
build_jars:
if: success()
needs: [ build_and_test ]
name: Package and upload package to Maven Central
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Package
run: |
mvn --no-transfer-progress -DskipTests clean package
- name: Publish to the Maven Central Repository
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
run: |
mvn --no-transfer-progress --batch-mode deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USER_TOKEN }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PWD_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PWD }}
- name: Cache Jars
uses: actions/upload-artifact@v4
with:
name: scanoss-jars-maven
path: ./target/*.jar
# Build all the native binaries for the given OSes
build_native:
if: success()
needs: [ build_and_test ]
name: Build native on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm'
- name: Version Details
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image --version
- name: Native Build ${{ matrix.os }}
run: |
mvn --no-transfer-progress -Pnative -DskipTests package -X
- name: List Binaries
continue-on-error: true
run: |
ls target/scanoss-java*
- name: Rename Binary Windows
if: runner.os == 'Windows'
run: |
cd target
ren scanoss-java-*.exe scanoss-java-${{ matrix.os }}.exe
cd ..
- name: Rename Binary Unix
if: runner.os != 'Windows'
run: mv target/scanoss-java-* target/scanoss-java-${{ matrix.os }}
- name: List Packages
continue-on-error: true
run: |
ls target/
- name: Test Binary Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
.\target\scanoss-java-${{ matrix.os }}.exe -h
.\target\scanoss-java-${{ matrix.os }}.exe wfp src > fingers-${{ matrix.os }}.wfp
- name: Test Binary Unix
if: runner.os != 'Windows'
run: |
./target/scanoss-java-${{ matrix.os }} -h
./target/scanoss-java-${{ matrix.os }} wfp src > fingers-${{ matrix.os }}.wfp
wfps=$(fgrep 'file=' fingers-${{ matrix.os }}.wfp | wc -l)
echo "Found ${wfps} in src."
- name: Cache ${{ matrix.os }} Binary Unix
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: scanoss-jars-${{ matrix.os }}
path: ./target/scanoss-java-${{ matrix.os }}
- name: Cache ${{ matrix.os }} Binary Windows
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: scanoss-jars-${{ matrix.os }}
path: ./target/scanoss-java-${{ matrix.os }}.exe
merge:
runs-on: ubuntu-latest
needs: [build_jars, build_native]
steps:
- name: Merge artifacts
uses: actions/upload-artifact/merge@v4
with:
name: scanoss-jars
pattern: scanoss-jars-*
# Upload all the jars and binaries a GH Release
create_release:
if: success()
needs: [ build_jars, build_native ]
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Cached artifacts
uses: actions/download-artifact@v4
with:
pattern: scanoss-jars-*
merge-multiple: true
path: target
- name: List Packages
continue-on-error: true
run: |
ls -la target/
- name: GH Release ${{ github.ref_type }} - ${{ github.ref_name }}
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{github.ref_name}} \
--draft \
--repo ${{ github.server_url }}/${{ github.repository }} \
--generate-notes \
target/* scanoss-cli.sh