Skip to content

Commit

Permalink
Modernize CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jul 23, 2024
1 parent cd10449 commit 2406752
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
57 changes: 28 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
name: "CI"
on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: true
- name: 'Cache'
uses: actions/cache@v2
with:
path: |
~/.m2
~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('build.gradle') }}
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: 'Validate Gradle wrapper'
uses: gradle/actions/wrapper-validation@v3
- name: 'Setup Java'
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: 21
- name: 'Setup Gradle'
uses: gradle/actions/setup-gradle@v3
with:
java-version: 17
java-package: jdk
gradle-version: wrapper
cache-read-only: false
- name: 'Mark tag as release'
if: startsWith(github.ref, 'refs/tags/')
run: echo "RELEASE=true" >> $GITHUB_ENV
Expand All @@ -41,7 +44,7 @@ jobs:
if: ${{ env.KEYSTORE_BASE64 }}
run: cp ${{ steps.unlock_keystore.outputs.filePath }} .
- name: 'Build'
run: ./gradlew build --max-workers 1
run: ./gradlew build --no-daemon
env:
SIGN_KEYSTORE: ${{ secrets.SIGN_KEYSTORE }}
SIGN_ALIAS: ${{ secrets.SIGN_ALIAS }}
Expand All @@ -56,6 +59,11 @@ jobs:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
if: ${{ env.COVERALLS_REPO_TOKEN }}
run: ./gradlew test jacocoTestReport coveralls
- name: 'Deploy as GitHub CI artifacts'
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
path: build/libs/*
- name: 'Deploy to CurseForge'
if: startsWith(github.ref, 'refs/tags/')
env:
Expand All @@ -66,27 +74,18 @@ jobs:
env:
MODRINTH_KEY_SECRET: ${{ secrets.MODRINTH_KEY_SECRET }}
run: ./gradlew modrinth
- name: 'Create GitHub release'
id: create_release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
- name: 'Deploy to Maven'
if: startsWith(github.ref, 'refs/heads/master')
if: startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/feature')
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_KEY: ${{ secrets.MAVEN_KEY }}
run: ./gradlew publish
- name: 'Deploy JavaDoc to GitHub Pages'
if: startsWith(github.ref, 'refs/heads/master')
uses: JamesIves/github-pages-deploy-action@3.6.2
uses: JamesIves/github-pages-deploy-action@v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: build/docs/javadoc
CLEAN: true
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: build/docs/javadoc
clean: true
14 changes: 14 additions & 0 deletions .github/workflows/publish-github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Publish GitHub release on version tags
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'net.neoforged.gradle.userdev' version '7.0.145'
id 'net.darkhax.curseforgegradle' version '1.0.8'
id 'com.github.kt3k.coveralls' version '2.12.0'
id 'com.diffplug.spotless' version '5.14.3'
id 'com.diffplug.spotless' version '6.25.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.modrinth.minotaur' version '2.+'
}
Expand Down

0 comments on commit 2406752

Please sign in to comment.