-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variables to build release name? #80
Comments
Well, it doesn't really. It merely illustrates that this is a string input. The method you employ to generate and/or provide the required string is entirely up to you.
Currently, there's no inherent mechanism to accomplish this (provided you're only using Furthermore, someone has already proposed employing home-brewed string interpolation for such scenarios. I'm genuinely contemplating this, but it's not a high priority right now. I need to finalize a wiki for this project, implement comprehensive support for modpacks and plugins (currently, That being said, the format would differ slightly from your proposal - I can't use
This is precisely what I suggest for such scenarios, and this is the reason I'm not in hurry to incorporate custom string interpolation logic into my code - the scenario you describe can be fully automated already, it's just not as convenient, as if a feature like that would be built-in into I'll keep this issue open, as I'm truly interested in integrating the requested feature, although not right-right now. |
Yeah basically I am! I'm not much experienced with GH Actions, and I believe something that keeps the CI file in sync with elsewhere in the project is really an anti-pattern - it's really a workaround.
Understandable, and honestly from my POV it doesn't matter what the format is as long as it works 😉 Anyways, I'll share what I've thrown together below for my project. I've used .publish-example-ci.ymlname: Gradle Release Artifact
on:
release:
types: [ created ]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build Fabric
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: Fabric:build
- name: Build Forge
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: Forge:build
- uses: actions/upload-artifact@v3
with:
name: builds
if-no-files-found: error
path: |
Fabric/build/libs/*.jar
Forge/build/libs/*.jar
publish:
runs-on: ubuntu-latest
needs:
- build
strategy:
matrix:
mod-loader: [Fabric, Forge]
steps:
- uses: actions/download-artifact@v3
with:
name: builds
- name: Publish Fabric
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: rkN8aqci
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: 625069
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
name: [${{ matrix.mod-loader }} $mc{ mcVersion }] $mc{ modVersion }
changelog-file: CHANGELOG.md
java: 17
files: |
${{ matrix.mod-loader }}/build/libs/!(*-@(dev|sources|javadoc)).jar
${{ matrix.mod-loader }}/build/libs/*-@(dev|sources|javadocs).jar Edit: |
And yet you use
Could you clarify your point here, please? GitHub Actions are intrinsically linked with the activities in your repository and its state. If you're referencing automatic alterations of workflow files, that's not what I was advocating for. I was suggesting finding a way to automate your objective inside the workflow itself, since there are no string interpolation capabilities in
This is exactly why I built this action :) Maintaining even a single project across multiple platforms can be daunting, let alone when dealing with several ones!
I appreciate your efforts. Now let's actually make your configuration work, shall we? So, here are the changes I propose:
So, here's an enhanced version of your configuration: name: Gradle Release Artifact
on:
release:
types: [created]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
mod-loader: [Fabric, Forge]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Extract versions from tag name
id: versions
run: |
readarray -td "-" VERSIONS <<< "${GITHUB_REF#refs/tags/}-"
echo "minecraft-version=${VERSIONS[0]}" >> "${GITHUB_OUTPUT}"
echo "mod-version=${VERSIONS[1]}" >> "${GITHUB_OUTPUT}"
- name: Build ${{ matrix.mod-loader }}
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: ${{ matrix.mod-loader }}:build
- name: Publish ${{ matrix.mod-loader }}
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: rkN8aqci
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: 625069
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
name: [${{ matrix.mod-loader }} ${{ steps.versions.outputs.minecraft-version }}] ${{ steps.versions.outputs.mod-version }}
changelog-file: CHANGELOG.md
java: 17
files: |
${{ matrix.mod-loader }}/build/libs/!(*-@(dev|sources|javadoc)).jar
${{ matrix.mod-loader }}/build/libs/*-@(dev|sources|javadocs).jar Let me know if it does the job for you! |
It's amazing how much I convinced you just by me writing this after reading the CI docs haha 😉
Perhaps I've been thinking about this the wrong way? I've come from using GitLab's CI a lot for my job, so I've quite used to being able to just simply write scripts for jobs rather than relying on actions for all their logic 😅 Anyways, I've read ahead and seen you've solved this haha.
That's fair, as you say it's pretty pointless here. Again, I've been used to how simple it is with GitLab and usually we separate jobs into separate distinct tasks. But yeah again, I'm literally only doing one process here. Anyways, looking at what you've suggested, I didn't realise you could actually run Bash in a step! I'll get this implemented and let you know how it goes next time I make a new release 😄 Thanks for all your help! |
Actually looking back, about this:
I realised I did it because I have the EDIT: Oh actually don't worry, I just realised you moved the build step inside the matrix! I didn't realise you could use the matrix variable in the way you did 😄 |
Hey, I'm just setting this up for one of my projects for the first time. However the docs in your README suggest that the
name
argument should be hardcoded...Is there not any way I can have the
name
created using version numbers that the action should already know?For example, what I want to achieve is something like:
That would aim to produce something like:
[Fabric 1.19.4] 1.0.0
My mod is using a multi-loader setup, so it supports both Fabric and Forge, hence the suggested
loader
variable there too. Although thinking about it more, this might be more appropriate using a matrix so that I can supply the correct files too, since they'll be in different locations per loader.Aim here is preventing any need to edit the CI pipeline constantly, as this should not be necessary.
The text was updated successfully, but these errors were encountered: