-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripts for automatic release uploading
- Loading branch information
1 parent
debbfe3
commit 19508f5
Showing
2 changed files
with
183 additions
and
1 deletion.
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
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,173 @@ | ||
#!/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/Neat/releases \ | ||
-F prerelease=true \ | ||
-f tag_name="${TAGNAME}")" | ||
GH_RELEASE_PAGE=$(echo "$GH_RELEASE_RESPONSE" | jq -r .html_url) | ||
|
||
echo >&2 'Uploading Fabric Jar and Signature to GitHub' | ||
gh release upload "${TAGNAME}" "${FABRIC_JAR}#Fabric Jar" | ||
gh release upload "${TAGNAME}" "${FABRIC_JAR}.asc#Fabric Signature" | ||
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 Fabric Jar to Modrinth' | ||
local MODRINTH_FABRIC_SPEC | ||
MODRINTH_FABRIC_SPEC=$(cat <<EOF | ||
{ | ||
"dependencies": [ | ||
{ | ||
"project_id": "P7dR8mSH", | ||
"dependency_type": "required" | ||
} | ||
], | ||
"version_type": "alpha", | ||
"loaders": ["fabric"], | ||
"featured": false, | ||
"project_id": "Ins7SzzR", | ||
"file_parts": [ | ||
"jar" | ||
], | ||
"primary_file": "jar" | ||
} | ||
EOF | ||
) | ||
|
||
MODRINTH_FABRIC_SPEC=$(echo "${MODRINTH_FABRIC_SPEC}" | \ | ||
jq --arg name "${VERSION}-fabric" \ | ||
--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_FABRIC_SPEC" \ | ||
-F "jar=@${FABRIC_JAR}" # TODO modrinth doesn't allow asc files. Remember to readd "signature" to the spec when reenabling this. \ -F "signature=@${FABRIC_JAR}.asc" | ||
|
||
echo >&2 'Uploading Forge Jar to Modrinth' | ||
local MODRINTH_FORGE_SPEC | ||
MODRINTH_FORGE_SPEC=$(cat <<EOF | ||
{ | ||
"dependencies": [], | ||
"version_type": "alpha", | ||
"loaders": ["forge"], | ||
"featured": false, | ||
"project_id": "Ins7SzzR", | ||
"file_parts": [ | ||
"jar" | ||
], | ||
"primary_file": "jar" | ||
} | ||
EOF | ||
) | ||
|
||
MODRINTH_FORGE_SPEC=$(echo "${MODRINTH_FORGE_SPEC}" | \ | ||
jq --arg name "${VERSION}-forge" \ | ||
--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_FABRIC_VERSION=7499 | ||
local CURSEFORGE_FORGE_VERSION=7498 | ||
local CURSEFORGE_CLIENT_VERSION=9638 | ||
# 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 Fabric Jar to CurseForge' | ||
local CURSEFORGE_FABRIC_SPEC | ||
CURSEFORGE_FABRIC_SPEC=$(cat <<EOF | ||
{ | ||
"changelogType": "text", | ||
"releaseType": "release", | ||
"relations": { | ||
"projects": [ | ||
{ | ||
"slug": "fabric-api", | ||
"type": "requiredDependency" | ||
} | ||
] | ||
} | ||
} | ||
EOF | ||
) | ||
|
||
local CURSEFORGE_FABRIC_GAMEVERS="[\ | ||
$CURSEFORGE_JAVA_VERSION,\ | ||
$CURSEFORGE_CLIENT_VERSION,\ | ||
$CURSEFORGE_FABRIC_VERSION,\ | ||
$CURSEFORGE_GAME_VERSION]" | ||
|
||
CURSEFORGE_FABRIC_SPEC=$(echo "$CURSEFORGE_FABRIC_SPEC" | \ | ||
jq --arg changelog "$GH_RELEASE_PAGE" \ | ||
--argjson gamevers "$CURSEFORGE_FABRIC_GAMEVERS" \ | ||
'.gameVersions=$ARGS.named.gamevers | .changelog=$ARGS.named.changelog') | ||
curl 'https://minecraft.curseforge.com/api/projects/639987/upload-file' \ | ||
-H "X-Api-Token: $CURSEFORGE_TOKEN" \ | ||
-F "metadata=$CURSEFORGE_FABRIC_SPEC" \ | ||
-F "file=@$FABRIC_JAR" | ||
|
||
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_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/238372/upload-file' \ | ||
-H "X-Api-Token: $CURSEFORGE_TOKEN" \ | ||
-F "metadata=$CURSEFORGE_FORGE_SPEC" \ | ||
-F "file=@$FORGE_JAR" | ||
} | ||
|
||
release_github | ||
release_modrinth | ||
release_curseforge |