diff options
author | Linnea Gräf <nea@nea.moe> | 2024-04-12 14:32:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-12 14:32:41 +0200 |
commit | afd3f0f861ebe7f8957eb6abc6e19f92c7b5896a (patch) | |
tree | 0e7990ed1e7083dd4da5f90a842d0122919f8c7c /.github | |
parent | a4a1c15a0b0de01e862c0f11882b45fee2c0cca7 (diff) | |
download | NotEnoughUpdates-afd3f0f861ebe7f8957eb6abc6e19f92c7b5896a.tar.gz NotEnoughUpdates-afd3f0f861ebe7f8957eb6abc6e19f92c7b5896a.tar.bz2 NotEnoughUpdates-afd3f0f861ebe7f8957eb6abc6e19f92c7b5896a.zip |
Add in-game updater (#1050)
Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com>
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/build.yml | 2 | ||||
-rw-r--r-- | .github/workflows/publish.yml | 34 | ||||
-rw-r--r-- | .github/workflows/push-to-modrinth.yaml | 28 | ||||
-rwxr-xr-x | .github/workflows/send_webhook_update.sh | 4 | ||||
-rwxr-xr-x | .github/workflows/upload-release.sh | 43 |
5 files changed, 108 insertions, 3 deletions
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 <https://www.gnu.org/licenses/>. +# + +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 <<EOF +Modrinth download: TBD + +Do **NOT** trust any mod just because they publish a checksum associated with it. These check sums are meant to verify only that two files are identical. They are not a certificate of origin, or a guarantee for the author of these files. + +sha256sum: \`$(sha256sum "$TARGET_NAME"|cut -f 1 -d ' '| tr -d '\n')\` +md5sum: \`$(md5sum "$TARGET_NAME"|cut -f 1 -d ' '| tr -d '\n')\` + +EOF + +preReleaseParam="" +if echo "$GITHUB_REF_NAME" | grep -E '.*\.0'>/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" + |