Skip to content

Commit

Permalink
Implement new gitlab workflow; remove modrith gradle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ruf committed Dec 13, 2023
1 parent 76ae34f commit e581e07
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 89 deletions.
142 changes: 76 additions & 66 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ on:
tags:
- '*'

env:
# For any reason, specifying this in the modrinth step does not work?
# But it is also well documented here, so this should be ok to do
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['1.19', '1.19.1', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2']
fail-fast: true
steps:
- name: Check tag condition or manual request of build
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
run: echo "Ref is a tag or this build was requested manually"

- name: Check out project
if: success()
uses: actions/checkout@v3
Expand All @@ -38,44 +33,36 @@ jobs:
with:
gradle-version: 8.3

- name: Build v1.19
if: success()
run: gradle remapJar -Pv=1.19

- name: Build v1.19.1
if: success()
run: gradle remapJar -Pv=1.19.1

- name: Build v1.19.2
- name: Build
if: success()
run: gradle remapJar -Pv=1.19.2
run: gradle remapJar -Pv=${{ matrix.version }}

- name: Build v1.19.3
- name: Upload artifact
if: success()
run: gradle remapJar -Pv=1.19.3

- name: Build v1.19.4
if: success()
run: gradle remapJar -Pv=1.19.4

- name: Build v1.20
if: success()
run: gradle remapJar -Pv=1.20
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.version }}
path: |
**/libs/server-portals-*.jar
- name: Build v1.20.1
if: success()
run: gradle remapJar -Pv=1.20.1
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out metadata
uses: actions/checkout@v3
with:
sparse-checkout: |
README.md
CHANGELOG.md
LICENSE
- name: Build v1.20.2
- name: Download artifacts
if: success()
run: gradle remapJar -Pv=1.20.2

- name: Check tag condition before release
if: success() && startsWith(github.ref, 'refs/tags/')
run: echo "Ref is a tag"
uses: actions/download-artifact@v3

- name: Release on GitHub
if: success()
- name: Release on github
if: success() # No git tag check, since action-gh-release fails if not valid
uses: softprops/action-gh-release@v1
with:
files: |
Expand All @@ -88,34 +75,57 @@ jobs:
prerelease: false
fail_on_unmatched_files: true

- name: Upload to modrinth v1.19
if: success()
run: gradle modrinth -Pv=1.19

- name: Upload to modrinth v1.19.1
if: success()
run: gradle modrinth -Pv=1.19.1

- name: Upload to modrinth v1.19.2
if: success()
run: gradle modrinth -Pv=1.19.2

- name: Upload to modrinth v1.19.3
if: success()
run: gradle modrinth -Pv=1.19.3

- name: Upload to modrinth v1.19.4
if: success()
run: gradle modrinth -Pv=1.19.4
publish:
runs-on: ubuntu-latest
needs: release
strategy:
matrix:
version: ['1.19', '1.19.1', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2']
fail-fast: true
steps:
- name: Check out metadata
uses: actions/checkout@v3
with:
sparse-checkout: |
CHANGELOG.md
- name: Upload to modrinth v1.20
- name: Download artifact
if: success()
run: gradle modrinth -Pv=1.20
uses: actions/download-artifact@v3
with:
name: build-${{ matrix.version }}

- name: Upload to modrinth v1.20.1
if: success()
run: gradle modrinth -Pv=1.20.1
- name: Publish on modrinth
if: success() && startsWith(github.ref, 'refs/tags/') # Failsafe check
# See https://github.com/Kir-Antipov/mc-publish
uses: Kir-Antipov/[email protected]
with:
modrinth-id: server-portals
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
modrinth-featured: false
files: |
**/libs/server-portals-*.jar
name: Server Portals ${{ github.ref_name }}
version: ${{ github.ref_name }}+${{ matrix.version }}
version-type: "${{ contains(github.ref_name, 'SNAPSHOT') && 'alpha' || 'release' }}"
changelog-file: CHANGELOG.md
#loaders: fabric
game-versions: "=${{ matrix.version }}"
#dependencies:

publish_readme:
runs-on: ubuntu-latest
needs: publish
steps:
- name: Check out metadata
uses: actions/checkout@v3
with:
sparse-checkout: |
README.md
- name: Upload to modrinth v1.20.2
- name: Update readme
if: success()
run: gradle modrinth -Pv=1.20.2
run: |
readme="$(sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/' README.md)"
json="{ \"body\": \"$readme\" }"
echo "$json" | curl -XPATCH -H "Authorization: ${{ secrets.MODRINTH_TOKEN }}" -H "Content-type: application/json" -d @- 'https://api.modrinth.com/v2/project/server-portals'
23 changes: 23 additions & 0 deletions .github/workflows/remove-old-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://github.com/marketplace/actions/remove-artifacts
name: Remove old artifacts

on:
schedule:
# Every day at 1am
- cron: '0 1 * * *'

jobs:
remove-old-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
# '<number> <unit>', e.g. 5 days, 2 years, 90 seconds, parsed by Moment.js
age: '2 days'

# Optional inputs
# skip-tags: true
# skip-recent: 5
23 changes: 0 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import de.michiruf.gradle.findversion.FindVersion
plugins {
id 'java'
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'com.modrinth.minotaur' version '2.+'
}

apply from: 'build.allprojects.gradle'
Expand Down Expand Up @@ -47,28 +46,6 @@ dependencies {
modImplementation include("eu.pb4:${minecraftVersionDefinition['polymer']}") { exclude group: 'net.fabricmc.fabric-api' }
}

def buildJarFile = file("build/libs/${rootProject.name}-${project.version}.jar")
modrinth {
projectId = rootProject.name
versionNumber = project.version
versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release'
gameVersions = [minecraftVersion]
loaders = ['fabric']
dependencies {
required.project 'fabric-api'
required.project 'owo-lib'
}
if(buildJarFile.exists())
uploadFile = buildJarFile;
else
uploadFile = remapJar
syncBodyFrom = rootProject.file("README.md").text

// Use the environment variable `$MODRINTH_TOKEN` for the token
// token = 'mySecretToken'
}
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)

processResources {
var replaceProperties = [
version : project.version,
Expand Down

0 comments on commit e581e07

Please sign in to comment.