diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1fe83df..1817740 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,15 +1,10 @@ -name: Build DivineMC +name: DivineMC CI + on: - workflow_dispatch: - pull_request: push: branches: - - "ver/**" - -env: - version: '1.21.4' - branch: 'ver/1.21.4' - debug: 'false' + - "master" + workflow_dispatch: jobs: build: @@ -17,13 +12,13 @@ jobs: if: "!contains(github.event.commits[0].message, '[ci-skip]')" steps: - name: Setup Action - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Setup JDK 21 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: temurin java-version: 21 @@ -32,7 +27,6 @@ jobs: - name: Configure Git and Gradle run: | git config --global user.email "no-reply@github.com" && git config --global user.name "Github Actions" - echo "workflow=$GITHUB_RUN_NUMBER" >> $GITHUB_ENV echo "BUILD_NUMBER=$GITHUB_RUN_NUMBER" >> $GITHUB_ENV chmod +x gradlew @@ -46,29 +40,18 @@ jobs: continue-on-error: true run: ./gradlew publish -PdivinemcUsername=${{ secrets.REPO_USERNAME }} -PdivinemcPassword=${{ secrets.REPO_SECRET }} - - name: Upload Artifacts - if: env.debug == 'true' || github.ref_name != env.branch - uses: actions/upload-artifact@main - with: - name: DivineMC - path: divinemc-server/build/libs/divinemc-paperclip-*-mojmap.jar + - name: Get Release Info + run: bash scripts/releaseInfo.sh + env: + BUILD_NUMBER: ${{ env.BUILD_NUMBER }} - - name: Release Artifacts - if: github.ref_name == env.branch - uses: marvinpinto/action-automatic-releases@latest + - name: Create Release + uses: ncipollo/release-action@latest with: - title: "Release #${{ env.workflow }}" - automatic_release_tag: release-${{ env.workflow }} - repo_token: "${{ secrets.GITHUB_TOKEN }}" - files: divinemc-server/build/libs/divinemc-paperclip-*-mojmap.jar - prerelease: false - - - name: Release Artifacts (Latest) - if: github.ref_name == env.branch - uses: marvinpinto/action-automatic-releases@latest - with: - title: "Release #${{ env.workflow }}" - automatic_release_tag: latest-${{ env.version }} - repo_token: "${{ secrets.GITHUB_TOKEN }}" - files: divinemc-server/build/libs/divinemc-paperclip-*-mojmap.jar - prerelease: false + artifacts: ${{ env.jar }} + bodyFile: ${{ env.info }} + tag: ${{ env.tag }} + name: ${{ env.name }} + prerelease: ${{ env.experimental }} + token: ${{ secrets.GITHUB_TOKEN }} + makeLatest: ${{ env.make_latest }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1b6fe0b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: DivineMC Test CI + +on: + push: + branches-ignore: [ master ] + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + if: "!contains(github.event.commits[0].message, '[ci-skip]')" + steps: + - name: Setup Action + uses: actions/checkout@v4 + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Setup JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + cache: 'gradle' + + - name: Configure Git and Gradle + run: | + git config --global user.email "no-reply@github.com" && git config --global user.name "Github Actions" + echo "BUILD_NUMBER=$GITHUB_RUN_NUMBER" >> $GITHUB_ENV + chmod +x gradlew + + - name: Patch + run: ./gradlew applyAllPatches --stacktrace + + - name: Build Paperclip Jar + run: ./gradlew createMojmapPaperclipJar --stacktrace + + - name: Upload Artifacts + uses: actions/upload-artifact@main + with: + name: DivineMC + path: divinemc-server/build/libs/divinemc-paperclip-*-mojmap.jar diff --git a/.gitignore b/.gitignore index 76a44b5..87d7382 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ run /paper-api /purpur-api *.jar +changelog.md diff --git a/gradle.properties b/gradle.properties index 2dc2d31..fbad130 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,9 @@ group = space.bxteam.divinemc -mcVersion = 1.21.4 -version = 1.21.4-R0.1-SNAPSHOT -purpurRef = a9bcd9f0c8b66ad84f9ca6005d425902c9cd0442 +mcVersion=1.21.4 +version=1.21.4-R0.1-SNAPSHOT +purpurRef=a9bcd9f0c8b66ad84f9ca6005d425902c9cd0442 +experimental=false org.gradle.configuration-cache=true org.gradle.caching = true diff --git a/scripts/releaseInfo.sh b/scripts/releaseInfo.sh new file mode 100644 index 0000000..db04edf --- /dev/null +++ b/scripts/releaseInfo.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +sha256() { + sha256sum "$1" | awk '{print $1}' +} + +sha1() { + sha1sum "$1" | awk '{print $1}' +} + +md5() { + md5sum "$1" | awk '{print $1}' +} + +prop() { + grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//' +} + +commitid=$(git log --pretty='%h' -1) +mcversion=$(prop mcVersion) +version=$(prop version) +experimental=$(prop experimental) +tagid="$mcversion-$BUILD_NUMBER-$commitid" +jarName="divinemc-$mcversion-$BUILD_NUMBER.jar" +divinemcid="DivineMC-$tagid" +changelog="changelog.md" +make_latest=$([ "$experimental" = "true" ] && echo "false" || echo "true") + +rm -f $changelog + +mv divinemc-server/build/libs/divinemc-paperclip-"$version"-mojmap.jar "$jarName" +{ + echo "name=$divinemcid" + echo "tag=$tagid" + echo "jar=$jarName" + echo "info=$changelog" + echo "experimental=$experimental" + echo "make_latest=$make_latest" +} >> "$GITHUB_ENV" + +{ + echo "$divinemcid [![download](https://img.shields.io/github/downloads/DivineMC/DivineMC/$tagid/total?color=0)](https://github.com/DivineMC/DivineMC/releases/download/$tagid/$jarName)" + echo "=====" + echo "" + if [ "$experimental" = "true" ]; then + echo "> This is an early, experimental build. It is only recommended for usage on test servers and should be used with caution." + echo "> **Backups are mandatory!**" + echo "" + fi + echo "### Commits" +} >> $changelog + +number=$(git log --oneline master ^"$(git describe --tags --abbrev=0)" | wc -l) +git log --pretty='> [%h] %s' "-$number" >> $changelog + +{ + echo "" + echo "### Checksum" + echo "| File | $jarName |" + echo "| ---- | ---- |" + echo "| MD5 | $(md5 "$jarName") |" + echo "| SHA1 | $(sha1 "$jarName") |" + echo "| SHA256 | $(sha256 "$jarName") |" +} >> $changelog +