From 850c60d04c30710cb0204f2b024692db19bb915b Mon Sep 17 00:00:00 2001 From: ShintoKosei <2081384668@qq.com> Date: Sun, 14 Apr 2024 07:09:19 +0800 Subject: [PATCH] update CI --- .github/workflows/build_1_20_4_v2.yml | 34 ++++++++++++++------------- scripts/PushToAPI.sh | 27 ++------------------- scripts/SetENV.sh | 1 - 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build_1_20_4_v2.yml b/.github/workflows/build_1_20_4_v2.yml index 0d45a57..b509669 100644 --- a/.github/workflows/build_1_20_4_v2.yml +++ b/.github/workflows/build_1_20_4_v2.yml @@ -1,34 +1,36 @@ -name: Luminol CI v2 - Ver/1.20.4 - +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 + uses: actions/checkout@v4 + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v3 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 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: Configure Git User Details + run: git config --global user.email "ci@luminolmc.com" && git config --global user.name "LuminolMC CI" - name: Apply Patches run: ./gradlew applyPatches - name: Build + run: ./gradlew build + - name: CreateJar run: ./gradlew createReobfBundlerJar createReobfPaperclipJar - - uses: "actions/upload-artifact@v3" + - run: "ls build/libs" + - uses: "actions/upload-artifact@v4" with: name: "Luminol CI Artifacts" path: "build/libs/*.jar" @@ -36,13 +38,13 @@ jobs: 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 + - 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 + if: "!contains(github.event.commits[0].message, '[release skip]')" + uses: ncipollo/release-action@v1.14.0 with: tag: ${{ env.tag }} name: Luminol ${{ env.mcversion }} - ${{ env.commitid }} @@ -56,8 +58,8 @@ jobs: prerelease: ${{ env.pre }} makeLatest: ${{ env.make_latest }} token: "${{ secrets.GITHUB_TOKEN }}" - - name: Push to Api - if: "!contains(github.event.commits[0].message, '[release-skip]')" + - name: Push to API + if: "!contains(github.event.commits[0].message, '[release skip]')" env: secret_v2: ${{ secrets.API_KEY }} tag: ${{ env.tag }} diff --git a/scripts/PushToAPI.sh b/scripts/PushToAPI.sh index 0bfbd59..0ac7d12 100644 --- a/scripts/PushToAPI.sh +++ b/scripts/PushToAPI.sh @@ -1,7 +1,6 @@ sha256() { sha256sum $1 | awk '{print $1}' } - prop() { grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//' } @@ -16,33 +15,11 @@ if [ $pre = "true" ]; then 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" 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" -echo "[DEBUG] $changes" -echo "[DEBUG] curl --location --request POST \"https://api.luminolmc.com/v2/projects/$project_id/$mcversion/build/commit\" \ - -H \"Content-Type: application/x-www-form-urlencoded\" \ - -H \"Authorization: $secret_v2\" \ - --data-urlencode \"channel=$channel\" \ - --data-urlencode \"jar_name=$jar_name\" \ - --data-urlencode \"sha256=$jar_sha256\" \ - --data-urlencode \"release_tag=$tag\" \ - --data-urlencode \"time=$ctime\" \ - --data-urlencode \"changes=$changes\"" -curl -L --request POST "https://api.luminolmc.com/v2/projects/$project_id/$mcversion/build/commit" \ - -H "Content-Type: application/x-www-form-urlencoded" \ - -H "Authorization: $secret_v2" \ - --data-urlencode "channel=$channel" \ - --data-urlencode "jar_name=$jar_name" \ - --data-urlencode "sha256=$jar_sha256" \ - --data-urlencode "release_tag=$tag" \ - --data-urlencode "time=$ctime" \ - --data-urlencode "changes=$changes" +curl -L --request POST "https://api.luminolmc.com/v2/projects/$project_id/$mcversion/build/commit" -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: $secret_v2" --data-urlencode "channel=$channel" --data-urlencode "jar_name=$jar_name" --data-urlencode "sha256=$jar_sha256" --data-urlencode "release_tag=$tag" --data-urlencode "time=$ctime" --data-urlencode "changes=$changes" \ No newline at end of file diff --git a/scripts/SetENV.sh b/scripts/SetENV.sh index 88f4caa..22095f9 100644 --- a/scripts/SetENV.sh +++ b/scripts/SetENV.sh @@ -11,7 +11,6 @@ make_latest=$([ $preVersion = "true" ] && echo "false" || echo "true") echo "commitid=$commitid" >> $GITHUB_ENV echo "mcversion=$mcversion" >> $GITHUB_ENV -echo "$mcversion" echo "tag=$release_tag" >> $GITHUB_ENV echo "jar=$jarName" >> $GITHUB_ENV echo "pre=$preVersion" >> $GITHUB_ENV