-
-
Notifications
You must be signed in to change notification settings - Fork 14
207 lines (204 loc) · 7.18 KB
/
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Server builds
on:
push:
branches:
- '**'
tags:
- '**'
pull_request:
branches:
- '**'
workflow_dispatch:
jobs:
create-release:
needs: test
runs-on: ubuntu-latest
if: ${{ 'refs/heads/1.20.1' == github.ref || 'refs/heads/1.20.2' == github.ref || 'refs/heads/1.20.4' == github.ref}}
#This permission is needed to push a release (and/or tags)
permissions:
contents: write #nessesary for tag creation and release creation
actions: write #nessesary for cache deletion
packages: write #packages write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Cache .gradle
uses: burrunan/gradle-cache-action@v1
with:
# Enable concurrent cache save and restore
# Default is concurrent=false for better log readability
concurrent: true
# Disable caching of $HOME/.gradle/caches/*.*/generated-gradle-jars
save-generated-gradle-jars: false
# Disable publishing Gradle Build Scan URL to job report
gradle-build-scan-report: false
- name: Restore Project Sources for faster setup
uses: actions/cache/restore@v3
with:
path: |
projects/
key: project-src-cache-sha-${{ github.ref }}-${{ github.sha }}
restore-keys: project-src-cache-
- name: Setup Gradle
uses: gradle/[email protected]
- name: Get Version Name
id: version_name
run: |
echo version=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Rename and move artifacts
run: |
for dir in artifacts/*/
do
dir=${dir%*/} # remove the trailing "/"
for file in $dir/*
do
echo "moving $file one folder higher"
mv $file artifacts/
done
rm -r "${dir}"
done
for archive in artifacts/*.tar.*
do
tar -xvf $archive -C artifacts
rm $archive
done
#PLEASE ALWAYS regen library hashes!!!
rm -f projects/ketting/build/ketting_libraries.txt
- name: Publish Ketting
run: ./gradlew setup forge:checkJarCompatibility publish
env:
KETTINGUSERNAME: ${{ secrets.KETTINGUSERNAME }}
KETTINGPASSWORD: ${{ secrets.KETTINGPASSWORD }}
VERSION: ${{ steps.version_name.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag repo
id: tag
run: bash .github/workflows/tagging.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Github Release if on default branch
if: false
# if: ${{ format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }}
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
gh release create "$TAG" artifacts/* \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${TAG#v}" \
--generate-notes
- name: Delete Project Sources for build
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH=${{ github.ref }}
echo "Deleting caches..."
## Setting this to not fail the workflow while deleting cache keys.
#set +e
gh actions-cache delete project-src-cache-${{ github.ref }}-${{ github.sha }} -R $REPO -B $BRANCH --confirm
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get Version Name
id: version_name
run: |
echo version=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT
- name: Rename Branch, if Pull_Request
if: ${{ github.event_name == 'pull_request' }}
run: git checkout -B 'branch'
- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Cache .gradle
uses: burrunan/gradle-cache-action@v1
with:
# Enable concurrent cache save and restore
# Default is concurrent=false for better log readability
concurrent: true
# Disable caching of $HOME/.gradle/caches/*.*/generated-gradle-jars
save-generated-gradle-jars: false
# Disable publishing Gradle Build Scan URL to job report
gradle-build-scan-report: false
- name: Restore Project Sources for faster setup
id: cache_projects-src_restore
uses: actions/cache/restore@v3
with:
path: |
projects/
key: project-src-cache-${{ hashFiles('patches/**', 'src/main/resources/META-INF/accesstransformer.cfg') }}
restore-keys: |
project-src-cache-
- name: Delete old jar's
run: rm -f */*/build/libs/*.jar
- name: Rename Branch, if Pull_Request
if: ${{ github.event_name == 'pull_request' }}
run: git checkout -B 'branch'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Setup Ketting, Check Setup Ketting & Generate KettingJar
run: ./gradlew setup build kettingJar
env:
VERSION: ${{ steps.version_name.outputs.version }}
- name: Put ketting jar in an archive
working-directory: projects/ketting/build/libs
run: |
tar -czf ketting.tar.gz ketting*.jar
mv ketting.tar.gz ../../../../
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: ketting-server
path: |
ketting.tar.gz
- name: Save Project Sources
if: steps.cache_projects-src_restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: |
projects/
key: ${{ steps.cache_projects-src_restore.outputs.cache-primary-key }}
- name: Save Project Sources for publish
if: github.ref_type == 'tag'
uses: actions/cache/save@v3
with:
path: |
projects/
key: project-src-cache-sha-${{ github.ref }}-${{ github.sha }}
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: ketting-server
path: .
- name: Extract Ketting-Server
run: |
tar -xvf ketting.tar.gz
- name: Test Simple Server Start&Stop
timeout-minutes: 10
run: echo "stop" | java -Dforge.enableGameTest=true -jar ketting*.jar -dau -accepteula