Skip to content

Setup a GitHub actions publish workflow #4

Setup a GitHub actions publish workflow

Setup a GitHub actions publish workflow #4

Workflow file for this run

name: Publish on GitHub, Curseforge and Modrinth
on:
push:
tags:
- 'v*'
jobs:
setup:
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: 'adopt'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Make Gradle Wrapper Executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
validation:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v3
version:
runs-on: ubuntu-latest
needs: setup
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: [ setup, validation, version ]
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
packages: write
env:
VERSION: ${{ needs.version.outputs.version_number }}
VERSION_TYPE: ${{ needs.version.outputs.version_type }}
steps:
- name: Log Version Info
run: echo "version = $VERSION, type = $VERSION_TYPE"
- name: Build
uses: gradle/gradle-build-action@v2
with:
arguments: build
- 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