copy and paste mistake #2
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 Publish | |
on: | |
push: | |
pull_request: | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get branch name | |
id: get_branch | |
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
- name: Get latest commit hash | |
id: get_hash | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Get MC version | |
uses: christian-draeger/read-properties@908f99d3334be3802ec7cb528395a69d19914e7b | |
id: read_properties | |
with: | |
path: gradle.properties | |
properties: minecraft_version mod_version mod_id | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: temurin | |
- name: Validate Gradle Wrapper | |
uses: gradle/wrapper-validation-action@v2 | |
- name: Grant execute permissions to gradlew | |
run: chmod +x gradlew | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-home-cache-includes: | | |
caches | |
loom-cache | |
- name: Run Data Gen | |
if: false #enable to run data gen before building | |
uses: gradle/actions/setup-gradle@v3 | |
with: | |
arguments: runDatagen | |
- name: Build | |
uses: gradle/actions/setup-gradle@v3 | |
with: | |
arguments: build | |
- name: Publish to GitHub Packages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: github.event_name == 'push' && env.GITHUB_TOKEN != '' | |
continue-on-error: true | |
uses: gradle/actions/setup-gradle@v3 | |
with: | |
arguments: publishMavenJavaPublicationToGitHubPackagesRepository | |
- name: Publish to realRobotix Maven | |
env: | |
MAVEN_USER: ${{ secrets.MAVEN_USER }} | |
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }} | |
if: github.event_name == 'push' && env.MAVEN_USER != '' && env.MAVEN_TOKEN != '' | |
uses: gradle/actions/setup-gradle@v3 | |
with: | |
arguments: | | |
publishMavenJavaPublicationToRealRobotixMavenRepository | |
-PrealRobotixMavenUsername=${{ secrets.MAVEN_USER }} | |
-PrealRobotixMavenPassword=${{ secrets.MAVEN_TOKEN }} | |
- name: Find jars | |
id: find_jars | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "jars<<$EOF" >> $GITHUB_OUTPUT | |
find . -regextype posix-extended -regex "\.\/build\/libs\/${{ steps.read_properties.outputs.mod_id }}-${{ steps.read_properties.outputs.mod_version }}\+mc\.${{ steps.read_properties.outputs.minecraft_version }}-build\.${{ github.run_number }}\.jar" >> $GITHUB_OUTPUT | |
echo "$EOF" >> $GITHUB_OUTPUT | |
- name: Send building message to discord | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
if: github.event_name == 'push' && env.DISCORD_WEBHOOK != '' | |
uses: realRobotix/action-discord-notifier@1fa6982aa12b61b0a17ae03afa813dfc990f50b6 | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
message-title: Building mod from branch ${{ steps.get_branch.outputs.branch }} | |
- name: Send built file to discord | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
if: github.event_name == 'push' && env.DISCORD_WEBHOOK != '' | |
run: | | |
while IFS= read -r f | |
do curl -F "file=@\"$f\";filename=\"$(echo ${f##*/} | sed 's/+/-/g')\"" $DISCORD_WEBHOOK | |
done <<< "${{ steps.find_jars.outputs.jars }}" | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.read_properties.outputs.archives_base_name }}-${{ steps.read_properties.outputs.mod_version }}+mc${{ steps.read_properties.outputs.minecraft_version }}-build.${{ github.run_number }} | |
path: ${{ steps.find_jars.outputs.jars }} |