Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Jun 11, 2024
1 parent 9589636 commit b32ec48
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ jobs:
- name: Set up Eclipse Temurin 21
uses: actions/setup-java@v4
with:
distribution: temurin
distribution: 'microsoft'
java-version: 21
cache: 'gradle'
- name: Build with Gradle
run: gradle build
run: gradle build --rerun-tasks
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Upload Release Artifacts

on:
push:
tags:
- '*'

env:
TAG: ${{ github.ref_name }}
BUILD_NUMBER: ${{ github.run_number }}

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: 21
- name: Copy Maven Upload URL
id: extract_maven_upload_url
run: echo "maven_upload_url=${{ secrets.MAVEN_UPLOAD_URL }}" >> $GITHUB_OUTPUT
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew assemble --rerun-tasks
- name: Maven Release
if: steps.extract_maven_upload_url.outputs.maven_upload_url
env:
MAVEN_UPLOAD_URL: ${{ secrets.MAVEN_UPLOAD_URL }}
MAVEN_UPLOAD_USERNAME: ${{ secrets.MAVEN_UPLOAD_USERNAME }}
MAVEN_UPLOAD_PASSWORD: ${{ secrets.MAVEN_UPLOAD_PASSWORD }}
run: ./gradlew publish
- name: Publish
id: publish_fabric
uses: Kir-Antipov/mc-publish@995edadc13559a8b28d0b7e6571229f067ec7659 # (new) v3.3.0
with:
github-token: ${{ github.token }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
version: ${{ env.TAG }}-Fabric
files: |
build/libs/!(*-@(dev|sources|javadoc|slim)).jar
build/libs/*-@(sources|javadoc).jar
45 changes: 34 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ plugins {
alias libs.plugins.quilt.loom
}

base.archivesName = project.archives_base_name
version = "${project.version}+${libs.versions.minecraft.get()}"
def ENV = System.getenv()
def now = new Date()

version = ENV.TAG ?: "development-${now.format('YY.MMdd.HHmm', TimeZone.getTimeZone('UTC'))}+${libs.versions.minecraft.get()}${(!ENV.TAG && ENV.BUILD_NUMBER) ? "-build.${ENV.BUILD_NUMBER}" : ''}"
group = project.maven_group

// Minecraft 1.20.6 (24w14a) upwards uses Java 21.
def javaVersion = 21

base {
archivesName.set("${rootProject.name}-fabric")
}

sourceSets {
testmod {
compileClasspath += main.compileClasspath
Expand Down Expand Up @@ -81,23 +90,26 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.20.6 (24w14a) upwards uses Java 21.
it.options.release.set(21)
it.options.release.set(javaVersion)
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

// If this mod is going to be a library, then it should also generate Javadocs in order to aid with developement.
// If this mod is going to be a library, then it should also generate Javadocs in order to aid with development.
// Uncomment this line to generate them.
withJavadocJar()

toolchain {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
}

jar {
from('LICENSE') {
rename { "${it}_${archivesBaseName}" }
from('LICENSE*') {
rename { "LICENSE_${rootProject.name}" }
}
}

Expand All @@ -107,10 +119,12 @@ publishing {
mavenJava(MavenPublication) {
from components.java

artifactId = "${rootProject.name}-fabric"

pom {
name = 'LibZoomer'
description = 'A library that allows other Minecraft mods to have powerful zooming easily.'
url = 'https://github.com/EnnuiL/LibZoomer'
url = 'https://github.com/Up-Mods/LibZoomer'
licenses {
license {
name = 'The MIT License'
Expand All @@ -124,9 +138,9 @@ publishing {
}
}
scm {
connection = 'scm:git:https://github.com/EnnuiL/LibZoomer.git'
developerConnection = 'scm:git:[email protected]:EnnuiL/LibZoomer.git'
url = 'https://github.com/EnnuiL/LibZoomer'
connection = 'scm:git:https://github.com/Up-Mods/LibZoomer.git'
developerConnection = 'scm:git:[email protected]:Up-Mods/LibZoomer.git'
url = 'https://github.com/Up-Mods/LibZoomer'
}
}
}
Expand All @@ -138,5 +152,14 @@ publishing {
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
if (ENV.MAVEN_UPLOAD_URL) {
maven {
url = ENV.MAVEN_UPLOAD_URL
credentials {
username = ENV.MAVEN_UPLOAD_USERNAME
password = ENV.MAVEN_UPLOAD_PASSWORD
}
}
}
}
}
4 changes: 1 addition & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ org.gradle.jvmargs = -Xmx1G
org.gradle.parallel = true

# Mod Properties
version = 0.9.1
maven_group = io.github.ennuil
archives_base_name = libzoomer
maven_group = io.github.ennuil.libzoomer

# Dependencies are managed at gradle/libs.versions.toml
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ pluginManagement {
gradlePluginPortal()
}
}

rootProject.name = 'libzoomer'

0 comments on commit b32ec48

Please sign in to comment.