-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Java CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
- name: Validate gradlew integrity | ||
uses: gradle/wrapper-validation-action@v1 | ||
- name: Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/build.gradle', '**/gradle-wrapper.properties') }} | ||
- name: Build with Gradle | ||
run: ./gradlew pmdMain build | ||
- name: PMD report | ||
uses: jwgmeligmeyling/pmd-github-action@v1 | ||
if: failure() | ||
with: | ||
path: '**/reports/pmd/main.xml' | ||
- name: Stop Gradle | ||
run: | | ||
./gradlew --stop | ||
- name: Calculate artifact names | ||
id: calculate_artifact_names | ||
run: | | ||
VERSION=$(awk -F '=' '/^version/ { print $2; }' build.properties) | ||
BUILD=$(awk -F '=' '/build_number/ { print $2; }' build.properties) | ||
echo "forge=build/libs/Zeta-${VERSION}-${BUILD}.jar" >> "$GITHUB_OUTPUT" | ||
- name: Sign jars | ||
env: | ||
SIGNING_KEY: ${{ secrets.VIOLET_MOON_SIGNING_KEY }} | ||
if: ${{ env.SIGNING_KEY != '' }} | ||
run: | | ||
echo "${SIGNING_KEY}" | gpg --import - | ||
gpg --local-user "Violet Moon Signing Key" --armor \ | ||
--detach-sign ${{ steps.calculate_artifact_names.outputs.forge }} | ||
- name: Archive Forge Artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Forge | ||
path: | | ||
${{ steps.calculate_artifact_names.outputs.forge }} | ||
${{ steps.calculate_artifact_names.outputs.forge }}.asc | ||
- name: Upload Releases | ||
if: startsWith(github.ref, 'refs/tags/release-') | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
GIT_REF: ${{ github.ref }} | ||
FORGE_JAR: ${{ steps.calculate_artifact_names.outputs.forge }} | ||
CURSEFORGE_TOKEN: ${{ secrets.VAZKII_CURSEFORGE_TOKEN }} | ||
MODRINTH_TOKEN: ${{ secrets.VAZKII_MODRINTH_TOKEN }} | ||
run: | | ||
scripts/upload_releases.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# Remove 'refs/tags/' from front | ||
TAGNAME="${GIT_REF/#refs\/tags\/}" | ||
|
||
# Remove 'release-' from front | ||
VERSION="${TAGNAME/#release-}" | ||
MC_VERSION=$(echo "${VERSION}" | cut -d '-' -f 1) | ||
|
||
function release_github() { | ||
echo >&2 'Creating GitHub Release' | ||
local GH_RELEASE_RESPONSE | ||
GH_RELEASE_RESPONSE="$(gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/repos/VazkiiMods/Zeta/releases \ | ||
-f tag_name="${TAGNAME}")" | ||
GH_RELEASE_PAGE=$(echo "$GH_RELEASE_RESPONSE" | jq -r .html_url) | ||
|
||
echo >&2 'Uploading Forge Jar and Signature to GitHub' | ||
gh release upload "${TAGNAME}" "${FORGE_JAR}#Forge Jar" | ||
gh release upload "${TAGNAME}" "${FORGE_JAR}.asc#Forge Signature" | ||
} | ||
|
||
function release_modrinth() { | ||
echo >&2 'Uploading Forge Jar to Modrinth' | ||
local MODRINTH_FORGE_SPEC | ||
MODRINTH_FORGE_SPEC=$(cat <<EOF | ||
{ | ||
"dependencies": [], | ||
"version_type": "release", | ||
"loaders": ["forge"], | ||
"featured": false, | ||
"project_id": "MVARlG2f", | ||
"file_parts": [ | ||
"jar" | ||
], | ||
"primary_file": "jar" | ||
} | ||
EOF | ||
) | ||
|
||
MODRINTH_FORGE_SPEC=$(echo "${MODRINTH_FORGE_SPEC}" | \ | ||
jq --arg name "${VERSION}" \ | ||
--arg mcver "${MC_VERSION}" \ | ||
--arg changelog "${GH_RELEASE_PAGE}" \ | ||
'.name=$ARGS.named.name | .version_number=$ARGS.named.name | .game_versions=[$ARGS.named.mcver] | .changelog=$ARGS.named.changelog') | ||
curl 'https://api.modrinth.com/v2/version' \ | ||
-H "Authorization: $MODRINTH_TOKEN" \ | ||
-F "data=$MODRINTH_FORGE_SPEC" \ | ||
-F "jar=@${FORGE_JAR}" # TODO modrinth doesn't allow asc files. Remember to readd "signature" to the spec when reenabling this. \ -F "signature=@${FORGE_JAR}.asc" | ||
} | ||
|
||
function release_curseforge() { | ||
# Java versions, Loaders, and Environment tags are actually "game versions" (lmfao), as are real game versions. | ||
|
||
# Hardcoded from https://minecraft.curseforge.com/api/game/version-types (which is undocumented, btw) | ||
# I'm not betting on these changing any time soon, so hardcoding is ok | ||
local CURSEFORGE_JAVA_VERSION=8326 # Java 17 | ||
local CURSEFORGE_FORGE_VERSION=7498 | ||
local CURSEFORGE_CLIENT_VERSION=9638 | ||
local CURSEFORGE_SERVER_VERSION=9639 | ||
# For the Minecraft one, don't hardcode so we don't have to remember to come change this every time. | ||
# Each game version seems to be duplicated three times: | ||
# Once with type ID 1 (unused?), once with its major-version-specific type ID, and once with the type ID for "Addons" 615 | ||
# We want the second one. Just dirtily pluck it out based on this. | ||
local CURSEFORGE_GAME_VERSION | ||
CURSEFORGE_GAME_VERSION=$(curl https://minecraft.curseforge.com/api/game/versions \ | ||
-H 'Accept: application/json' \ | ||
-H "X-Api-Token: ${CURSEFORGE_TOKEN}" | \ | ||
jq --arg mcver "${MC_VERSION}" \ | ||
'map(select(.name == $ARGS.named.mcver and .gameVersionTypeID != 1 and .gameVersionTypeID != 615)) | first | .id') | ||
|
||
echo >&2 'Uploading Forge Jar to CurseForge' | ||
local CURSEFORGE_FORGE_SPEC | ||
CURSEFORGE_FORGE_SPEC=$(cat <<EOF | ||
{ | ||
"changelogType": "text", | ||
"releaseType": "release" | ||
} | ||
EOF | ||
) | ||
|
||
local CURSEFORGE_FORGE_GAMEVERS="[\ | ||
$CURSEFORGE_JAVA_VERSION,\ | ||
$CURSEFORGE_CLIENT_VERSION,\ | ||
$CURSEFORGE_SERVER_VERSION,\ | ||
$CURSEFORGE_FORGE_VERSION,\ | ||
$CURSEFORGE_GAME_VERSION]" | ||
|
||
CURSEFORGE_FORGE_SPEC=$(echo "$CURSEFORGE_FORGE_SPEC" | \ | ||
jq --arg changelog "$GH_RELEASE_PAGE" \ | ||
--argjson gamevers "$CURSEFORGE_FORGE_GAMEVERS" \ | ||
'.gameVersions=$ARGS.named.gamevers | .changelog=$ARGS.named.changelog') | ||
curl 'https://minecraft.curseforge.com/api/projects/968868/upload-file' \ | ||
-H "X-Api-Token: $CURSEFORGE_TOKEN" \ | ||
-F "metadata=$CURSEFORGE_FORGE_SPEC" \ | ||
-F "file=@$FORGE_JAR" | ||
# TODO: Upload the asc as an 'Additional file' | ||
} | ||
|
||
release_github | ||
release_modrinth | ||
release_curseforge |