Files
architectury-api/.github/workflows/push.yml
2021-05-19 00:54:13 +02:00

194 lines
6.2 KiB
YAML

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:
validate-gradle:
name: "Validate Gradle wrapper"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v1
license:
name: "Verify License integrity"
runs-on: ubuntu-20.04
if: |
!contains(github.event.head_commit.message, '[ci skip]')
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: 'adopt'
- name: Cache Gradle wrapper
uses: actions/cache@v2
with:
path: ~/.gradle/wrapper
key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/**/*') }}
restore-keys: gradle-wrapper-${{ runner.os }}-
- name: Cache packages
id: cache-packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: gradle-packages-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-packages-${{ runner.os }}-
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Verify license using Licenser
run: |
./gradlew licenseCheck
# Remove some potentially problematic files from the Gradle cache,
# so that GitHub Actions doesn't cache them.
- name: Cleanup Gradle Cache
if: steps.cache-packages.outputs.cache-hit != 'true'
run: |
rm -f $HOME/.gradle/caches/*/*.lock
rm -rf $HOME/.gradle/caches/*/plugin-resolution/
rm -rf $HOME/.gradle/caches/*/scripts/
rm -rf $HOME/.gradle/caches/*/scripts-remapped/
rm -rf $HOME/.gradle/caches/*/fileHashes/
rm -f $HOME/.gradle/caches/journal-1/file-access.bin
build:
name: "Build"
strategy:
matrix:
java: [ 8, 11, 15 ]
runs-on: ubuntu-20.04
if: |
!contains(github.event.head_commit.message, '[ci skip]')
steps:
- uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
- name: Cache Gradle wrapper
uses: actions/cache@v2
with:
path: ~/.gradle/wrapper
key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/**/*') }}
restore-keys: gradle-wrapper-${{ runner.os }}-
- name: Cache packages
id: cache-packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: gradle-packages-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-packages-${{ runner.os }}-
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: |
./gradlew build --stacktrace --no-daemon
# Remove some potentially problematic files from the Gradle cache,
# so that GitHub Actions doesn't cache them.
- name: Cleanup Gradle Cache
if: steps.cache-packages.outputs.cache-hit != 'true'
run: |
rm -f $HOME/.gradle/caches/*/*.lock
rm -rf $HOME/.gradle/caches/*/plugin-resolution/
rm -rf $HOME/.gradle/caches/*/scripts/
rm -rf $HOME/.gradle/caches/*/scripts-remapped/
rm -rf $HOME/.gradle/caches/*/fileHashes/
rm -f $HOME/.gradle/caches/journal-1/file-access.bin
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: 'Build Artifacts (JDK ${{ matrix.java }}, Build #${{ github.run_number }})'
path: |
**/build/libs/
!build/libs/
!**/*-dev.jar
!**/*-shadow.jar
!**/*-transformProduction*.jar
!**/testmod*/
publish:
needs:
- validate-gradle
- license
- build
runs-on: ubuntu-20.04
if: |
!contains(github.event.head_commit.message, '[norelease]') && github.event.inputs.norelease != 'true'
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: 'adopt'
- name: Cache Gradle wrapper
uses: actions/cache@v2
with:
path: ~/.gradle/wrapper
key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/**/*') }}
restore-keys: gradle-wrapper-${{ runner.os }}-
- name: Cache packages
id: cache-packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: gradle-packages-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-packages-${{ runner.os }}-
- 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
# Remove some potentially problematic files from the Gradle cache,
# so that GitHub Actions doesn't cache them.
- name: Cleanup Gradle Cache
if: steps.cache-packages.outputs.cache-hit != 'true'
run: |
rm -f $HOME/.gradle/caches/*/*.lock
rm -rf $HOME/.gradle/caches/*/plugin-resolution/
rm -rf $HOME/.gradle/caches/*/scripts/
rm -rf $HOME/.gradle/caches/*/scripts-remapped/
rm -rf $HOME/.gradle/caches/*/fileHashes/
rm -f $HOME/.gradle/caches/journal-1/file-access.bin