diff --git a/.github/workflows/build_1_20_4.yml b/.github/workflows/build_1_20_4.yml index e427438..577145a 100644 --- a/.github/workflows/build_1_20_4.yml +++ b/.github/workflows/build_1_20_4.yml @@ -37,7 +37,7 @@ jobs: - name: Build project to paperclip jar uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 with: - arguments: createReobfPaperclipJar + arguments: createReobfBundlerJar createReobfPaperclipJar - name: Capture build artifacts uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/build_1_20_4_v2.yml b/.github/workflows/build_1_20_4_v2.yml new file mode 100644 index 0000000..e401e30 --- /dev/null +++ b/.github/workflows/build_1_20_4_v2.yml @@ -0,0 +1,74 @@ +name: Luminol CI v2 - Ver/1.20.4 + +on: + # push: + # branches: [ "ver/1.20.4" ] + # pull_request: + # branches: [ "ver/1.20.4" ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Git Repository + uses: actions/checkout@v3 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + - name: Setup Git Config + run: | + git config --global user.email "ci@luminolmc.com" + git config --global user.name "Luminol CI" + - name: Apply Patches + run: ./gradlew applyPatches + - name: Build + run: ./gradlew createReobfBundlerJar createReobfPaperclipJar + - uses: "actions/upload-artifact@v3" + with: + name: "Luminol CI Artifacts" + path: "build/libs/*.jar" + - name: Get version from asset + id: get_version + run: echo "::set-output name=version::$(echo build/libs/*.jar | grep -oP 'bundler-\K\d+\.\d+\.\d+' | head -1)" + - name: Set outputs + id: short_sha + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - name: Set env + run: echo "tag=${{ steps.get_version.outputs.version }}-${{ steps.short_sha.outputs.sha_short }}" >> $GITHUB_ENV + - name: Rename jar file + run: | + mv build/libs/luminol-bundler-1.20.4-R0.1-SNAPSHOT-reobf.jar build/libs/luminol-1.20.4-bundler.jar + mv build/libs/luminol-paperclip-1.20.4-R0.1-SNAPSHOT-reobf.jar build/libs/luminol-1.20.4-paperclip.jar + - name: Get Release Info + run: sh scripts/Get&SetENV.sh + - name: Create Release + if: github.event.commits[0].message != '[release-skip]' + uses: ncipollo/release-action@v1.12.0 + with: + tag: ${{ env.tag }} + name: Luminol ${{ steps.get_version.outputs.version }} - ${{ steps.short_sha.outputs.sha_short }} + body: | + 📦Version: `${{ steps.get_version.outputs.version }}` | Commit ${{ steps.short_sha.outputs.sha_short }} [![download](https://img.shields.io/github/downloads/LuminolMC/Luminol/${{ env.tag }}/total?color=0&style=flat-square)](https://github.com/LeavesMC/LuminolMC/Luminol/download/${{ steps.get_version.outputs.version }}-${{ steps.short_sha.outputs.sha_short }}/luminol-1.20.4-paperclip.jar) + This release is automatically compiled by GitHub Actions + artifacts: | + build/libs/luminol-1.20.4-bundler.jar + build/libs/luminol-1.20.4-paperclip.jar + generateReleaseNotes: true + prerelease: ${{ env.pre }} + makeLatest: ${{ env.make_latest }} + token: ${{ secrets.GITHUB_TOKEN }} + - name: Push to Api + if: github.event.commits[0].message != '[release-skip]' + env: + secret_v2: ${{ secrets.API_V2_PUSH_TOKEN }} + tag: ${{ env.tag }} + run: sh scripts/PushToAPI.sh \ No newline at end of file diff --git a/scripts/Get&SetENV.sh b/scripts/Get&SetENV.sh new file mode 100644 index 0000000..a4f639e --- /dev/null +++ b/scripts/Get&SetENV.sh @@ -0,0 +1,15 @@ +prop() { + grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//' +} + +commitid=$(git log --pretty='%h' -1) +mcversion=$(prop mcVersion) +preVersion=$(prop preVersion) +release_tag="$mcversion-$commitid" +jarName="build/libs/luminol-1.20.4-paperclip.jar" +make_latest=$([ $preVersion = "true" ] && echo "false" || echo "true") + +echo "tag=$release_tag" >> $GITHUB_ENV +echo "jar=$jarName" >> $GITHUB_ENV +echo "pre=$preVersion" >> $GITHUB_ENV +echo "make_latest=$make_latest" >> $GITHUB_ENV \ No newline at end of file diff --git a/scripts/PushToAPI.sh b/scripts/PushToAPI.sh index e69de29..c4aea19 100644 --- a/scripts/PushToAPI.sh +++ b/scripts/PushToAPI.sh @@ -0,0 +1,27 @@ +sha256() { + sha256sum $1 | awk '{print $1}' +} + +prop() { + grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//' +} +echo "$tag" +project_id="luminol" +project_name="uminol" +mcversion=$(prop mcVersion) +ctime=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +pre=$(prop preVersion) +if [ $pre = "true" ]; then + channel="experimental" +else + channel="default" +fi +promoted=false + +number=$(git log --oneline master ^`git describe --tags --abbrev=0` | wc -l) +changes=$(git log --pretty='%H<<<%s>>>' -"$number" | sed ':a;N;$!ba;s/\n//g') +jar_name="build/libs/luminol-1.20.4-paperclip.jar" +jar_sha256=`sha256 $jar_name` + +# v2 +curl --location --request POST "https://api.luminolmc.com/v2/commit/build" --header "Content-Type: application/json" --header "Authentication: Bearer $secret_v2" --data-raw "{\"project_id\":\"$project_id\",\"version\":\"$mcversion\",\"channel\":\"$channel\",\"changes\":\"$changes\",\"jar_name\":\"$jar_name\",\"sha256\":\"$jar_sha256\",\"tag\":\"$tag\"}" \ No newline at end of file