Repository navigation
156 lines (136 loc) · 6.6 KB
/
Copy pathbuild.yml
File metadata and controls
156 lines (136 loc) · 6.6 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
153
154
155
156
name: build
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
# A release is created here, and the tag on it is what records that this
# version has been published.
contents: write
steps:
- uses: actions/checkout@v7
with:
# The publish gate asks the remote whether this version's tag
# already exists, so the checkout needs to be a real clone.
fetch-depth: 0
# Checked out inside this one rather than beside it: the address
# generator takes a path, and a nested clone is one less path to get
# wrong in a job that has no workspace around it.
- uses: actions/checkout@v7
with:
repository: ancaria-dev/mappings
path: mappings
# The registry is generated from its own text file; a stale JSON here
# would silently give every hook the wrong address.
- name: Check the registry is current
working-directory: mappings
run: python mappings.generator.py --check
- name: Generate the address table
run: python tools/addr.py mappings
# The agent decides at attach whether the module it is looking at is the
# binary these addresses were found in. That check is only ever exercised
# by somebody with the wrong game, so it is exercised here instead:
# gen/addr.js and agent/signatures.json against a fake process.
- name: Check the agent notices the wrong game build
run: node tests/buildcheck.js
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '21'
- uses: gradle/actions/setup-gradle@v5
- run: ./gradlew build --no-daemon
- name: Version and whether it is new
id: gate
shell: bash
run: |
version=$(grep -E "^version=" gradle.properties | cut -d= -f2)
echo "version=$version" >> "$GITHUB_OUTPUT"
if git ls-remote --exit-code --tags origin "refs/tags/v$version" >/dev/null 2>&1; then
echo "publish=false" >> "$GITHUB_OUTPUT"
echo "v$version is already published; nothing to do"
else
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "v$version is new"
fi
# What the launcher downloads when it is built without this checkout
# beside it. The address table is inside, already generated.
- name: Pack the release assets
if: steps.gate.outputs.publish == 'true' && github.ref == 'refs/heads/master'
run: |
mkdir -p release
v=${{ steps.gate.outputs.version }}
cp "api/build/libs/api-$v.jar" release/api.jar
cp "zygote/build/libs/zygote-$v.jar" release/zygote.jar
(cd agent/src && zip -r ../../release/agent.zip .)
- uses: actions/upload-artifact@v7
with:
name: jars
path: '*/build/libs/*.jar'
# One signed bundle over the Portal API, not a repository deploy. The
# upload lands as a deployment awaiting release, because publishingType
# in build.gradle.kts is USER_MANAGED: a Central artifact can never be
# deleted, so the first ones are worth a look before they are permanent.
- name: Upload to Maven Central
if: steps.gate.outputs.publish == 'true' && github.ref == 'refs/heads/master'
run: ./gradlew nmcpPublishAggregationToCentralPortal --no-daemon
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
# Creates the tag as well, which is what the gate above reads next time.
- name: Release
if: steps.gate.outputs.publish == 'true' && github.ref == 'refs/heads/master'
uses: softprops/action-gh-release@v3
with:
tag_name: v${{ steps.gate.outputs.version }}
files: release/*
# The API contract major is the same number in three repositories that cannot
# import each other. Raising one and forgetting the others makes the Gradle
# plugin stamp mods with a major the loader then refuses, which is the exact
# failure the contract exists to prevent, one floor up. Coderpack owns the
# number, so the check that they still agree lives here.
api-contract:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
# Not `build`: that is where Gradle puts its output in this repository.
# `ref` is pinned rather than left to default: actions/checkout resolves
# an unspecified ref on an external repo to whatever GitHub reports as
# its default branch, and an empty repository reports the placeholder
# `main` even though every ancaria-dev repository publishes to `master`.
# Pushing coderpack before a sibling has any commits at all then fails
# this checkout with "couldn't find remote ref refs/heads/main" instead
# of a clear ordering error.
- uses: actions/checkout@v7
with:
repository: ancaria-dev/build
path: plugin
ref: master
- uses: actions/checkout@v7
with:
repository: ancaria-dev/launcher
path: launcher
ref: master
# `|| true` because the step runs under `bash -eo pipefail`: a grep that
# finds nothing would end the job on the spot, and the whole point is to
# print which of the three could not be read.
- name: The three API majors agree
shell: bash
run: |
api=$(grep -oE 'VERSION = [0-9]+' api/src/main/java/dev/ancaria/coderpack/api/Api.java | grep -oE '[0-9]+' || true)
plugin=$(grep -oE 'String API = "[0-9]+"' plugin/verify/src/main/java/dev/ancaria/coderpack/verify/Verifier.java | grep -oE '[0-9]+' || true)
launcher=$(grep -oE 'const API = "[0-9]+"' launcher/mods/mods.go | grep -oE '[0-9]+' || true)
echo "coderpack Api.VERSION = ${api:-not found}"
echo "build Verifier.API = ${plugin:-not found}"
echo "launcher mods.API = ${launcher:-not found}"
if [ -n "$api" ] && [ "$api" = "$plugin" ] && [ "$api" = "$launcher" ]; then
echo "the API contract is $api in all three"
exit 0
fi
echo "::error::the API contract major does not agree across the three repositories. Raising it is one edit in each: Api.VERSION here, Verifier.API in the build repository, mods.API in the launcher. A value shown as 'not found' means the constant moved or was renamed, and this check has to move with it."
exit 1