chore(deps): Update gradle and github actions #573
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "build" | |
on: | |
push: | |
branches: "**" | |
tags-ignore: ["**"] | |
pull_request: | |
concurrency: | |
group: "${{ github.workflow }}-${{ github.event.number || github.ref }}" | |
cancel-in-progress: true | |
env: | |
RUNTIME_VERSION: 17 | |
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", "windows-latest"] | |
runs-on: "${{ matrix.os }}" | |
steps: | |
- name: "checkout repository" | |
uses: "actions/checkout@v3" | |
with: | |
fetch-depth: 0 | |
- name: "setup jdk ${{ env.RUNTIME_VERSION }}" | |
uses: "actions/setup-java@v3" | |
with: | |
distribution: "temurin" | |
java-version: "${{ env.RUNTIME_VERSION }}" | |
- name: "prime gradle build" | |
uses: "gradle/gradle-build-action@v2" | |
with: | |
cache-read-only: "${{ !startsWith(github.ref, 'refs/heads/mc/') || github.event_name == 'pull_request' }}" | |
arguments: "generateTemplates generateTestmodTemplates --stacktrace" # Bonk loom | |
- name: "run gradle build" | |
run: "./gradlew build --stacktrace" | |
- name: "Archive test results" | |
if: "${{ always() }}" | |
uses: "actions/upload-artifact@v3" | |
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@v3" | |
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 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" | |
if: "${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/mc/')) }}" | |
run: "./gradlew publish" | |
env: | |
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" | |
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" |