浏览代码

Update push workflow

Max 4 年之前
父节点
当前提交
0b2c0d8d74
共有 2 个文件被更改,包括 82 次插入28 次删除
  1. 0 28
      .github/workflows/publish.yml
  2. 82 0
      .github/workflows/push.yml

+ 0 - 28
.github/workflows/publish.yml

@@ -1,28 +0,0 @@
-name: Java CI
-
-on:
-  push:
-    paths:
-      - '**.gradle'
-      - '**.properties'
-      - '**/src/**'
-    branches:
-      - "1.16"
-      - "1.17"
-
-jobs:
-  build:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v1
-      - name: Set up JDK 1.8
-        uses: actions/setup-java@v1
-        with:
-          java-version: 1.8
-      - name: Upload to Maven
-        run: ./gradlew publish curseforgePublish --stacktrace
-        if: |
-          !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.pull_request.title, '[ci skip]')
-        env:
-          MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
-          curse_api_key: ${{ secrets.CURSE_API_KEY }}

+ 82 - 0
.github/workflows/push.yml

@@ -0,0 +1,82 @@
+name: Build and Release
+
+on:
+  push:
+    paths:
+      - '**.gradle'
+      - '**.properties'
+      - '**/src/**'
+    branches:
+      - "1.16"
+      - "1.17"
+  workflow_dispatch:
+    inputs:
+      norelease:
+        description: 'Do not publish'
+        required: true
+        default: 'false'
+
+jobs:
+  build:
+    strategy:
+      matrix:
+        java: [ 8-jdk, 11-jdk, 15-jdk ]
+    runs-on: ubuntu-20.04
+    container:
+      image: openjdk:${{ matrix.java }}
+      options: --user root
+    if: |
+      !contains(github.event.head_commit.message, '[ci skip]')
+    steps:
+      - uses: actions/cache@v2
+        with:
+          path: |
+            ~/.gradle/caches
+            ~/.gradle/wrapper
+          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+          restore-keys: |
+            ${{ runner.os }}-gradle-
+      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+      - uses: actions/checkout@v2
+      - uses: gradle/wrapper-validation-action@v1
+      - name: Build with Gradle
+        run: |
+          ./gradlew build --stacktrace --no-daemon
+      - name: Upload Artifacts
+        uses: actions/upload-artifact@v2
+        with:
+          name: '${{ github.event.repository.name }} Build #${{ github.run_number }}'
+          path: |
+            **/build/libs/
+            !build/libs/
+            !**/*-shadow.jar
+            !**/*-transformProduction([\w]+).jar
+  publish:
+    needs: build
+    runs-on: ubuntu-20.04
+    container:
+      image: openjdk:${{ matrix.java }}
+      options: --user root
+    if: |
+      !contains(github.event.head_commit.message, '[norelease]') && github.event.inputs.norelease != 'true'
+    steps:
+      - uses: actions/cache@v2
+        with:
+          path: |
+            ~/.gradle/caches
+            ~/.gradle/wrapper
+          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+          restore-keys: |
+            ${{ runner.os }}-gradle-
+      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+      - uses: actions/checkout@v2
+      - name: Release to Maven and CurseForge
+        env:
+          # currently unused, may want to use these for changelogs though!
+          # GIT_COMMIT: ${{ github.event.after }}
+          # GIT_PREVIOUS_COMMIT: ${{ github.event.before }}
+          MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
+          CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }}
+        # TODO: make this use the artifacts from the previous build step
+        run: |
+          ./gradlew build publish curseforgePublish --stacktrace --no-daemon