forked from SergeyDertan/SRegionProtector
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (75 loc) · 3.05 KB
/
Copy pathbuild.yml
File metadata and controls
87 lines (75 loc) · 3.05 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
name: Build and Release
on:
workflow_dispatch:
push:
tags:
- 'v*'
branches:
- '**'
pull_request:
permissions:
contents: write
jobs:
build-maven:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
server-id: powernukkitx-releases
server-username: PNX_REPO_USERNAME
server-password: PNX_REPO_PASSWORD
- name: Build with Maven
run: mvn -B package -DskipTests=false -Darguments="-Dmaven.javadoc.skip=true"
- name: Read project metadata
id: project
shell: bash
run: |
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
FINAL_NAME=$(mvn help:evaluate -Dexpression=project.build.finalName -q -DforceStdout)
echo "artifact_id=$ARTIFACT_ID" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "final_name=$FINAL_NAME" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
echo "jar_path=target/$FINAL_NAME.jar" >> "$GITHUB_OUTPUT"
- name: Verify artifact
shell: bash
run: |
if [ ! -f "${{ steps.project.outputs.jar_path }}" ]; then
echo "${{ steps.project.outputs.jar_path }} was not created"
exit 1
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: success()
with:
name: ${{ steps.project.outputs.artifact_id }}
path: ${{ steps.project.outputs.jar_path }}
- name: Create GitHub release
if: github.event_name == 'push' && (github.ref_type == 'tag' || github.ref_name == github.event.repository.default_branch)
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
RELEASE_TAG="${{ github.ref_name }}"
else
RELEASE_TAG="${{ steps.project.outputs.tag }}"
fi
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" "${{ steps.project.outputs.jar_path }}" --clobber
else
gh release create "$RELEASE_TAG" "${{ steps.project.outputs.jar_path }}" --target "${{ github.sha }}" --title "$RELEASE_TAG" --notes "Automated release for $RELEASE_TAG"
fi
- name: Deploy to PowerNukkitX repository
if: github.event_name == 'push' && (github.ref_type == 'tag' || github.ref_name == github.event.repository.default_branch)
run: mvn -B deploy -DskipTests -Darguments="-Dmaven.javadoc.skip=true" -DaltDeploymentRepository=powernukkitx-releases::default::https://repo.powernukkitx.org/releases
env:
PNX_REPO_USERNAME: ${{ secrets.PNX_REPO_USERNAME }}
PNX_REPO_PASSWORD: ${{ secrets.PNX_REPO_PASSWORD }}