Skip to content

Commit

Permalink
Properly setup GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSuperGamer20578 committed Sep 19, 2023
1 parent ef5f8e5 commit e64dde4
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 60 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/dependencies.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#file: noinspection SpellCheckingInspection
name: Push (master)
on:
push:
branches:
- master

jobs:
dependencies:
name: Dependencies
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: mikepenz/[email protected]
with:
use-gradlew: false
modrinth-description:
name: Update Modrinth Description
runs-on: ubuntu-latest
if: false # TODO Make description work on Modrinth
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- uses: gradle/gradle-build-action@v2
- name: Build
run: |
gradle modrinthSyncBody
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
76 changes: 76 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Push
on:
pull_request_target:
push:
branches:
- "*"

permissions:
contents: read
packages: read

jobs:
qodana:
name: Qodana
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: JetBrains/[email protected]
with:
args: -e,GITHUB_ACTOR=${{ env.GITHUB_ACTOR }},-e,GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- uses: gradle/gradle-build-action@v2
- name: Build
run: |
gradle build -Pci=snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
with:
name: Chromatic SNAPSHOT
path: build/libs
codeql:
name: CodeQL
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: github/codeql-action/init@v2
with:
languages: java
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- uses: gradle/gradle-build-action@v2
- name: Build
run: |
gradle build -Pci=snapshot --no-build-cache
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v3
with:
name: Chromatic SNAPSHOT
path: build/libs
- uses: github/codeql-action/analyze@v2
18 changes: 0 additions & 18 deletions .github/workflows/qodana.yml

This file was deleted.

97 changes: 97 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Release

on:
push:
tags:
- v*.*.*

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- uses: gradle/gradle-build-action@v2
- name: Build
run: |
gradle build -Pci=release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
with:
name: Chromatic Release
path: build/libs
publish:
name: Publish
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Get version information from tag
id: tag
run: |
git fetch -f origin ${{ github.ref }}:${{ github.ref }} # https://github.com/actions/checkout/issues/290
ref=${GITHUB_REF/refs\/tags\//}
echo "tag=$ref" >> $GITHUB_OUTPUT
echo "version=${ref/v/}" >> $GITHUB_OUTPUT
if grep -q "-" <<< "$ref"
then
echo "embed_message=" >> $GITHUB_OUTPUT
if grep -q "alpha" <<< "$ref"
then
echo "embed_colour=$((0xfc2803))" >> $GITHUB_OUTPUT
elif grep -q "beta" <<< "$ref"
then
echo "embed_colour=$((0x03befc))" >> $GITHUB_OUTPUT
else
echo "embed_colour=$((0x6be8c0))" >> $GITHUB_OUTPUT
fi
else
echo "embed_message=<@&1040804523553345646>" >> $GITHUB_OUTPUT
echo "embed_colour=$((0x6be86f))" >> $GITHUB_OUTPUT
fi
{
echo $'changelog<<\04'
git tag -l --format="%(contents)" $ref | sed -n "/-----BEGIN PGP SIGNATURE-----/q;p" | tee CHANGELOG.md
echo $'\04'
} >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v3
- uses: Kir-Antipov/[email protected]
id: mc-publish
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
game-version-filter: releases | min-major | max-major
github-discussion: Announcements
modrinth-featured: false
name: Chromatic ${{ steps.tag.outputs.tag }}
version: ${{ steps.tag.outputs.tag }}
changelog-file: CHANGELOG.md
files: "Chromatic Release/Chromatic-${{ steps.tag.outputs.version }}.jar"
- uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
content: ${{ steps.tag.outputs.embed_message }}
embed-title: "Chromatic ${{ steps.tag.outputs.tag }} has been released!"
embed-author-name: ${{ github.actor }}
embed-author-icon-url: https://avatars.githubusercontent.com/u/${{ github.actor_id }}
embed-color: ${{ steps.tag.outputs.embed_colour }}
embed-description: |
${{ steps.tag.outputs.changelog }}
__**Download:**__
[<:github:1148533096166215730> GitHub](${{ steps.mc-publish.outputs.github-url }})
[<:modrinth:1148533092097728592> Modrinth](https://modrinth.com/mod/${{ steps.mc-publish.outputs.modrinth-id }}/version/${{ steps.mc-publish.outputs.modrinth-version }})
[<:curseforge:1148533086959706122> CurseForge](${{ steps.mc-publish.outputs.curseforge-url }})
88 changes: 73 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,42 +1,81 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.palantir.git-version' version '3.0.0'
id 'com.modrinth.minotaur' version '2.+'
id 'io.github.themrmilchmann.curseforge-publish' version '0.4.0'
}

version = project.mod_version
group = "com.TheSuperGamer20578"

def git = versionDetails()
def prefix = 'v'
def tag
if (git.lastTag.startsWith(prefix)) {
tag = git.lastTag.substring(prefix.length())
} else {
tag = git.lastTag
}
if (hasProperty('ci')) {
switch (property('ci')) {
case 'release':
if (git.commitDistance != 0) {
throw new InvalidUserDataException('Not on a tag')
}
if (!git.lastTag.startsWith('v')) {
throw new InvalidUserDataException('Last tag was not a version tag')
}
version = "${tag}"
break
case 'snapshot':
version = "${tag}${tag.contains('-') ? '.' : '-'}SNAPSHOT.${git.commitDistance}.${git.branchName}.${git.gitHash}"
break
default:
throw new InvalidUserDataException("Invalid ci argument: ${property("ci")}")
}
} else {
version = "${tag}${tag.contains('-') ? '.' : '-'}SNAPSHOT.${git.commitDistance}.${git.branchName}.${git.gitHash}+local"
}
group = 'io.github.thesupergamer20578'


repositories {
maven {
url "https://maven.terraformersmc.com/"
}
url 'https://maven.terraformersmc.com/'
}
maven {
url 'https://maven.shedaniel.me/'
}
maven {
url "https://maven.shedaniel.me/"
url 'https://maven.pkg.github.com/thesupergamer20578/chroma/'
credentials {
username = project.findProperty('gpr.user') ?: System.getenv('GITHUB_ACTOR')
password = project.findProperty('gpr.key') ?: System.getenv('GITHUB_TOKEN')
}
}
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "com.terraformersmc:modmenu:6.1.0-rc.4"
modApi("me.shedaniel.cloth:cloth-config-fabric:10.0.96") {
exclude(group: "net.fabricmc.fabric-api")
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: 'net.fabricmc.fabric-api')
}
implementation project(":lib:JChroma")
include project(":lib:JChroma")
}

processResources {
inputs.property "version", project.version
inputs.property 'version', project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
filesMatching('fabric.mod.json') {
expand 'version': project.version
}
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 11
it.options.encoding 'UTF-8'
}

Expand All @@ -45,7 +84,26 @@ java {
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
from('LICENSE') {
rename { "${it}_${project.archivesBaseName}" }
}
}

shadowJar {
archiveClassifier = 'unmapped'
configurations = [project.configurations.shadow]
exclude 'META-INF'
exclude 'org/apache/commons/lang3/**'
}

remapJar {
dependsOn shadowJar
mustRunAfter shadowJar
inputFile = file(shadowJar.archiveFile)
}

modrinth {
projectId = 'gB2OPOxC'
token = System.getenv('MODRINTH_TOKEN')
syncBodyFrom = rootProject.file('README.md').text
}
Loading

0 comments on commit e64dde4

Please sign in to comment.