Skip to content

Commit

Permalink
update actions & scrips
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Oct 23, 2024
1 parent 34aaafe commit ac96468
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 62 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
- name: Validate gradlew integrity
uses: gradle/wrapper-validation-action@v1
uses: gradle/actions/wrapper-validation@v3
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand All @@ -35,28 +35,28 @@ jobs:
run: |
VERSION=$(awk -F '=' '/^version/ { print $2; }' build.properties)
BUILD=$(awk -F '=' '/build_number/ { print $2; }' build.properties)
echo "forge=build/libs/Morph-o-Tool-${VERSION}-${BUILD}.jar" >> "$GITHUB_OUTPUT"
echo "neoforge=build/libs/Morph-o-Tool-${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
--detach-sign ${{ steps.calculate_artifact_names.outputs.neoforge }}
- name: Archive NeoForge Artifacts
uses: actions/upload-artifact@v4
with:
name: Forge
name: NeoForge
path: |
${{ steps.calculate_artifact_names.outputs.forge }}
${{ steps.calculate_artifact_names.outputs.forge }}.asc
${{ steps.calculate_artifact_names.outputs.neoforge }}
${{ steps.calculate_artifact_names.outputs.neoforge }}.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 }}
NEOFORGE_JAR: ${{ steps.calculate_artifact_names.outputs.neoforge }}
CURSEFORGE_TOKEN: ${{ secrets.VAZKII_CURSEFORGE_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.VAZKII_MODRINTH_TOKEN }}
run: |
Expand Down
58 changes: 30 additions & 28 deletions push_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,36 @@
import re
from jproperties import Properties


def main():
build = Properties()
with open('build.properties', 'rb') as f:
build.load(f , "utf-8")

mc_version, mcv_meta = build['mc_version']
version, v_meta = build['version']
build_number, bn_meta = build['build_number']

print('MC Version:', mc_version)
print('Version:', version)
print('Build Number', build_number)

changelog = '-m "Changelog:" '
with open('changelog.txt', 'r') as f:
content = f.read()

content = content.replace('"', '\'');
changelog = changelog + re.sub(r'(- .+)\n?', '-m "\g<1>" ', content)

os.system('git tag -a release-{}-{}-{} {}'.format(mc_version, version, build_number, changelog))

build['build_number'] = str(int(build_number) + 1)
with open("build.properties", "wb") as f:
build.store(f, encoding="utf-8")

os.system('git commit -a -m build')
os.system('git push origin master release-{}-{}-{}'.format(mc_version, version, build_number))
build = Properties()
with open('build.properties', 'rb') as f:
build.load(f, "utf-8")

mc_version, mcv_meta = build['mc_version']
version, v_meta = build['version']
build_number, bn_meta = build['build_number']

print('MC Version:', mc_version)
print('Version:', version)
print('Build Number', build_number)

changelog = '-m "Changelog:" '
with open('changelog.txt', 'r') as f:
content = f.read()

content = content.replace('"', '\'');
changelog = changelog + re.sub(r'(- .+)\n?', '-m "\g<1>" ', content)

os.system('git tag -a release-{}-{}-{} {}'.format(mc_version, version, build_number, changelog))

build['build_number'] = str(int(build_number) + 1)
with open("build.properties", "wb") as f:
build.store(f, encoding="utf-8")

os.system('git commit -a -m build')
os.system('git push origin master release-{}-{}-{}'.format(mc_version, version, build_number))


if __name__ == '__main__':
main()
main()
42 changes: 21 additions & 21 deletions scripts/upload_releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ function release_github() {
-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"
echo >&2 'Uploading NeoForge Jar and Signature to GitHub'
gh release upload "${TAGNAME}" "${NEOFORGE_JAR}#NeoForge Jar"
gh release upload "${TAGNAME}" "${NEOFORGE_JAR}.asc#NeoForge Signature"
}

function release_modrinth() {
echo >&2 'Uploading Forge Jar to Modrinth'
local MODRINTH_FORGE_SPEC
MODRINTH_FORGE_SPEC=$(cat <<EOF
echo >&2 'Uploading NeoForge Jar to Modrinth'
local MODRINTH_NEOFORGE_SPEC
MODRINTH_NEOFORGE_SPEC=$(cat <<EOF
{
"dependencies": [],
"version_type": "release",
"loaders": ["forge"],
"loaders": ["neoforge"],
"featured": false,
"project_id": "rtbzFq0N",
"file_parts": [
Expand All @@ -42,24 +42,24 @@ function release_modrinth() {
EOF
)

MODRINTH_FORGE_SPEC=$(echo "${MODRINTH_FORGE_SPEC}" | \
MODRINTH_NEOFORGE_SPEC=$(echo "${MODRINTH_NEOFORGE_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"
-F "data=$MODRINTH_NEOFORGE_SPEC" \
-F "jar=@${NEOFORGE_JAR}" # TODO modrinth doesn't allow asc files. Remember to readd "signature" to the spec when reenabling this. \ -F "signature=@${NEOFORGE_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_JAVA_VERSION=11135 # Java 21
local CURSEFORGE_NEOFORGE_VERSION=10150
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.
Expand All @@ -73,31 +73,31 @@ function release_curseforge() {
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
echo >&2 'Uploading NeoForge Jar to CurseForge'
local CURSEFORGE_NEOFORGE_SPEC
CURSEFORGE_NEOFORGE_SPEC=$(cat <<EOF
{
"changelogType": "text",
"releaseType": "release"
}
EOF
)

local CURSEFORGE_FORGE_GAMEVERS="[\
local CURSEFORGE_NEOFORGE_GAMEVERS="[\
$CURSEFORGE_JAVA_VERSION,\
$CURSEFORGE_CLIENT_VERSION,\
$CURSEFORGE_SERVER_VERSION,\
$CURSEFORGE_FORGE_VERSION,\
$CURSEFORGE_NEOFORGE_VERSION,\
$CURSEFORGE_GAME_VERSION]"

CURSEFORGE_FORGE_SPEC=$(echo "$CURSEFORGE_FORGE_SPEC" | \
CURSEFORGE_NEOFORGE_SPEC=$(echo "$CURSEFORGE_NEOFORGE_SPEC" | \
jq --arg changelog "$GH_RELEASE_PAGE" \
--argjson gamevers "$CURSEFORGE_FORGE_GAMEVERS" \
--argjson gamevers "$CURSEFORGE_NEOFORGE_GAMEVERS" \
'.gameVersions=$ARGS.named.gamevers | .changelog=$ARGS.named.changelog')
curl 'https://minecraft.curseforge.com/api/projects/245287/upload-file' \
-H "X-Api-Token: $CURSEFORGE_TOKEN" \
-F "metadata=$CURSEFORGE_FORGE_SPEC" \
-F "file=@$FORGE_JAR"
-F "metadata=$CURSEFORGE_NEOFORGE_SPEC" \
-F "file=@$NEOFORGE_JAR"
# TODO: Upload the asc as an 'Additional file'
}

Expand Down

0 comments on commit ac96468

Please sign in to comment.