diff --git a/.github/workflows/build_1.20.4.yml b/.github/workflows/build_1.20.4.yml new file mode 100644 index 0000000..003c2d9 --- /dev/null +++ b/.github/workflows/build_1.20.4.yml @@ -0,0 +1,66 @@ +name: Luminol CI - ver/1.20.4 + +on: + push: + branches: [ "ver/1.20.4" ] + pull_request: + branches: [ "ver/1.20.4" ] + +permissions: write-all + +jobs: + build: + runs-on: ubuntu-latest + environment: default + steps: + - name: Checkout Git Repository + uses: actions/checkout@v4 + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v3 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-version: 8.4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - name: Configure Git User Details + run: git config --global user.email "ci@luminolmc.com" && git config --global user.name "LuminolMC CI" + - name: Apply Patches + run: gradle applyPatches + - name: CreateJar + run: gradle createReobfBundlerJar createReobfPaperclipJar + - name: SetENV + run: sh scripts/SetENV.sh + - name: Upload Artifact + uses: "actions/upload-artifact@v4" + with: + name: "${{ env.project_id_b }} CI Artifacts" + path: "build/libs/*.jar" + - name: Create Release + if: "!contains(github.event.commits[0].message, '[release skip]')" + uses: ncipollo/release-action@v1.14.0 + with: + tag: ${{ env.tag }} + name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }} + body: | + 📦Version: `${{ env.mcversion }}` | Commit ${{ env.commit_id }} [![download](https://img.shields.io/github/downloads/LuminolMC/${{ env.project_id }}/${{ env.tag }}/total?color=0&style=flat-square)](https://github.com/LuminolMC/${{ env.project_id }}/download/${{ env.tag }}/${{ env.jar }}) + This release is automatically compiled by GitHub Actions + ### Commit Message + ${{ env.commit_msg }} + artifacts: | + ${{ env.jar_dir }} + build/libs/${{ env.project_id }}-${{ env.mcversion }}-bundler.jar + generateReleaseNotes: true + prerelease: ${{ env.pre }} + makeLatest: ${{ env.make_latest }} + token: "${{ secrets.GITHUB_TOKEN }}" + - name: Push to API + if: "!contains(github.event.commits[0].message, '[release skip]')" + env: + secret_v2: ${{ secrets.API_KEY }} + tag: ${{ env.tag }} + project_id: ${{ env.project_id }} + run: sh scripts/PushToAPI.sh \ No newline at end of file diff --git a/.github/workflows/build_1_20_4.yml_dis b/.github/workflows/build_1_20_4.yml_dis deleted file mode 100644 index 577145a..0000000 --- a/.github/workflows/build_1_20_4.yml_dis +++ /dev/null @@ -1,63 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: LuminolCI - Ver/1.20.4 - -on: - push: - branches: [ "ver/1.20.4" ] - pull_request: - branches: [ "ver/1.20.4" ] - -permissions: write-all - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up git - run: git config --global user.email "noreply@github.com" && git config --global user.name "ci" - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Make gradlew executable - run: chmod 777 ./gradlew - - name: Setup project - uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 - with: - arguments: applyPatches - - name: Build project to paperclip jar - uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 - with: - arguments: createReobfBundlerJar createReobfPaperclipJar - - name: Capture build artifacts - uses: actions/upload-artifact@v3 - with: - name: Artifacts - path: build/libs/ - - name: Publish All - run: | - echo "GITHUB_USERNAME=LuminolCI" >> $GITHUB_ENV - export GITHUB_USERNAME=LuminolCI - echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV - export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} - ./gradlew publish -PpublishDevBundle=true - - name: Rename jar file - run: mv build/libs/luminol-paperclip-1.20.4-R0.1-SNAPSHOT-reobf.jar build/libs/luminol-1.20.4-paperclip.jar - - name: Release Artifacts - uses: svenstaro/upload-release-action@v2 - with: - release_name: "Luminol MC1.20.4 - ${{ github.event.repository.updated_at}}" - tag: "1.20.4-${{ github.run_id }}" - repo_token: "${{ secrets.GITHUB_TOKEN }}" - file: "build/libs/luminol-1.20.4-paperclip.jar" - file_glob: true - prerelease: true diff --git a/.github/workflows/build_1_20_4_v2.yml b/.github/workflows/build_1_20_4_v2.yml deleted file mode 100644 index 0d45a57..0000000 --- a/.github/workflows/build_1_20_4_v2.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Luminol CI v2 - Ver/1.20.4 - -on: - push: - branches: [ "ver/1.20.4" ] - pull_request: - branches: [ "ver/1.20.4" ] - # workflow_dispatch: -permissions: write-all -jobs: - build: - runs-on: ubuntu-latest - environment: default - - steps: - - name: Checkout Git Repository - uses: actions/checkout@v3 - - 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: 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: setenv - run: | - sh scripts/SetENV.sh - echo "${{ env.tag }}" - - name: Create Release - if: "!contains(github.event.commits[0].message, '[release-skip]')" - uses: ncipollo/release-action@v1.12.0 - with: - tag: ${{ env.tag }} - name: Luminol ${{ env.mcversion }} - ${{ env.commitid }} - body: | - 📦Version: `${{ env.mcversion }}` | Commit ${{ env.commitid }} [![download](https://img.shields.io/github/downloads/LuminolMC/Luminol/${{ env.tag }}/total?color=0)](https://github.com/LeavesMC/LuminolMC/Luminol/download/${{ env.tag }}/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: "!contains(github.event.commits[0].message, '[release-skip]')" - env: - secret_v2: ${{ secrets.API_KEY }} - tag: ${{ env.tag }} - run: sh scripts/PushToAPI.sh diff --git a/gradle.properties b/gradle.properties index 0dffdfc..2f3bc12 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,6 +8,6 @@ org.gradle.parallel = true org.gradle.vfs.watch = false org.gradle.jvmargs = -Xmx3G -mcVersion=1.20.4 -GroupMCV=1.20 -preVersion=false \ No newline at end of file +mcVersion = 1.20.4 +GroupMCV = 1.20 +preVersion = false \ No newline at end of file diff --git a/scripts/PushToAPI.sh b/scripts/PushToAPI.sh index 0bfbd59..2955314 100644 --- a/scripts/PushToAPI.sh +++ b/scripts/PushToAPI.sh @@ -1,29 +1,27 @@ sha256() { sha256sum $1 | awk '{print $1}' } - prop() { - grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//' + grep "^[[:space:]]*${1}" gradle.properties | cut -d'=' -f2 | sed 's/^[[:space:]]*//; s/\r//' } -project_id="luminol" mcversion_group=$(prop GroupMCV) mcversion=$(prop mcVersion) pre=$(prop preVersion) +pro_id_mcv=$project_id-$mcversion if [ $pre = "true" ]; then channel="experimental" else channel="default" fi + changes=$(git log -1 --pretty="[{\"commit\": \"%H\", \"message\": \"%s\", \"summary\": \"%s\"}]") -jar_sha256=`sha256 build/libs/luminol-1.20.4-paperclip.jar` -jar_name="luminol-1.20.4-paperclip.jar" +jar_sha256=`sha256 build/libs/$pro_id_mcv-paperclip.jar` +jar_name="$pro_id_mcv-paperclip.jar" ctime=$(date -u +"%s")"000" # v2 -echo "Authentication: $secret_v2" -#echo "{\"version_group\":\"$mcversion_group\",\"channel\":\"$channel\",\"changes\":\"$changes\",\"jar_name\":\"$jar_name\",\"sha256\":\"$jar_sha256\",\"release_tag\":\"$tag\",\"time\":\"$ctime\"}" > data.json json=$(printf "{\\\"channel\\\":\\\"%s\\\", \\\"jar_name\\\":\\\"%s\\\", \\\"sha256\\\":\\\"%s\\\", \\\"tag\\\":\\\"%s\\\", \\\"time\\\":\\\"%s\\\", \\\"changes\\\":\\\"%s\\\"}" \ "$channel" "$jar_name" "$jar_sha256" "$tag" "$ctime" "$changes") echo "[DEBUG] $json" @@ -45,4 +43,4 @@ curl -L --request POST "https://api.luminolmc.com/v2/projects/$project_id/$mcver --data-urlencode "sha256=$jar_sha256" \ --data-urlencode "release_tag=$tag" \ --data-urlencode "time=$ctime" \ - --data-urlencode "changes=$changes" + --data-urlencode "changes=$changes" \ No newline at end of file diff --git a/scripts/SetENV.sh b/scripts/SetENV.sh index 88f4caa..09d428c 100644 --- a/scripts/SetENV.sh +++ b/scripts/SetENV.sh @@ -1,18 +1,32 @@ prop() { - grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//' + grep "^[[:space:]]*${1}" gradle.properties | cut -d'=' -f2 | sed 's/^[[:space:]]*//; s/\r//' } +project_id="luminol" +project_id_b="Luminol" + commitid=$(git log --pretty='%h' -1) mcversion=$(prop mcVersion) +grdversion=$(prop version) preVersion=$(prop preVersion) release_tag="$mcversion-$commitid" -jarName="build/libs/luminol-1.20.4-paperclip.jar" +jarName="$project_id-$mcversion-paperclip.jar" +jarName_dir="build/libs/$jarName" make_latest=$([ $preVersion = "true" ] && echo "false" || echo "true") +number=$(git log --oneline master ^`git describe --tags --abbrev=0` | wc -l) -echo "commitid=$commitid" >> $GITHUB_ENV +mv build/libs/$project_id-paperclip-$grdversion-reobf.jar build/libs/$jarName +mv build/libs/$project_id-bundler-$grdversion-reobf.jar build/libs/$project_id-$mcversion-bundler.jar + + +echo "project_id=$project_id" >> $GITHUB_ENV +echo "project_id_b=$project_id_b" >> $GITHUB_ENV +echo "commit_id=$commitid" >> $GITHUB_ENV +echo "commit_msg=$(git log --pretty='> [%h] %s' -$number)" >> $GITHUB_ENV +echo "$commit_msg" echo "mcversion=$mcversion" >> $GITHUB_ENV -echo "$mcversion" +echo "pre=$preVersion" >> $GITHUB_ENV echo "tag=$release_tag" >> $GITHUB_ENV echo "jar=$jarName" >> $GITHUB_ENV -echo "pre=$preVersion" >> $GITHUB_ENV -echo "make_latest=$make_latest" >> $GITHUB_ENV +echo "jar_dir=$jarName_dir" >> $GITHUB_ENV +echo "make_latest=$make_latest" >> $GITHUB_ENV \ No newline at end of file