Publish #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Publish' | |
on: | |
workflow_dispatch: | |
inputs: | |
label: | |
type: choice | |
description: 'Version label' | |
options: | |
- -beta | |
- -alpha | |
default: '' | |
required: false | |
permissions: | |
contents: write | |
statuses: write | |
jobs: | |
build: | |
name: 'Build' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
loader: [ 'Forge', 'Fabric' ] | |
steps: | |
- name: 'Checkout repository' | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
fetch-tags: true | |
- name: 'Set up JDK 17' | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: 'Build ${{ matrix.loader }} with Gradle' | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: :${{ matrix.loader }}:build | |
cache-read-only: false | |
- name: 'Upload ${{ matrix.loader }} artifacts' | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: 'Artifacts-${{ matrix.loader }}' | |
path: ${{ matrix.loader }}/build/libs/*.jar | |
publish: | |
name: 'Publish' | |
runs-on: ubuntu-latest | |
needs: [build] | |
continue-on-error: true | |
steps: | |
- name: 'Checkout repository' | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
fetch-tags: true | |
- name: 'Set up JDK 17' | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: 'Publish with Gradle' | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: publishMod | |
cache-read-only: false | |
env: | |
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} | |
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
release: | |
name: 'Create release' | |
runs-on: ubuntu-latest | |
needs: [build, publish] | |
continue-on-error: true | |
steps: | |
- name: 'Checkout repository' | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
fetch-tags: true | |
- name: 'Get latest tag' | |
id: latest-tag | |
uses: WyriHaximus/github-action-get-previous-tag@v1 | |
with: | |
fallback: '0.0.0.0' | |
- name: 'Download ${{ matrix.loader }} artifacts' | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: 'Artifacts-*' | |
path: artifacts/ | |
merge-multiple: true | |
- name: 'Create release' | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: "${{ github.event.repository.name }}-${{ github.ref_name }}-${{ steps.latest-tag.outputs.tag }}${{ inputs.label }}" | |
tag_name: ${{ steps.latest-tag.outputs.tag }} | |
target_commitish: ${{ github.ref }} | |
body_path: CHANGELOG.md | |
files: | | |
'artifacts/*' | |
'!artifacts/*-slim.*' |