Skip to content

Commit

Permalink
ci!: use googleapis/release-please for releases (closes #26)
Browse files Browse the repository at this point in the history
ci: upgrade Modrinth gradle extension to v2

deps: upgrade everything for Minecraft 1.18.2
  • Loading branch information
axieum committed Mar 26, 2022
1 parent e25981a commit e2727b1
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 174 deletions.
20 changes: 5 additions & 15 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ made regularly.
At any given time, the latest code that exists in production can be found under
the `main` branch.

#### `next` / `next-major`

An upcoming major release can be found under the `next` or `next-major`
branches. For example, if `main` is currently on `v2.4.1`, the next major
release is expected to be on `v3.0.0`.

#### `beta` / `alpha`

The latest Beta and Alpha releases can be found under the `beta` and `alpha`
Expand Down Expand Up @@ -117,18 +111,15 @@ pattern `+([0-9])?(.{+([0-9]),x}).x`, e.g. `2.x`.
## Continuous Integration & Deployment (CI/CD)

This project uses [GitHub Actions][github:actions] in tandem
with [semantic-release][semantic-release] to automate building, testing and
with [release-please][release-please] to automate building, testing and
deploying new versions of the codebase.

Please refer to the following [recipes][semantic-release:recipes] for triggering
new releases.

### How it works?

When new commits make their way into one of the release branches outlined in
the [Branching Strategy](#branching-strategy), a
GitHub [workflow][workflow:publish] is triggered. This workflow in turn
executes [semantic-release][semantic-release].
GitHub [workflow][workflow:release] is triggered. This workflow in turn
executes [release-please][release-please].

## Code Style

Expand All @@ -149,7 +140,6 @@ this functionality to your IDE.
[conventionalcommits]: https://www.conventionalcommits.org/
[github:actions]: https://github.com/features/actions
[github:flow]: https://guides.github.com/introduction/flow
[semantic-release]: https://github.com/semantic-release/semantic-release
[semantic-release:recipes]: https://github.com/semantic-release/semantic-release/blob/v17.4.4/docs/recipes
[release-please]: https://github.com/googleapis/release-please
[semver]: https://semver.org/
[workflow:publish]: workflows/publish.yml
[workflow:release]: workflows/release.yml
16 changes: 16 additions & 0 deletions .github/release-please.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"release-type": "simple",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"group-pull-request-title-pattern": "chore: release v${version}",
"extra-files": ["gradle.properties"],
"packages": {
".": {
"component": "fabric-example-mod",
"include-component-in-tag": false
},
"example-submod": {
"component": "example-submod"
}
}
}
30 changes: 12 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,20 @@ jobs:
- name: ✨ Checkout repository
uses: actions/checkout@v2

- name: 🛂 Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: 🏗 Set up JDK 17
- name: ☕ Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: adopt

- name: 📷 Begin Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: 🐘 Set up Gradle
uses: gradle/gradle-build-action@v2

- name: 🧪 Run tests
run: ./gradlew check

- name: 🔨 Build artifacts
run: gradle clean build
run: ./gradlew build publishToMavenLocal

- name: 📦 Upload artifacts
uses: actions/upload-artifact@v2
Expand All @@ -58,7 +51,8 @@ jobs:
name: reports
path: '**/build/reports/'

- name: 🧨 Cleanup Gradle cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: 🗃 Upload Maven local
uses: actions/upload-artifact@v2
with:
name: maven
path: ~/.m2/repository/
66 changes: 0 additions & 66 deletions .github/workflows/publish.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Prepares, builds and publishes new releases

name: Release

on:
push:
branches:
- main
- master
workflow_dispatch:

jobs:
release:
name: Release

runs-on: ubuntu-latest

steps:
- name: 🙌 Prepare release
id: release-please
uses: GoogleCloudPlatform/release-please-action@v3
with:
command: manifest
config-file: .github/release-please.json
token: ${{ secrets.GITHUB_TOKEN }}

- name: ✨ Checkout repository
if: ${{ steps.release-please.outputs.release_created }}
uses: actions/checkout@v2

- name: ☕ Set up JDK 17
if: ${{ steps.release-please.outputs.release_created }}
uses: actions/setup-java@v2
with:
java-version: 17
distribution: adopt

- name: 🐘 Set up Gradle
if: ${{ steps.release-please.outputs.release_created }}
uses: gradle/gradle-build-action@v2

- name: 📢 Publish new release
if: ${{ steps.release-please.outputs.release_created }}
run: ./gradlew publish
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

- name: 📦 Upload artifacts
if: ${{ steps.release-please.outputs.release_created }}
uses: svenstaro/upload-release-action@v2
with:
tag: ${{ steps.release-please.outputs.tag_name }}
file: '**/build/libs/*'
file_glob: true
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{".":"1.0.0","example-submod":"1.0.0"}
28 changes: 0 additions & 28 deletions .releaserc.yml

This file was deleted.

Empty file added CHANGELOG.md
Empty file.
56 changes: 26 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ plugins {
id 'java'
id 'checkstyle'
id 'maven-publish'
id 'com.modrinth.minotaur' version '1.2.1'
id 'com.modrinth.minotaur' version '2.1.1'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'fabric-loom' version '0.11-SNAPSHOT'
}

allprojects {
Expand Down Expand Up @@ -96,7 +96,7 @@ curseforge {
// Set the release notes
changelog = "For a list of changes, please refer to https://github.com/${project.github_repo}/releases/tag/v${project.version}"
// Add all supported game versions
project.cf_game_versions.split(',').each { addGameVersion it }
project.cf_game_versions.split(', ').each { addGameVersion it }
// Add the main artifact
mainArtifact(remapJar) { displayName = "${project.mod_name} v${project.version} for Minecraft ${project.minecraft_version}" }
// Add any additional artifacts
Expand All @@ -109,32 +109,28 @@ curseforge {
}
// Add any dependencies
relations {
if (project.cf_relations_required) project.cf_relations_required.split(',').each { requiredDependency it }
if (project.cf_relations_optional) project.cf_relations_optional.split(',').each { optionalDependency it }
if (project.cf_relations_embedded) project.cf_relations_embedded.split(',').each { embeddedLibrary it }
if (project.cf_relations_tools) project.cf_relations_tools.split(',').each { tool it }
if (project.cf_relations_incompatible) project.cf_relations_incompatible.split(',').each { incompatible it }
if (project.cf_relations_required) project.cf_relations_required.split(', ').each { requiredDependency it }
if (project.cf_relations_optional) project.cf_relations_optional.split(', ').each { optionalDependency it }
if (project.cf_relations_embedded) project.cf_relations_embedded.split(', ').each { embeddedLibrary it }
if (project.cf_relations_tools) project.cf_relations_tools.split(', ').each { tool it }
if (project.cf_relations_incompatible) project.cf_relations_incompatible.split(', ').each { incompatible it }
}
}

// Configure other options
options {
forgeGradleIntegration = false
debug = System.getenv('CURSEFORGE_DEBUG') as boolean ?: false
}
}

// Define how artifacts are published to Modrinth (https://modrinth.com)
import com.modrinth.minotaur.TaskModrinthUpload
task modrinth(type: TaskModrinthUpload) {
// Set task metadata
description 'Uploads all Modrinth projects'
group 'upload'
allprojects.each { dependsOn it.build }

import com.modrinth.minotaur.dependencies.ModDependency
modrinth {
// Set the API token from the environment
token = System.getenv('MODRINTH_TOKEN') ?: ''
onlyIf { !token.isEmpty() }

// Set whether debug mode is enabled
debugMode = System.getenv('MODRINTH_DEBUG') as boolean ?: false
// Set the project id
projectId = project.mr_project_id
// Set the release name
Expand All @@ -146,23 +142,23 @@ task modrinth(type: TaskModrinthUpload) {
// Set the release notes
changelog = "For a list of changes, please refer to https://github.com/${project.github_repo}/releases/tag/v${project.version}"
// Add all supported mod loaders
addLoader 'fabric'
loaders = ['fabric']
// Add all supported game versions
project.mr_game_versions.split(',').each { addGameVersion it }
project.mr_game_versions.split(', ').each { gameVersions.add it }
// Add the main artifact
uploadFile = remapJar
// // Add any additional artifacts
// addFile sourcesJar
// addFile jar
// subprojects.each {
// addFile it.remapJar
// addFile it.sourcesJar
// addFile it.jar
// }
// Add any additional artifacts
additionalFiles.add sourcesJar
additionalFiles.add jar
subprojects.each {
additionalFiles.add it.remapJar
additionalFiles.add it.sourcesJar
additionalFiles.add it.jar
}
// Add any dependencies
if (project.mr_relations_required) project.mr_relations_required.split(',').each { addDependency it, 'required' }
if (project.mr_relations_optional) project.mr_relations_optional.split(',').each { addDependency it, 'optional' }
if (project.mr_relations_incompatible) project.mr_relations_incompatible.split(',').each { addDependency it, 'incompatible' }
if (project.mr_relations_required) dependencies.addAll project.mr_relations_required.split(', ').collect { new ModDependency(it, 'required') }
if (project.mr_relations_optional) dependencies.addAll project.mr_relations_optional.split(', ').collect { new ModDependency(it, 'optional') }
if (project.mr_relations_incompatible) dependencies.addAll project.mr_relations_incompatible.split(', ').collect { new ModDependency(it, 'incompatible') }
}

// Define how packages are published
Expand Down
Empty file added example-submod/CHANGELOG.md
Empty file.
2 changes: 2 additions & 0 deletions example-submod/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Mod
mod_name = Another Example
mod_id = modid-sub
## {x-release-please-start-version}
mod_version = 1.0.0
## {x-release-please-end}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import net.fabricmc.api.ModInitializer;

/**
* Another Example Minecraft mod.
*/
public class AnotherExample implements ModInitializer
{
public static final Logger LOGGER = LogManager.getLogger("modid-sub");
Expand Down
Loading

0 comments on commit e2727b1

Please sign in to comment.