Repository navigation
80 lines (69 loc) · 2.78 KB
/
Copy pathbuild.yml
File metadata and controls
80 lines (69 loc) · 2.78 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
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- name: Set up JDK 21
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '21'
cache: maven
- name: Install shared plugin dependencies
uses: TF-Minecraft/TLibs/.github/actions/setup-plugins@8ef41de589f121c98ff892b10696e7c1feb4ca74
with:
mode: pinned
- name: Set build version
id: dev
shell: bash
run: |
dev_version="main-SNAPSHOT"
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
dev_version="DEV-$(date -u +%Y%m%d-%H%M)"
fi
mvn -B --no-transfer-progress org.codehaus.mojo:versions-maven-plugin:2.22.0:set \
-DnewVersion="$dev_version" -DgenerateBackupPoms=false
mvn -B --no-transfer-progress help:evaluate \
-Dexpression=project.build.finalName -Doutput="$RUNNER_TEMP/final-name"
final_name=$(cat "$RUNNER_TEMP/final-name")
[[ "$final_name" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]] || exit 1
echo "version=$dev_version" >> "$GITHUB_OUTPUT"
echo "name=$final_name" >> "$GITHUB_OUTPUT"
echo "jar=target/$final_name.jar" >> "$GITHUB_OUTPUT"
- name: Run unit tests and build
run: mvn -B --no-transfer-progress clean verify -DskipTests=false -Dmaven.test.skip=false
- name: Verify runtime JAR
env:
ARTIFACT_PATH: ${{ steps.dev.outputs.jar }}
BUILD_VERSION: ${{ steps.dev.outputs.version }}
run: python3 .github/scripts/plugin-artifact.py --jar "$ARTIFACT_PATH" --version "$BUILD_VERSION"
- name: Upload plugin jar
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v7
with:
name: ${{ steps.dev.outputs.name }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
${{ steps.dev.outputs.jar }}
.build/plugin-dependencies.json
include-hidden-files: true
if-no-files-found: error
- name: Upload unit test reports
if: ${{ !cancelled() && hashFiles('target/surefire-reports/*.xml') != '' }}
uses: actions/upload-artifact@v7
with:
name: unit-test-reports-${{ github.run_id }}-${{ github.run_attempt }}
path: target/surefire-reports/
if-no-files-found: error
- name: Upload coverage report
if: ${{ !cancelled() && hashFiles('target/site/jacoco/jacoco.xml') != '' }}
uses: actions/upload-artifact@v7
with:
name: coverage-report-${{ github.run_id }}-${{ github.run_attempt }}
path: target/site/jacoco/
if-no-files-found: error