chore: [publish beta] #626
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 Pre-Release version and Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
release-beta: | |
description: 'Publish a beta release?' | |
required: true | |
type: boolean | |
push: | |
branches: | |
- "1.21" | |
jobs: | |
build-and-publish-pre-release: | |
strategy: | |
matrix: | |
# Use thses Java versions: | |
java: [ 21 ] # Current Java LTS and current latest Java version | |
# Use these operating systems: | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Store all lowercase commit message | |
run: | | |
echo COMMIT_MESSAGE=$( git log --format=%B --no-merges -n 1 | tr '[:upper:]' '[:lower:]' ) >> ${GITHUB_ENV} | |
echo COMMIT_MESSAGE_ALL=$( git log --format=%B --no-merges -n 1 ) >> ${GITHUB_ENV} | |
- name: Detect if a beta release should be published | |
if: ${{ contains(env.COMMIT_MESSAGE, '[publish beta]') || inputs.release-beta }} | |
run: | | |
echo "PUBLISH_BETA=true" >> ${GITHUB_ENV} | |
- name: Set up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: ${{ matrix.java }} | |
- name: Show Java version | |
run: java -version | |
- name: Validate Gradle Wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Show Gradle version | |
run: gradle --version | |
- name: Build with Gradle (DEV) | |
if : ${{ env.PUBLISH_BETA != 'true' }} | |
run: gradle getVersion build --stacktrace | |
- name: Build with Gradle (BETA) | |
if : ${{ env.PUBLISH_BETA == 'true' }} | |
env: | |
REDEN_BUILD_TYPE: "BETA" | |
run: gradle getVersion build --stacktrace | |
- name: Get Mod Name | |
id: get_mod_name | |
uses: christian-draeger/read-properties@1.1.1 | |
with: | |
path: gradle.properties | |
properties: 'mod_name' | |
- name: Get Mod Version | |
id: get_mod_version | |
run: | | |
echo "mod_version=$(cat build/.reden-version)" >> $GITHUB_OUTPUT | |
echo "short_mod_version=$(cat build/.reden-short-version)" >> $GITHUB_OUTPUT | |
- name: Upload assets to GitHub Action | |
if: success() || failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "[DEV-CI#${{ github.run_number }}] ${{ steps.get_mod_name.outputs.mod_name }} ${{ steps.get_mod_version.outputs.mod_version }} - Java ${{ matrix.java }}" | |
path: | | |
build/libs/*.jar | |
build/reports/tests/ | |
- name: Publish to GitHub Pre-Releases | |
if: ${{ env.PUBLISH_BETA == 'true' && matrix.java == 21 }} # Only publish the version built with Java LTS | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
artifacts: build/libs/*.jar | |
generateReleaseNotes: true | |
name: "[CI#${{ github.run_number }}] ${{ steps.get_mod_name.outputs.mod_name }} Mod Pre-Release ${{ steps.get_mod_version.outputs.mod_version }}" | |
prerelease: true | |
tag: "beta/${{ steps.get_mod_version.outputs.mod_version }}" | |
- name: Publish to Modrinth & CurseForge | |
if: ${{ env.PUBLISH_BETA == 'true' && matrix.java == 17 }} # Only publish the version built with Java LTS | |
uses: Kir-Antipov/mc-publish@v3.3 | |
with: | |
# Publish to Modrinth | |
modrinth-id: xRu8OXEJ | |
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
# Publish to CurseForge | |
curseforge-id: 903236 | |
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | |
# Universal Configurations | |
files: | | |
build/libs/*-@(beta).jar | |
build/libs/*-@(beta)*@(ci)*[0123456789].jar | |
name: "${{ steps.get_mod_name.outputs.mod_name }} Pre-Release ${{ steps.get_mod_version.outputs.mod_version }}" | |
version: "${{ steps.get_mod_version.outputs.short_mod_version }}" | |
version-type: beta | |
loaders: | | |
fabric | |
quilt | |
modrinth-featured: false | |
dependencies: | | |
carpet | |
malilib | |
fabric-api | |
fabric-language-kotlin | |
owo-lib | |
java: | | |
17 | |
18 | |
19 | |
20 | |
21 | |
retry-attempts: 2 | |
retry-delay: 10000 | |
changelog: ${{ env.COMMIT_MESSAGE_ALL }} |