-
-
Notifications
You must be signed in to change notification settings - Fork 26
152 lines (149 loc) · 7.22 KB
/
ci.yaml
File metadata and controls
152 lines (149 loc) · 7.22 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
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
name: "build"
on:
push:
branches: "**"
tags-ignore: ["**"]
pull_request:
release:
types: [ released ]
concurrency:
group: "${{ github.workflow }}-${{ github.event.number || github.ref }}"
cancel-in-progress: true
jobs:
build:
# Only run on PRs if the source branch is on someone else's repo
if: "${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}"
strategy:
matrix:
os: ["ubuntu-latest"] # disable windows cuz it fails ONLY in GH actions and not locally
# os: ["ubuntu-latest", "windows-latest"]
runs-on: "${{ matrix.os }}"
steps:
- name: "setup env"
id: "setup"
uses: "KyoriPowered/ci-cookbook/actions/setup-java-env@f3b9a3fbb31e9f4320d855e7be17b028522e87be" # 2026.02.07
with:
runtime_version: 25
publishing_branch_regex: '(?:(?:(?:mc\/)?(\d+(?:\.\d+)*(?:\.x)?)))'
gradle_warning_mode: "all"
- name: "prime gradle build"
run: "./gradlew --no-daemon generateTemplates generateTestmodTemplates --stacktrace" # Bonk loom
- name: "run gradle build"
run: "./gradlew build --stacktrace"
- name: "archive test results"
if: "${{ always() }}"
uses: "actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f" # v7.0.0
with:
name: "${{ runner.os }}-test-results"
path: |
build/reports/
*/build/reports/
- name: "determine status"
shell: "bash"
run: |
VERSION="$(./gradlew properties | awk '/^version:/ { print $2; }')"
if [ "$(echo $VERSION | grep '\-SNAPSHOT')" ]; then
echo "STATUS=snapshot" >> $GITHUB_ENV
else
echo "STATUS=release" >> $GITHUB_ENV
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: "Cache test run data"
uses: "actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306" # v5.0.3
with:
path: |
testserver/libraries
testserver/versions
testserver/.fabric/server
testserver/world
key: testserver-${{ runner.os }}-${{ github.run_id }}
restore-keys: testserver-${{ runner.os }}-
- name: "Execute production test run"
shell: bash
run: |
echo "::group::Environment Setup"
pip install yq
mkdir -p testserver/mods
MC_VERSION="$(tomlq -r '.versions.minecraft' gradle/libs.versions.toml)"
LOADER_VERSION="$(tomlq -r '.versions.fabricLoader' gradle/libs.versions.toml)"
API_VERSION="$(tomlq -r '.versions.fabricApi' gradle/libs.versions.toml)"
# Download fabric server launch
curl https://meta.fabricmc.net/v2/versions/loader/$MC_VERSION/$LOADER_VERSION/0.11.0/server/jar -o testserver/fabric-server.jar
# eula=true
echo "eula=true" > testserver/eula.txt
# copy artifact into mods folder
cp fabric/build/libs/adventure-platform-fabric-$VERSION.jar testserver/mods/adventure-platform-fabric.jar
# copy API
API_URL=$(curl https://api.modrinth.com/v2/project/fabric-api/version | jq ". | map(select(.version_number == \"$API_VERSION\")) | .[0].files[0].url" -r)
echo "Downloading Fabric API from $API_URL"
curl -L "$API_URL" -o testserver/mods/fabric-api.jar
echo "::endgroup::" # Environment Setup
echo "::group::Server Execution"
pushd testserver/
java -Dadventure.testMode=true -jar fabric-server.jar nogui
if [[ -d "crash-reports" ]]; then
for i in crash-reports/*.txt; do
echo "::error title=Server crashed::$(cat $i)"
done
fi
popd
echo "::endgroup" # Server Execution
echo "# Server Execution" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat testserver/logs/latest.log >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
if [ ! -e "testserver/adventure-test-success.out" ]; then
echo "::error::Server did not exit successfully, see logs for details"
exit 1
fi
- name: "publish snapshot"
if: "${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && steps.setup.outputs.publishing_branch != '' }}"
run: "./gradlew publish"
env:
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.ADVENTURE_SONATYPE_USERNAME }}"
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.ADVENTURE_SONATYPE_PASSWORD }}"
- name: "publish release"
if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}"
run: "./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository"
env:
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.ADVENTURE_SONATYPE_USERNAME }}"
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.ADVENTURE_SONATYPE_PASSWORD }}"
ORG_GRADLE_PROJECT_kyoriSigningKey: "${{ secrets.ADVENTURE_GPG_KEY }}"
ORG_GRADLE_PROJECT_kyoriSigningPassword: "${{ secrets.ADVENTURE_GPG_PASSWORD }}"
- name: "publish release to modrinth"
if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}"
run: ./gradlew publishModrinth
env:
MODRINTH_TOKEN: "${{ secrets.PAPERMC_MODRINTH_TOKEN }}"
RELEASE_NOTES: "${{ github.event.release.body }}"
- name: "copy javadoc for publication"
if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}"
run: |
mkdir -p build/publish-jd/platform/
./gradlew copyJavadoc --output build/publish-jd/platform/
- name: "authenticate for javadoc publication"
if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}"
uses: "actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859" # v3.0.0
id: jd-token
with:
app-id: "${{ secrets.DEPLOYMENT_APP_ID }}"
private-key: "${{ secrets.DEPLOYMENT_APP_SECRET }}"
owner: "PaperMC"
repositories: "adventure-javadocs"
- name: "get JD app ID"
if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}"
id: "get-app-id"
run: 'echo "user-id=$(gh api "/users/${{ steps.jd-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"'
- name: "publish javadoc"
if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}"
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
with:
folder: build/publish-jd
repository-name: "PaperMC/adventure-javadocs"
token: ${{ steps.jd-token.outputs.token }}
branch: main
git-config-name: "${{ steps.jd-token.outputs.app-slug }}[bot]"
git-config-email: "${{ steps.get-app-id.outputs.user-id }}+${{ steps.jd-token.outputs.app-slug }}[bot]@users.noreply.github.com"
clean: false
force: false
commit-message: "Publishing javadoc for ${{ github.repository }} ${{ env.PROJECT_VERSION }}"