forked from Cannoneers-of-Create/CreateBigCannons
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (90 loc) · 4.26 KB
/
release.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Release
on:
push:
tags:
- 'v**'
- '!v*-dev**'
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get branch name
id: get_branch
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Get mod version
id: get_mod_version
run: echo "version=$(git describe --tags --abbrev=0 | grep -oP '(?<=v)\d+\.\d+\.\d+(?:-\w+)?(?=\+)')" >> $GITHUB_OUTPUT
- name: Get MC version
uses: christian-draeger/read-properties@908f99d3334be3802ec7cb528395a69d19914e7b
id: read_properties
with:
path: gradle.properties
properties: minecraft_version enabled_platforms archives_base_name
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-includes: |
caches
loom-cache
- name: Build jar
env:
RELEASE: true
run: ./gradlew build
- name: Publish to GitHub Packages
env:
RELEASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: env.GITHUB_TOKEN != ''
continue-on-error: true
run: ./gradlew publishMavenJavaPublicationToGitHubPackagesRepository
- name: Publish to realRobotix Maven
env:
RELEASE: true
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_ACCESS_TOKEN: ${{ secrets.MAVEN_ACCESS_TOKEN }}
if: env.MAVEN_USER != '' && env.MAVEN_ACCESS_TOKEN != ''
run: ./gradlew publishMavenJavaPublicationToRealRobotixMavenRepository -PrealRobotixMavenUsername=${{ secrets.MAVEN_USER }} -PrealRobotixMavenPassword=${{ secrets.MAVEN_ACCESS_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 "\.\/($(tr "," "|" <<< ${{ steps.read_properties.outputs.enabled_platforms }}))\/build\/libs\/${{ steps.read_properties.outputs.archives_base_name }}-${{ steps.get_mod_version.outputs.version }}\+mc\.${{ steps.read_properties.outputs.minecraft_version }}-($(tr "," "|" <<< ${{ steps.read_properties.outputs.enabled_platforms }}))\.jar" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Send building message to discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
if: env.DISCORD_WEBHOOK != ''
uses: realRobotix/action-discord-notifier@master
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: 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.get_mod_version.outputs.version }}+mc.${{ steps.read_properties.outputs.minecraft_version }}
path: ${{ steps.find_jars.outputs.jars }}