-
Notifications
You must be signed in to change notification settings - Fork 9
130 lines (124 loc) · 4.22 KB
/
mvn.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
120
121
122
123
124
125
126
127
128
129
130
# This workflow will build a Java project with Ant
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-ant
name: Java CI
on:
push:
branches:
- master
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check_commit.outputs.result }}
commit: ${{ steps.latest_commit.outputs.commit }}
semVer: ${{ steps.gitversion.outputs.fullSemVer }}
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
- name: Set latest_commit
id: latest_commit
run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Check if latest commit already built
uses: actions/github-script@v6
id: check_commit
with:
script: |
const latestDevCommit = "${{ steps.latest_commit.outputs.commit }}"
const { owner, repo } = context.repo
try
{
let { data: release } = await github.rest.repos.getLatestRelease({ owner, repo })
const latestReleaseCommit = release.body.split('@')[1]
console.log(`Latest release commit: ${latestReleaseCommit}`)
console.log(`Latest dev commit: ${latestDevCommit}`)
if (latestReleaseCommit === latestDevCommit) {
return 'false'
} else {
return 'true'
}
}
catch
{
return 'true'
}
result-encoding: string
# release:
# runs-on: ubuntu-latest
# needs: [prepare]
# outputs:
# tag: ${{ steps.tag.outputs.tag }}
# steps:
# - name: Set tag name
# id: tag
# run: |
# tag=v$(date +%Y%m%d.%H%M%S)
# echo "tag=$tag" >> $GITHUB_OUTPUT
# - name: Create Release
# env:
# GH_TOKEN: ${{ github.token }}
# GH_REPO: ${{ github.repository }}
# run: |
# tag="${{ steps.tag.outputs.tag }}"
# body="runsafe/framework@${{ needs.prepare.outputs.commit }}"
# gh release create --draft "$tag" --title "$tag" --notes "$body"
build:
runs-on: ubuntu-latest
needs: [prepare]
if: needs.prepare.outputs.should_build == 'true'
steps:
- name: Clone framework
uses: actions/checkout@v3
with:
repository: Runsafe/Framework
ref: ${{ needs.prepare.outputs.commit }}
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Build spigot
shell: bash
run: |
mkdir target
cd target
curl https://hub.spigotmc.org/jenkins/job/BuildTools/lastStableBuild/artifact/target/BuildTools.jar -o BuildTools.jar
java -jar BuildTools.jar --rev 1.12.2
- name: Build with Maven
shell: bash
run: |
sed -e "s/1.12-SNAPSHOT/$SEMVER/" pom.xml > patched.xml
mvn -B deploy -f patched.xml
mvn deploy:deploy-file -DgroupId=no.runsafe -DartifactId=framework -DrepositoryId=framework -Dversion=$SEMVER -DgeneratePom=true -Dfiles=spigot-1.12.2jar,craftbukkit-1.12.2.jar -Dfile=framework.jar -f patched.pom
env:
GITHUB_TOKEN: ${{ github.token }}
SEMVER: ${{ needs.prepare.outputs.semVer }}
# - name: Upload Built framework jar
# env:
# GH_TOKEN: ${{ github.token }}
# GH_REPO: ${{ github.repository }}
# run: gh release upload "${{ needs.release.outputs.tag }}" "target/framework.jar"
# publish:
# name: Publish Release
# needs: [release, build]
# runs-on: ubuntu-latest
# steps:
# - name: Publish Release
# env:
# GH_TOKEN: ${{ github.token }}
# GH_REPO: ${{ github.repository }}
# run: gh release edit "${{ needs.release.outputs.tag }}" --draft=false
# - uses: eregon/keep-last-n-releases@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# n: 3
# remove_tags_without_release: true