Skip to content

Commit

Permalink
Setup a GitHub actions publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Traister101 committed Oct 7, 2024
1 parent 1064ed9 commit f6fea4e
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 3 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Publish on GitHub, Curseforge and Modrinth

on:
push:
tags:
- 'v*'

jobs:
version:
runs-on: ubuntu-latest
outputs:
version_number: "${{ steps.version_number.outputs.result }}"
version_type: "${{ steps.version_type.outputs.result }}"
steps:
- name: Get Version
id: version_number
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
let ref = '${{ github.ref }}';
return ref.startsWith('refs/tags/v') ? ref.replace('refs/tags/v', '') : 'indev';
- name: Get Version Type
id: version_type
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
let version = '${{ steps.version.outputs.result }}';
return version.includes('alpha') ? 'alpha' : (version.includes('beta') ? 'beta' : 'release');
main:
needs: [ version ]
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: write
packages: write
env:
VERSION: ${{ needs.version.outputs.version_number }}
VERSION_TYPE: ${{ needs.version.outputs.version_type }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Make Gradle Wrapper Executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew

- name: Log Version Info
run: echo "version = $VERSION, type = $VERSION_TYPE"

- name: Build
run: ./gradlew build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish (CurseForge/Modrinth/GitHub)
uses: Kir-Antipov/[email protected]
with:
# TODO update this after ensuring CI produces a working jar
# modrinth-id: PhnM3Lkv
# modrinth-token: ${{ secrets.MODRINTH_API_KEY }}
#
# curseforge-id: 695822
# curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}

github-tag: ${{ github.ref }}
github-draft: true
github-prerelease: false
github-token: ${{ secrets.GITHUB_TOKEN }}

name: "Sacks 'N Such-1.20.1-${{ env.VERSION }}"
version: "${{ env.VERSION }}"
version-type: "${{ env.VERSION_TYPE }}"

files: |
build/libs/!(*-@(dev|sources|javadoc))-all.jar
loaders: |
forge
neoforge
game-versions: "1.20.1"
java: 17
changelog-file: CHANGELOG.md
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Bug fixes

- Fix duplication bug when picking up items which entirely refill all partial slots with at least one left over

### Changes

- Added new tag 'allowed_in_ore_sack' for items which can go into ore sacks (wow crazy)
- Not ugly Icon courtesy of Aleki
13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ final String mappingsVersion = project.findProperty("mappings_version") as Strin
final boolean minifyResources = project.findProperty("minify_resources") as Boolean ?: true
final boolean useAdvancedClassRedef = project.findProperty("use_advanced_class_redefinition") as Boolean ?: false

final String modVersion = System.getenv("VERSION") ?: "0.0.0-indev"

base {
archivesName.set("$modName-$minecraftVersion")
group = "mod.traister101" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down Expand Up @@ -161,7 +163,15 @@ repositories {
includeGroup "vazkii.patchouli"
}
}
mavenLocal()
maven {
name "Extended Slot Capacity github package"
// https://github.com/Traister101/ExtendedSlotCapacity
url uri("https://maven.pkg.github.com/traister101/ExtendedSlotCapacity")
credentials {
username = project.findProperty("githubUser") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("githubToken") ?: System.getenv("GITHUB_TOKEN")
}
}
}

dependencies {
Expand All @@ -179,7 +189,6 @@ dependencies {

annotationProcessor("org.spongepowered:mixin:0.8.5:processor")

// https://github.com/Traister101/ExtendedSlotCapacity
implementation jarJar(fg.deobf("mod.traister101:Extended-Slot-Capacity-1.20.1:$extendedSlotCapacityVersion")) {
jarJar.ranged(it as Dependency, "[$extendedSlotCapacityVersion,)")
}
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ org.gradle.daemon=false
# Mod stuff
modID=sns
modName=Sacks \'N Such
modVersion=1.0.0
# MC version
minecraftVersion=1.20.1
# Forge version
Expand Down

0 comments on commit f6fea4e

Please sign in to comment.