From afd3f0f861ebe7f8957eb6abc6e19f92c7b5896a Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Fri, 12 Apr 2024 14:32:41 +0200 Subject: Add in-game updater (#1050) Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/publish.yml | 34 +++++++++++++++++++++++++ .github/workflows/push-to-modrinth.yaml | 28 +++++++++++++++++++++ .github/workflows/send_webhook_update.sh | 4 +-- .github/workflows/upload-release.sh | 43 ++++++++++++++++++++++++++++++++ 5 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/push-to-modrinth.yaml create mode 100755 .github/workflows/upload-release.sh (limited to '.github') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cb85ac0..8242eef3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: run: ./gradlew clean test remapJar --no-daemon - uses: actions/upload-artifact@v3 with: - path: build/libs/*-dep.jar + path: build/libs/*.jar - name: Update discord notification if: ${{ env.WEBHOOK_URL && success() }} run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..de01458a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Pre-Publish + +on: + push: + tags: + - "*" + +jobs: + build: + env: + GIT_URL: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: temurin + - name: Set up gradle cache + uses: gradle/gradle-build-action@v2 + - name: Build with Gradle + run: ./gradlew clean test includeBackupRepo remapJar --no-daemon + env: + NEU_RELEASE: true + - uses: actions/upload-artifact@v3 + with: + path: build/libs/*.jar + - run: ./.github/workflows/upload-release.sh + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/push-to-modrinth.yaml b/.github/workflows/push-to-modrinth.yaml new file mode 100644 index 00000000..930ca13c --- /dev/null +++ b/.github/workflows/push-to-modrinth.yaml @@ -0,0 +1,28 @@ +on: + release: + types: + - published + +jobs: + upload-to-modrinth: + runs-on: ubuntu-latest + steps: + - uses: dsaltares/fetch-gh-release-asset@master + with: + version: ${{ release.id }} + regex: true + file: "*.jar" + token: ${{ secrets.GITHUB_TOKEN }} + - run: | + printf %s "$CHANGELOG" > CHANGELOG.md + env: + CHANGELOG: ${{ release.body }} + - uses: Kir-Antipov/mc-publish@v3.3 + with: + modrinth-id: GGamhqbw + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + files: "*.jar" + loaders: forge + game-versions: 1.8.9 + version: ${{ release.tag_name }} + # TODO: version-type: release diff --git a/.github/workflows/send_webhook_update.sh b/.github/workflows/send_webhook_update.sh index 7a6f932d..6111b53d 100755 --- a/.github/workflows/send_webhook_update.sh +++ b/.github/workflows/send_webhook_update.sh @@ -35,8 +35,8 @@ case "$STATUS" in SUCCESS) color="$COLOR_SUCCESS" status_message="Build succeeded." - to_upload=$(echo build/libs/*-dep.jar) - upload_name=NotEnoughUpdates-beta-dep.jar + to_upload=$(echo build/libs/*.jar) + upload_name=NotEnoughUpdates-beta.jar ;; esac diff --git a/.github/workflows/upload-release.sh b/.github/workflows/upload-release.sh new file mode 100755 index 00000000..2cbca693 --- /dev/null +++ b/.github/workflows/upload-release.sh @@ -0,0 +1,43 @@ +# +# Copyright (C) 2024 NotEnoughUpdates contributors +# +# This file is part of NotEnoughUpdates. +# +# NotEnoughUpdates is free software: you can redistribute it +# and/or modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation, either +# version 3 of the License, or (at your option) any later version. +# +# NotEnoughUpdates is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with NotEnoughUpdates. If not, see . +# + +last_tag="$(git log --pretty='%H %D'|grep -oE 'tag: [^ ]+'|sed -E 's/tag: ([^ ,]+),?/\1/'|head -2|tail -1)" +echo "Generating notes from $last_tag" +TARGET_NAME="build/libs/NotEnoughUpdates-$GITHUB_REF_NAME.jar" +mv build/libs/*.jar "$TARGET_NAME" + +read -r -d '' extra_notes </dev/null; then + preReleaseParam="--prerelease" +fi + +gh release create -t "NotEnoughUpdates $GITHUB_REF_NAME" --verify-tag "$GITHUB_REF_NAME" --generate-notes \ + --draft --notes-start-tag "$last_tag" $preReleaseParam \ + --notes "$extra_notes" "$TARGET_NAME" + -- cgit