-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (85 loc) · 2.89 KB
/
maven-build-and-release.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
name: Build and Release JAR
on:
push:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: ubuntu-latest
os-name: linux
- os: windows-latest
os-name: windows
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 21 (Zulu)
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'zulu'
- name: Build with Maven
run: mvn package -B -DskipTests=true -f pom.xml
- name: Find JAR file
id: find-jar
uses: actions/github-script@v5
with:
script: |
const fs = require('fs');
const files = fs.readdirSync('./target').filter(fn => fn.endsWith('.jar'));
if (files.length > 0) {
core.setOutput('jar_name', files[0]);
} else {
core.setFailed('No JAR file found');
}
- name: Rename JAR file
run: |
mv ./target/${{ steps.find-jar.outputs.jar_name }} ./target/${{ matrix.os-name }}-viro.jar
shell: bash
- name: Upload JAR Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os-name }}
path: ./target/${{ matrix.os-name }}-viro.jar
release:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: target/
- name: Get short SHA
id: short-sha
run: echo "SHORT_SHA=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly-${{ env.SHORT_SHA }}
release_name: nightly-${{ env.SHORT_SHA }}
draft: false
prerelease: true
- name: Upload Linux JAR to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/linux/linux-viro.jar
asset_name: viro-linux-${{ env.SHORT_SHA }}.jar
asset_content_type: application/java-archive
- name: Upload Windows JAR to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/windows/windows-viro.jar
asset_name: viro-windows-${{ env.SHORT_SHA }}.jar
asset_content_type: application/java-archive