Skip to content

Merge pull request #553 from P3pp3rF1y/1.21.x-dev #970

Merge pull request #553 from P3pp3rF1y/1.21.x-dev

Merge pull request #553 from P3pp3rF1y/1.21.x-dev #970

Workflow file for this run

name: Mod Build
on: [ workflow_dispatch, push ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 200
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: zulu
cache: gradle
- name: Build with Gradle
env:
USERNAME: ${{ secrets.USERNAME }}
READ_PACKAGES_TOKEN: ${{ secrets.READ_PACKAGES_TOKEN }}
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: ./gradlew build
- name: Publish to Github Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build publish
- name: Cleanup old artifacts
uses: actions/delete-package-versions@v5
with:
package-name: 'sophisticatedstorage.sophisticatedstorage'
package-type: 'maven'
min-versions-to-keep: 10
- name: Publish to CurseForge
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
run: |
BRANCH_NAME=${GITHUB_REF##*/}
if [[ "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+\.([0-9]+|x)$ ]]; then
./gradlew curseforge
else
echo "Branch name does not match the pattern: $BRANCH_NAME. Skipping CurseForge upload."
exit 0
fi
- name: Publish to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: |
BRANCH_NAME=${GITHUB_REF##*/}
if [[ "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+\.([0-9]+|x)$ ]]; then
./gradlew modrinth
else
echo "Branch name does not match the pattern: $BRANCH_NAME. Skipping Modrinth upload."
exit 0
fi
- name: Code Quality
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dsonar.organization=p3pp3rf1y-github sonarqube
- name : Retrieve Version
run: |
echo "$(${{github.workspace}}/gradlew -q printVersionName | awk -F "version:" '{printf $2}')"
echo "VERSION_NAME=$(${{github.workspace}}/gradlew -q printVersionName | awk -F "version:" '{printf $2}')" >> $GITHUB_OUTPUT
id: version
- name : Compile version message
uses: actions/github-script@v7
with:
script: |
const gh = ${{ toJSON(github) }};
core.setOutput('EMBED_TITLE', "[" + gh.event.repository.name + ":" + gh.ref_name +"] new build ${{steps.version.outputs.VERSION_NAME}}");
core.setOutput('EMBED_URL', "https://github.com/P3pp3rF1y/SophisticatedStorage/packages/1388832?version=${{steps.version.outputs.VERSION_NAME}}");
core.setOutput('EMBED_AUTHOR_NAME', gh.event.sender.login);
core.setOutput('EMBED_AUTHOR_ICON_URL', gh.event.sender.avatar_url);
const commits = ${{ toJSON(github.event.commits) }};
let description = "";
for (const commit of commits) {
if (description.length !== 0) {
description += "\n";
}
description += "[" + commit.id.slice(0,7) + "](<" + commit.url + ">) " + commit.message + " - " + commit.author.username;
}
core.setOutput('EMBED_DESCRIPTION', description);
id: embed
- name: Send Discord Notification
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
embed-title: "${{steps.embed.outputs.EMBED_TITLE}}"
embed-url: "${{steps.embed.outputs.EMBED_URL}}"
embed-description: "${{steps.embed.outputs.EMBED_DESCRIPTION}}"
embed-author-name: "${{steps.embed.outputs.EMBED_AUTHOR_NAME}}"
embed-author-icon-url: "${{steps.embed.outputs.EMBED_AUTHOR_ICON_URL}}"
embed-color: 58633