Release (2.0.0+1.20) #15
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: Release | |
run-name: Release (${{ inputs.version }}) | |
on: | |
workflow_dispatch: | |
inputs: | |
is-release: | |
description: Publish release | |
required: true | |
type: boolean | |
version: | |
description: Pack version (e.g. 1.3.1+1.21) | |
required: true | |
type: string | |
jobs: | |
create-release: | |
name: Create release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: "write" | |
id-token: write | |
attestations: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Ensure Gradle wrapper is executable | |
run: chmod +x ./gradlew | |
- name: Validate Gradle | |
uses: gradle/actions/wrapper-validation@v4 | |
- name: Get Data | |
id: get-data | |
run: | | |
java_version=$(grep '^java_version=' gradle.properties | cut -d= -f2) | |
minecraft_version=$(grep '^minecraft_version=' gradle.properties | cut -d= -f2) | |
mod_id=$(cat src/client/resources/fabric.mod.json | jq -r '.id') | |
mod_name=$(cat src/client/resources/fabric.mod.json | jq -r '.name') | |
modrinth_project_id=$(cat src/client/resources/fabric.mod.json | jq -r '.custom["mc-publish"].modrinth') | |
echo "java-version=$java_version" >> "$GITHUB_OUTPUT" | |
echo "minecraft-version=$minecraft_version" >> "$GITHUB_OUTPUT" | |
echo "mod-id=$mod_id" >> "$GITHUB_OUTPUT" | |
echo "mod-name=$mod_name" >> "$GITHUB_OUTPUT" | |
echo "modrinth-project-id=$modrinth_project_id" >> "$GITHUB_OUTPUT" | |
- name: Setup Java ${{ steps.get-data.outputs.java-version }} | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ steps.get-data.outputs.java-version }} | |
distribution: "zulu" | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Get deploy info | |
id: deploy-info | |
run: | | |
# Also update the mod version in gradle | |
sed -i "s/^mod_version=.*/mod_version=${{ inputs.version }}/" gradle.properties | |
release_name="${{ steps.get-data.outputs.mod-name }} v${{ inputs.version }}" | |
echo "release-name=$release_name" >> "$GITHUB_OUTPUT" | |
version_slug="v${{ inputs.version }}" | |
echo "version-slug=$version_slug" >> "$GITHUB_OUTPUT" | |
icon_url=$(curl -A "secret_online/mod-auto-updater (mc@secretonline.co)" "https://api.modrinth.com/v2/project/${{ steps.get-data.outputs.modrinth-project-id }}" | jq --raw-output ".icon_url") | |
echo "icon-url=$icon_url" >> "$GITHUB_OUTPUT" | |
- name: Parse changelog | |
id: changelog | |
uses: release-flow/keep-a-changelog-action@v3 | |
with: | |
command: query | |
version: v${{ inputs.version }} | |
changelog: CHANGELOG.md | |
- name: Build | |
run: ./gradlew clean build | |
- name: Print release details | |
run: | | |
echo "name: ${{ steps.deploy-info.outputs.release-name }}" | |
echo "version: v${{ inputs.version }}" | |
echo "changelog: ${{ steps.changelog.outputs.release-notes }}" | |
echo "icon-url: ${{ steps.deploy-info.outputs.icon-url }}" | |
# - uses: actions/attest-build-provenance@v1 | |
# if: inputs.is-release | |
# with: | |
# subject-path: "build/libs/*.jar" | |
- name: Create GitHub release | |
if: inputs.is-release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.deploy-info.outputs.version-slug }} | |
name: ${{ steps.deploy-info.outputs.release-name }} | |
body: ${{ steps.changelog.outputs.release-notes }} | |
files: | | |
build/libs/!(*-sources).jar | |
build/libs/*-sources.jar | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Modrinth Release | |
if: inputs.is-release | |
id: modrinth-release | |
uses: Kir-Antipov/mc-publish@v3.3 | |
with: | |
name: ${{ steps.deploy-info.outputs.release-name }} | |
version: ${{ steps.deploy-info.outputs.version-slug }} | |
changelog: ${{ steps.changelog.outputs.release-notes }} | |
loaders: fabric | |
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | |
- name: Update Modrinth decription | |
if: inputs.is-release | |
uses: funnyboy-roks/modrinth-auto-desc@v1.6 | |
with: | |
auth-token: ${{ secrets.MODRINTH_TOKEN }} | |
slug: ${{ steps.get-data.outputs.modrinth-project-id }} | |
readme: MODRINTH.md | |
- name: Post release to Discord | |
if: inputs.is-release | |
uses: tsickert/discord-webhook@v6.0.0 | |
with: | |
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
content: | | |
${{ steps.deploy-info.outputs.release-name }} has been released! https://modrinth.com/mod/${{ steps.get-data.outputs.mod-id }}/version/${{ steps.deploy-info.outputs.version-slug }} |