Skip to content

Commit

Permalink
Merge branch 'master' into 24w46a
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Nov 20, 2024
2 parents e2b896f + ac09361 commit b8f40bb
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 53 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/dependency_graph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Update Gradle Dependency Graph

on:
push:
branches:
# Submitting dependency graph reports on non-default branches does nothing
- "master"
tags-ignore:
- "**"
paths:
- "gradle**"
- "*.gradle"
workflow_dispatch:

permissions:
contents: write

jobs:
dependency-submission:
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "microsoft"

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v4
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"
79 changes: 57 additions & 22 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,41 @@ name: Java CI with Gradle

on:
push:
branches:
- "**"
tags-ignore:
- "**"
paths:
- '**.java'
- '**.json'
- 'gradle**'
- 'build.gradle'
- "**.java"
- "**.json"
- "**.yml"
- "gradle**"
- "*.gradle"
pull_request:
paths:
- '**.java'
- '**.json'
- 'gradle**'
- 'build.gradle'
# Makes it possible to run this workflow manually from the Actions tab
- "**.java"
- "**.json"
- "**.yml"
- "gradle**"
- "*.gradle"
workflow_dispatch:

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest

env:
VIRUSTOTAL_API_KEY: ${{ secrets.VIRUSTOTAL_API_KEY }}
IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }}
steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'microsoft'
java-version: "21"
distribution: "microsoft"

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -45,18 +50,48 @@ jobs:
# Enable cache writing for NeoForge branches, since they don't benefit from the Fabric cache on master
cache-read-only: ${{ github.ref != 'refs/heads/master' && !contains(github.ref, 'neoforge') }}

- name: Generate and submit dependency graph
if: ${{ github.event_name == 'push' }}
uses: gradle/actions/dependency-submission@v4
- name: Compile Java code
run: ./gradlew remapJar --stacktrace --warning-mode=fail

- name: Validate JSON files
run: ./gradlew spotlessJsonCheck || (echo "::error::JSON validation failed! Run './gradlew spotlessApply' to fix style issues, or check the full error message for syntax errors." && exit 1)

- name: Run tests and build
- name: Validate Java code style
run: ./gradlew spotlessCheck || (echo "::error::Java code style validation failed! To fix, run 'Clean Up' and then 'Format' in Eclipse, or './gradlew spotlessApply' in the terminal." && exit 1)

- name: Run unit tests
run: ./gradlew test --stacktrace --warning-mode=fail

- name: Validate access widener
run: ./gradlew validateAccessWidener --stacktrace --warning-mode=fail

- name: Build
run: ./gradlew build --stacktrace --warning-mode=fail

- name: VirusTotal scan
if: ${{ github.event_name == 'push' }}
- name: Upload to VirusTotal for analysis
id: virustotal
if: ${{ env.VIRUSTOTAL_API_KEY }}
uses: crazy-max/ghaction-virustotal@v4
with:
vt_api_key: ${{ secrets.VIRUSTOTAL_API_KEY }}
vt_api_key: ${{ env.VIRUSTOTAL_API_KEY }}
files: |
./build/libs/*.jar
# An error in this step means that the upload failed, not that a false
# positive was detected.
continue-on-error: true

- name: Add VirusTotal links to build summary
if: ${{ env.VIRUSTOTAL_API_KEY && steps.virustotal.outputs.analysis }}
shell: bash
run: |
echo "<details open>" >> $GITHUB_STEP_SUMMARY
echo "<summary>🛡️ VirusTotal Scans</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
IFS=',' read -ra ANALYSIS <<< "${{ steps.virustotal.outputs.analysis }}"
for i in "${ANALYSIS[@]}"; do
filepath=${i%%=*}
url=${i#*=}
filename=$(basename "$filepath")
echo "- [$filename]($url)" >> $GITHUB_STEP_SUMMARY
done
echo "</details>" >> $GITHUB_STEP_SUMMARY
20 changes: 0 additions & 20 deletions .github/workflows/jsonsyntax.yml

This file was deleted.

87 changes: 87 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Publish Release

on:
workflow_dispatch:
inputs:
close_milestone:
description: "Close milestone"
required: true
type: boolean
default: true
upload_backups:
description: "Upload to backups server"
required: true
type: boolean
default: true
publish_github:
description: "Publish to GitHub"
required: true
type: boolean
default: true
publish_curseforge:
description: "Publish to CurseForge"
required: true
type: boolean
default: true
publish_modrinth:
description: "Publish to Modrinth"
required: true
type: boolean
default: true

jobs:
publish:
runs-on: ubuntu-latest
env:
WI_BACKUPS_API_KEY: ${{ secrets.WI_BACKUPS_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

steps:
- uses: actions/checkout@v4

- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "microsoft"

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build
run: ./gradlew build --stacktrace --warning-mode=fail

- name: Create and push tag
run: |
MOD_VERSION=$(grep "mod_version" gradle.properties | cut -d'=' -f2 | tr -d ' ')
git config --global user.name "Wurst-Bot"
git config --global user.email "[email protected]"
git tag v$MOD_VERSION
git push origin v$MOD_VERSION
- name: Close milestone
if: ${{ inputs.close_milestone }}
run: ./gradlew closeMilestone --stacktrace

- name: Upload backups
if: ${{ inputs.upload_backups }}
run: ./gradlew uploadBackups --stacktrace

- name: Publish to GitHub
if: ${{ inputs.publish_github }}
env:
GITHUB_TOKEN: ${{ secrets.MCX_PUBLISH_TOKEN }}
run: ./gradlew github --stacktrace

- name: Publish to CurseForge
if: ${{ inputs.publish_curseforge }}
run: ./gradlew publishCurseforge --stacktrace

- name: Publish to Modrinth
if: ${{ inputs.publish_modrinth }}
run: ./gradlew publishModrinth --stacktrace
4 changes: 3 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: "Close stale issues and pull requests"
name: Close stale issues and pull requests

on:
schedule:
- cron: "30 1 * * 1-5"
Expand All @@ -11,6 +12,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:

- uses: actions/stale@v9
with:
stale-issue-message: |
Expand Down
Loading

0 comments on commit b8f40bb

Please sign in to comment.