From 54366e2b3553ccf349a365cbd0d63d30a33e66a9 Mon Sep 17 00:00:00 2001 From: Neeve Date: Sat, 13 Jan 2024 16:58:14 +1100 Subject: [PATCH] Initialize GHA workflows for pushing & caching (#359) --- .github/workflows/build.yml | 25 --------- .github/workflows/publish.yml | 68 +++++++++++++++++++++++ .github/workflows/update_gradle_cache.yml | 39 +++++++++++++ 3 files changed, 107 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/update_gradle_cache.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 24d63ea331f..00000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Build mod - -on: [ push, pull_request, workflow_dispatch ] - -jobs: - build: - name: Build mod - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v2 - with: - distribution: 'adopt' - java-version: '8' - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew -Pnet.minecraftforge.gradle.disableUpdateChecker=true build - - name: Upload artifacts - uses: actions/upload-artifact@v2 - with: - name: appliedenergistics2 - path: build/libs diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000000..1b3c9d67196 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,68 @@ +# Publishes built jars to distribution platforms +name: Publish + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' # any semver tag, e.g. 1.2.3 + +env: + # type of release + RELEASE_TYPE: "release" + +jobs: + Publish: + runs-on: ubuntu-latest + + permissions: + contents: write # needed to create GitHub releases + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Check for Duplicate Tags + run: | + if git rev-parse -q --verify "refs/tags/${{ github.ref }}" >/dev/null; then + echo "Tag already exists. A version bump is required." + exit 1 + fi + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '17' + + - name: Build Project + uses: gradle/gradle-build-action@v2 + with: + arguments: 'build --build-cache --daemon' # use the daemon here so the rest of the process is faster + generate-job-summary: false + gradle-home-cache-includes: | + caches + jdks + notifications + wrapper + + - name: Publish to GitHub + uses: softprops/action-gh-release@v1 + with: + files: "build/libs/*.jar" + generate_release_notes: true + fail_on_unmatched_files: true + + - name: Publish to Curseforge + uses: gradle/gradle-build-action@v2 + env: + CURSEFORGE_API_KEY: "${{secrets.CURSEFORGE_API_KEY}}" + CURSEFORGE_PROJECT_ID: "${{secrets.CURSEFORGE_PROJECT_ID}}" + RELEASE_TYPE: "${{env.RELEASE_TYPE}}" + with: + arguments: 'curseforge --daemon' + generate-job-summary: false + gradle-home-cache-includes: | + caches + jdks + notifications + wrapper diff --git a/.github/workflows/update_gradle_cache.yml b/.github/workflows/update_gradle_cache.yml new file mode 100644 index 00000000000..9853000d7ac --- /dev/null +++ b/.github/workflows/update_gradle_cache.yml @@ -0,0 +1,39 @@ +# Updates the Gradle Cache when relevant files change +name: Update Gradle Cache + +on: + workflow_dispatch: + push: + branches: + - master + paths: + - "gradle**" # covers gradle folder, gradle.properties, gradlew + - "build.gradle*" + - "settings.gradle*" + - "src/main/resources/*_at.cfg" # access transformers + +jobs: + Update_Cache: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '17' + + - name: Update Cache + uses: gradle/gradle-build-action@v2 + with: + arguments: 'test --build-cache --no-daemon' # disable daemon since only one gradle operation will happen + generate-job-summary: false + gradle-home-cache-includes: | + caches + jdks + notifications + wrapper + cache-write-only: true