1.0.3 #4
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: Gradle publish | |
on: | |
release: | |
types: [ created ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 3 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
cache: 'gradle' | |
- uses: gradle/actions/setup-gradle@v4 | |
- name: Configure Git | |
run: git config --global user.email "[email protected]" && git config --global user.name "Github Actions" | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Get commit hash | |
run: | | |
COMMIT_HASH=$(git rev-parse --short HEAD) | |
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV | |
- name: Set version | |
run: | | |
VERSION=${{ github.event.release.name }} | |
if [ "${{ github.event.release.prerelease }}" = "true" ]; then | |
FULL_VERSION="${VERSION}-commit-${COMMIT_HASH}" | |
echo "VERSION_TYPE=beta" >> $GITHUB_ENV | |
else | |
FULL_VERSION="${VERSION}" | |
echo "VERSION_TYPE=release" >> $GITHUB_ENV | |
fi | |
echo "Setting version to $FULL_VERSION" | |
sed -i "s/^project_version = .*/project_version = $FULL_VERSION/" gradle.properties | |
echo "FULL_VERSION=$FULL_VERSION" >> $GITHUB_ENV | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
# - name: Publish | |
# run: ./gradlew publish --no-daemon --stacktrace | |
- name: Build Jar | |
run: | | |
./gradlew clean | |
./gradlew shadowJar --no-daemon --stacktrace --refresh-dependencies | |
- name: Find Jar | |
run: | | |
JAR_FILE=$(find build/libs -name "*.jar" -type f | head -n 1) | |
echo "JAR_FILE=$JAR_FILE" >> $GITHUB_ENV | |
- name: Upload Jar to Release | |
run: | | |
echo "File size: $(stat -c %s $JAR_FILE) bytes" | |
echo "${{ github.event.release.upload_url }}" | |
echo $(basename "$JAR_FILE") | |
UPLOAD_URL="https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets?name=$(basename "$JAR_FILE")" | |
echo $UPLOAD_URL | |
# Upload the file to GitHub using the correct curl format | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Content-Type: application/octet-stream" \ | |
"$UPLOAD_URL" \ | |
--data-binary "@$JAR_FILE" | |
- name: Upload to Modrinth | |
uses: RubixDev/modrinth-upload@v1 | |
with: | |
token: ${{ secrets.MODRINTH_TOKEN }} | |
file_path: ${{ env.JAR_FILE }} | |
name: ${{ env.VERSION }} | |
version: ${{ env.VERSION }} | |
changelog: ${{ github.event.release.body }} | |
game_versions: 1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4 | |
release_type: ${{ env.VERSION_TYPE }} | |
loaders: paper,purpur | |
featured: true | |
project_id: ${{ secrets.PROJECT_ID }} |