What would be the ideal setup for my multi-platform project? #29
-
I have a project on Modrinth and looking at this action, I can see some good use in it. However, the thing is that my project in question, namely AdvancedServerList, is offering 4 distinct jar files for 4 different platforms to use on. So... What would be an optimal Action setup to publish the jar files to Modrinth without any major problems? I already have a GitHub Action to automatically add the Jar files to a new GitHub Release, so Jar files would be already available from that Action: https://github.com/Andre601/AdvancedServerList/blob/master/.github/workflows/release.yml |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
You can view your uploads as different versions of your plugin (because technically they are different versions), therefore, taking into consideration the fact that mc-publish is able to publish one version to one platform at a time, since I do not want to turn it into a LHC control panel, you need 4 calls to mc-publish (or 5, if you want to publish files to GitHub in batch, as you're doing right now). Considering all of the above, I would suggest you to replace your existing configuration with something like this: name: Build Jars
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 1.16
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '16'
- name: Build jar
run: mvn clean install
- name: Upload BungeeCord assets to GitHub and Modrinth
uses: Kir-Antipov/[email protected]
with:
name: 1.15.1 - BungeeCord
version: 1.15.1
files-primary: bungeecord/target/AdvancedServerList-*.jar
files-secondary: ""
loaders: bungeecord
game-versions: |
1.19
1.19.1
1.19.2
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Paper assets to GitHub and Modrinth
uses: Kir-Antipov/[email protected]
with:
name: 1.15.1 - Paper
version: 1.15.1
files-primary: paper/target/AdvancedServerList-*.jar
files-secondary: ""
loaders: paper
game-versions: |
1.19
1.19.1
1.19.2
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Spigot assets to GitHub and Modrinth
uses: Kir-Antipov/[email protected]
with:
name: 1.15.1 - Spigot
version: 1.15.1
files-primary: spigot/target/AdvancedServerList-*.jar
files-secondary: ""
loaders: spigot
game-versions: |
1.19
1.19.1
1.19.2
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Velocity assets to GitHub and Modrinth
uses: Kir-Antipov/[email protected]
with:
name: 1.15.1 - Velocity
version: 1.15.1
files-primary: velocity/target/AdvancedServerList-*.jar
files-secondary: ""
loaders: velocity
game-versions: |
1.19
1.19.1
1.19.2
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }} In order to make the configuration a little bit more readable and compact you could use matrices: name: Build Jars
on:
release:
types: [published]
jobs:
build:
strategy:
matrix:
include:
- platform: bungeecord
name: BungeeCord
- platform: paper
name: Paper
- platform: spigot
name: Spigot
- platform: velocity
name: Velocity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 1.16
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '16'
- name: Build jar
run: mvn clean install
- name: Get GitHub Release version
id: release-version
run: |
version=$(echo ${{ github.event.release.tag_name }} | cut -d'v' -f2)
echo "::set-output name=version::$version"
- name: Upload ${{ matrix.name }} assets to GitHub and Modrinth
uses: Kir-Antipov/[email protected]
with:
name: ${{ steps.release-version.outputs.version }} - ${{ matrix.name }}
version: ${{ steps.release-version.outputs.version }}
files-primary: ${{ matrix.platform }}/target/AdvancedServerList-*.jar
files-secondary: ""
loaders: ${{ matrix.platform }}
game-versions: |
1.19
1.19.1
1.19.2
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }} Hope this helps :) |
Beta Was this translation helpful? Give feedback.
-
Thank you for the really detailed info! I made a few minor changes to the action you showed (The one with the matrices) to fit some specific needs and I have a few minor questions I would appreciate to get answer for. Where does the action retrieve the Modrinth Project ID from? The readme mentions "a value specified in the config file" as its default value, but that is quite vague... What config? I made some adjustments to the matrix setting. I would like to include the changelog from the release, so if I understand it correctly would I set I for now made a PR, so that you can hopefully take a look and give some feedback. |
Beta Was this translation helpful? Give feedback.
-
Right, you need to provide it by yourself. Also, you can click on any input to get more information about it, e.g. #modrinth-id provides examples of acceptable "config" files. Since this action was made primarily for mod uploads, mc-publish understands Fabric metadata, Forge metadata, and Quilt metadata, at least at this moment in time. You do not fall in these categories, so, sadly, you cannot rely on most of the default value resolvers, but you still can use the action to upload your assets to GitHub, Modrinth, and Curseforge, you just need to specify the required stuff manually
It's better to separate values in array-like inputs with the new line symbol, because it is acceptable and understandable by all of them, but for
This is one of the things you do not need to worry about just because you have a plugin and not a mod. |
Beta Was this translation helpful? Give feedback.
-
This made me have a question I forgot to ask. With the current setup using the Matrix, will all the different jars from the different iterations of the Matrix be included in the GitHub release? Because I do include them all in the GitHub release for that matter.
So, I was considering to use the
Good to know, thank you. |
Beta Was this translation helpful? Give feedback.
-
Yup,
The problem with GitHub Actions is they do not allow users to specify complex objects as inputs. GitHub Action developers receive all the inputs as strings and it's absolutely terrible. I'd love it if it was possible for users to specify, for example, a valid yaml array and I could read it as an... array: loaders: [bungeecord, waterfall] But this is just not possible. So, users need to give us strings, and we need to parse them and convert into arrays ¯\(ツ)/¯ |
Beta Was this translation helpful? Give feedback.
-
I've made a small release and it worked, so thanks for this setup. run: |
mvn clean # Even needed? Since it usually is a blank workspace
mvn install --project :core,:${{ matrix.directory }} so that I would only build the core + module I need for the respective matrix entry... I also had a small typo in the action (github-toke instead of github-token). Good thing the action pointed it out. 😅 |
Beta Was this translation helpful? Give feedback.
You can view your uploads as different versions of your plugin (because technically they are different versions), therefore, taking into consideration the fact that mc-publish is able to publish one version to one platform at a time, since I do not want to turn it into a LHC control panel, you need 4 calls to mc-publish (or 5, if you want to publish files to GitHub in batch, as you're doing right now).
Considering all of the above, I would suggest you to replace your existing configuration with something like this: