-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (70 loc) · 2.93 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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 }}