Skip to content

Build #17

Build #17 #17

Workflow file for this run

name: Build
run-name: "Build #${{ github.run_number }}"
on:
push:
tags:
- 'v*'
branches:
- main
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
jobs:
changelog:
name: Changelog
runs-on: ubuntu-latest
outputs:
latest_tag: ${{ steps.changelog.outputs.latest_tag }}
version: ${{ steps.changelog.outputs.version }}
rel_type: ${{ steps.changelog.outputs.rel_type }}
changelog_text: ${{ steps.changelog.outputs.changelog_text }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Changelog
id: changelog
shell: bash
run: |
latest_tag=$(git describe --tags --abbrev=0)
{ grep --color=auto -Pzo "(?<=## $latest_tag)((?!\n## )[\s\S])*" ./CHANGELOG.md || true; } | sed '$ s/.$//' > ./NEW_CHANGELOG.md
rel_type="release"
case $latest_tag in
*alpha*) rel_type="alpha" ;;
*beta*) rel_type="beta" ;;
*) rel_type="release" ;;
esac
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT
echo "version=${latest_tag/v}" >> $GITHUB_OUTPUT
echo "rel_type=$rel_type" >> $GITHUB_OUTPUT
{
echo 'changelog_text<<EOF'
cat ./NEW_CHANGELOG.md
echo EOF
} >> $GITHUB_OUTPUT
- name: Upload Changelog
uses: actions/upload-artifact@v4
with:
name: changelog
path: ${{ github.workspace }}/NEW_CHANGELOG.md
build-jvm-jar:
name: Build JVM Jar
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build the mod
run: ./gradlew --no-daemon build
- name: Upload JVM Jar
uses: actions/upload-artifact@v4
with:
name: jvm-jar
path: build/libs/*
release-github:
name: Release GitHub
runs-on: ubuntu-latest
needs: [changelog, build-jvm-jar]
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download Artifact Changelog
uses: actions/download-artifact@v4
with:
name: changelog
- name: Download Artifact JVM Jar
uses: actions/download-artifact@v4
with:
name: jvm-jar
path: jar
- name: Create release
uses: softprops/action-gh-release@v1
with:
body_path: ./NEW_CHANGELOG.md
prerelease: false
token: ${{ secrets.PUSH_ACCESS_TOKEN }}
files: |
jar/*
release-curseforge:
name: Release CurseForge
runs-on: ubuntu-latest
needs: [changelog, build-jvm-jar]
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download Artifact Changelog
uses: actions/download-artifact@v4
with:
name: changelog
- name: Download Artifact JVM Jar
uses: actions/download-artifact@v4
with:
name: jvm-jar
path: jar
- name: Create release
id: cf_release
uses: itsmeow/[email protected]
with:
token: ${{ secrets.CF_TOKEN }}
project_id: 574029
file_path: jar/Greenery-1.12.2-${{ needs.changelog.outputs.version }}.jar
display_name: Greenery-1.12.2-${{ needs.changelog.outputs.version }}
changelog: ${{ needs.changelog.outputs.changelog_text }}
changelog_type: markdown
game_versions: "Minecraft 1.12.2, Forge"
game_endpoint: minecraft
release_type: ${{ needs.changelog.outputs.rel_type }}
release-modrinth:
name: Release Modrinth
runs-on: ubuntu-latest
needs: [changelog, build-jvm-jar]
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download Artifact Changelog
uses: actions/download-artifact@v4
with:
name: changelog
- name: Download Artifact JVM Jar
uses: actions/download-artifact@v4
with:
name: jvm-jar
path: jar
- name: Upload to Modrinth
uses: dsx137/[email protected]
env:
MODRINTH_TOKEN: ${{ secrets.MR_TOKEN }}
with:
name: Greenery-1.12.2-${{ needs.changelog.outputs.version }}
project_id: EVaCo3rr
loaders: forge
game_versions: 1.12.2, 1.12.1, 1.12
version_number: ${{ needs.changelog.outputs.version }}
changelog: ${{ needs.changelog.outputs.changelog_text }}
version_type: ${{ needs.changelog.outputs.rel_type }}
files: |
jar/Greenery-1.12.2-${{ needs.changelog.outputs.version }}.jar