1.2.5+1.21 #2
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: 'Deploy' | |
on: | |
release: | |
types: [ published ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# Load the variables needed | |
- name: Load gradle.properties into the environment | |
run: | | |
while IFS='=' read -r key value; do | |
[[ -z "$key" || "$key" =~ ^#.* ]] && continue | |
env_key=$(echo "$key" | tr '[:lower:]' '[:upper:]' | tr '.' '_') | |
echo "${env_key}=${value}" >> $GITHUB_ENV | |
done < gradle.properties | |
- name: Load GitHub variables into the environment | |
run: | | |
echo "GITHUB_REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV | |
echo "GITHUB_RELEASE_TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
{ | |
echo "MOD_CHANGELOG<<EOF" | |
echo "${{ github.event.release.body }}" | |
echo "EOF" | |
} >> $GITHUB_ENV | |
- name: Generate additional variables into the environment | |
run: | | |
{ | |
echo "MOD_CHANGELOG_TRIMMED<<EOF" | |
echo "$(echo "$MOD_CHANGELOG" | sed -E '/^\s*$/d; s#\*\*Full Changelog\*\*: (https?://[^\ ]+)#\[Full Changelog\](\1)#g' | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')" | |
echo "EOF" | |
} >> $GITHUB_ENV | |
echo "RELEASE_TYPE_DISPLAY=${RELEASE_TYPE^}" >> $GITHUB_ENV | |
echo "EMBED_COLOR=$(if [ $RELEASE_TYPE == "release" ]; then echo 2336090; elif [ $RELEASE_TYPE == "beta" ]; then echo 15774258; else echo 15875907; fi)" >> $GITHUB_ENV | |
- name: Prepare Discord webhook JSON file | |
run: | | |
envsubst < .github/workflows/discord_message.json > prepared_discord_message.json | |
echo "Prepared Discord webhook JSON:" | |
cat prepared_discord_message.json | |
# Build the mod and publish it to ModMaven, CurseForge, and Modrinth | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 21 | |
cache: gradle | |
distribution: temurin | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Publish to ModMaven | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: publishMavenJavaPublicationToModmavenRepository | |
env: | |
MODMAVEN_USERNAME: ${{ secrets.MODMAVEN_USERNAME }} | |
MODMAVEN_PASSWORD: ${{ secrets.MODMAVEN_PASSWORD }} | |
- name: Publish to Curseforge | |
run: ./gradlew curseforge | |
env: | |
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} | |
- name: Publish to Modrinth | |
run: ./gradlew modrinth | |
env: | |
MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }} | |
# Post to the Discord that the update has been deployed | |
- name: Post to Discord | |
run: | | |
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data @prepared_discord_message.json ${{ secrets.RELEASE_WEBHOOK_URL }} |