From 9a14aaa9dc9346f7eb2948b6364f00e6109a96aa Mon Sep 17 00:00:00 2001 From: Derek Date: Fri, 11 Apr 2025 22:25:51 +0000 Subject: [PATCH] Add .forgejo/workflows/test.yml --- .forgejo/workflows/test.yml | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .forgejo/workflows/test.yml diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml new file mode 100644 index 0000000..66f8c6f --- /dev/null +++ b/.forgejo/workflows/test.yml @@ -0,0 +1,93 @@ +name: Release tagged build + +on: + workflow_call: + secrets: + MAVEN_USER: + required: false + MAVEN_PASSWORD: + required: false + CURSEFORGE_TOKEN: + required: false + MODRINTH_TOKEN: + required: false + inputs: + workspace: + description: 'setupCIWorkspace/setupDecompWorkspace' + required: false + default: "setupCIWorkspace" + type: string + workflow_dispatch: + inputs: + workspace: + description: 'setupCIWorkspace/setupDecompWorkspace' + required: false + default: "setupCIWorkspace" + type: string + +jobs: + build: + runs-on: ubuntu-24.04 + env: + VERSION: ${{ github.ref_name }} + RELEASE_VERSION: ${{ github.ref_name }} + SNAPSHOT: ${{ endsWith(github.ref_name, '-snapshot') || contains(github.event.head_commit.message, '[snapshot]') }} + MAVEN_PUBLISHING_URL: ${{ vars.MAVEN_PUBLISHING_URL || 'https://nexus.gtnewhorizons.com/repository/releases/' }} + steps: + - name: Checkout mod repo + uses: actions/checkout@v4 + with: + fetch-depth: 32 + + - name: Set up JDK versions + uses: https://github.com/actions/setup-java@v4 + with: + java-version: | + 8 + 17 + 21 + distribution: 'zulu' + + - name: Setup Gradle + uses: https://github.com/gradle/gradle-build-action@v2 + with: + build-scan-publish: true + build-scan-terms-of-use-url: "https://gradle.com/terms-of-service" + build-scan-terms-of-use-agree: "yes" + validate-wrappers: true + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew --build-cache --info --stacktrace -PmavenPublishUrl='${{ env.MAVEN_PUBLISHING_URL }}' ${{ inputs.workspace }} + + - name: Build the mod + run: ./gradlew --build-cache --info --stacktrace -PmavenPublishUrl='${{ env.MAVEN_PUBLISHING_URL }}' assemble + + # Continue on error in the following steps to make sure releases still get made even if one of the methods fails + + - name: Delete old release if it already exists + run: gh release delete --yes "${RELEASE_VERSION}" + continue-on-error: true + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + + - name: Release under current tag + run: | + PRERELEASE="" + if [[ "$SNAPSHOT" == "true" ]]; then + PRERELEASE="--prerelease" + fi + export "CHANGELOG_FILE=$(mktemp --suffix=.md)" + echo "CHANGELOG_FILE=${CHANGELOG_FILE}" >> $GITHUB_ENV + gh api --method POST -H "Accept: application/vnd.github+json" \ + "/repos/${GITHUB_REPOSITORY}/releases/generate-notes" \ + -f tag_name="${RELEASE_VERSION}" \ + --jq ".body" > "${CHANGELOG_FILE}" + cat "${CHANGELOG_FILE}" + gh release create "${RELEASE_VERSION}" -F "${CHANGELOG_FILE}" $PRERELEASE ./build/libs/*.jar + shell: bash + continue-on-error: true + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} \ No newline at end of file