Fix pipeline #45
Workflow file for this run
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: Build and Release Mod | |
on: | |
push: | |
branches: | |
- '**' | |
create: | |
tags: | |
- '*' | |
permissions: | |
contents: write | |
checks: write | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Run unit tests | |
run: ./gradlew test | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: build/test-results/test | |
- name: Upload test report | |
if: always() | |
uses: mikepenz/action-junit-report@v3 | |
with: | |
report_paths: '**/build/test-results/test/TEST-*.xml' | |
release: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Run unit tests | |
run: ./gradlew test | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: build/test-results/test | |
- name: Upload test report | |
if: always() | |
uses: mikepenz/action-junit-report@v3 | |
with: | |
report_paths: '**/build/test-results/test/TEST-*.xml' | |
- name: Build project | |
run: ./gradlew build | |
- name: Extract properties from gradle.properties | |
id: properties | |
run: | | |
modId=$(grep 'modId' gradle.properties | cut -d'=' -f2 | xargs) | |
modVersion=$(grep 'modVersion' gradle.properties | cut -d'=' -f2 | xargs) | |
minecraftFirstSnapshotVersion=$(grep 'minecraftFirstSnapshotVersion' gradle.properties | cut -d'=' -f2 | xargs) | |
minecraftReleaseVersion=$(grep 'minecraftReleaseVersion' gradle.properties | cut -d'=' -f2 | xargs) | |
fabricSupportedLoaders=$(grep 'fabricSupportedLoaders' gradle.properties | cut -d'=' -f2 | xargs) | |
echo "MOD_ID=$modId" >> $GITHUB_ENV | |
echo "MOD_VERSION=$minecraftReleaseVersion-$modVersion" >> $GITHUB_ENV | |
echo "MINECRAFT_VERSIONS=Minecraft: $minecraftFirstSnapshotVersion-$minecraftReleaseVersion" >> $GITHUB_ENV | |
echo "LOADERS=Loaders: $fabricSupportedLoaders" >> $GITHUB_ENV | |
echo "MINECRAFT_FIRST_SNAPSHOT_VERSION=$minecraftFirstSnapshotVersion" >> $GITHUB_ENV | |
echo "MINECRAFT_RELEASE_VERSION=$minecraftReleaseVersion" >> $GITHUB_ENV | |
- name: Get version changelog | |
id: changelog | |
run: | | |
VERSION=${{ env.MOD_VERSION }} | |
CHANGELOG=$(sed -n "/^## $VERSION$/,/^## [0-9]/p" CHANGELOG.md | sed '$d' | tail -n +2) | |
echo "CHANGELOG<<EOF" >> $GITHUB_ENV | |
echo "$CHANGELOG" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
shell: bash | |
- name: Combine release notes | |
id: combine | |
run: | | |
echo "${{ env.MINECRAFT_VERSIONS }}" > combined_changelog.txt | |
echo "${{ env.LOADERS }}" >> combined_changelog.txt | |
echo "" >> combined_changelog.txt | |
echo "## Changes" >> combined_changelog.txt | |
echo "" >> combined_changelog.txt | |
echo "${{ env.CHANGELOG }}" >> combined_changelog.txt | |
cat combined_changelog.txt | |
echo "FINAL_CHANGELOG<<EOF" >> $GITHUB_ENV | |
cat combined_changelog.txt >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: "Foggy Pale Garden ${{ env.MOD_VERSION }}" | |
files: build/libs/*.jar | |
body: ${{ env.FINAL_CHANGELOG }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to Modrinth | |
run: ./gradlew modrinth | |
env: | |
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
- name: Publish to CurseForge | |
run: ./gradlew curseforge | |
env: | |
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} |