-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (101 loc) · 3.81 KB
/
maven.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
name: Java CI with Maven and Release
on:
push:
branches: [ "dev-master" ]
pull_request:
branches: [ "dev-master" ]
permissions:
contents: write
packages: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
java: [21]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Get version from pom.xml
run: |
echo "PROJECT_VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)" >> $GITHUB_ENV
shell: bash
- name: Build with Maven
run: mvn clean install -B -V
- name: Display Java version
run: java -version
- name: Display Maven version
run: mvn --version
- name: Calculate SHA-256 checksum
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sha256sum target/NovelAI-Studio-FX-${{ env.PROJECT_VERSION }}.jar > target/NovelAI-Studio-FX-${{ env.PROJECT_VERSION }}.jar.sha256
elif [ "$RUNNER_OS" == "Windows" ]; then
$hash = (Get-FileHash -Path target\NovelAI-Studio-FX-${{ env.PROJECT_VERSION }}.jar -Algorithm SHA256).Hash.ToLower()
$hash + " *NovelAI-Studio-FX-${{ env.PROJECT_VERSION }}.jar" | Out-File -Encoding ASCII target\NovelAI-Studio-FX-${{ env.PROJECT_VERSION }}.jar.sha256
else
echo "Unsupported operating system"
exit 1
fi
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: NovelAI-Studio-FX-${{ matrix.os }}-${{ env.PROJECT_VERSION }}
path: |
target/NovelAI-Studio-FX-*.jar
target/NovelAI-Studio-FX-*.jar.sha256
- name: Run tests
run: mvn test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-${{ matrix.java }}-${{ env.PROJECT_VERSION }}
path: target/surefire-reports
- name: Upload Maven logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: maven-logs-${{ matrix.os }}-${{ matrix.java }}-${{ env.PROJECT_VERSION }}
path: ~/.m2/repository/.m2.log
- name: Create Release
if: success() && matrix.os == 'ubuntu-latest'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.PROJECT_VERSION }}
release_name: Release ${{ env.PROJECT_VERSION }}
draft: false
prerelease: false
- name: Upload Release Asset (JAR)
if: success() && matrix.os == 'ubuntu-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/NovelAI-Studio-FX-${{ env.PROJECT_VERSION }}.jar
asset_name: NovelAI-Studio-FX-${{ env.PROJECT_VERSION }}.jar
asset_content_type: application/java-archive
- name: Upload Release Asset (SHA-256)
if: success() && matrix.os == 'ubuntu-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/NovelAI-Studio-FX-${{ env.PROJECT_VERSION }}.jar.sha256
asset_name: NovelAI-Studio-FX-${{ env.PROJECT_VERSION }}.jar.sha256
asset_content_type: text/plain