-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (114 loc) · 4.8 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Release
run-name: Release (${{ inputs.version }})
on:
workflow_dispatch:
inputs:
is-release:
description: Publish release
required: true
type: boolean
version:
description: Pack version (e.g. 1.3.1+1.21)
required: true
type: string
jobs:
create-release:
name: Create release
runs-on: ubuntu-latest
permissions:
contents: "write"
id-token: write
attestations: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Ensure Gradle wrapper is executable
run: chmod +x ./gradlew
- name: Validate Gradle
uses: gradle/actions/wrapper-validation@v4
- name: Get Data
id: get-data
run: |
java_version=$(grep '^java_version=' gradle.properties | cut -d= -f2)
minecraft_version=$(grep '^minecraft_version=' gradle.properties | cut -d= -f2)
mod_id=$(cat src/client/resources/fabric.mod.json | jq -r '.id')
mod_name=$(cat src/client/resources/fabric.mod.json | jq -r '.name')
modrinth_project_id=$(cat src/client/resources/fabric.mod.json | jq -r '.custom["mc-publish"].modrinth')
echo "java-version=$java_version" >> "$GITHUB_OUTPUT"
echo "minecraft-version=$minecraft_version" >> "$GITHUB_OUTPUT"
echo "mod-id=$mod_id" >> "$GITHUB_OUTPUT"
echo "mod-name=$mod_name" >> "$GITHUB_OUTPUT"
echo "modrinth-project-id=$modrinth_project_id" >> "$GITHUB_OUTPUT"
- name: Setup Java ${{ steps.get-data.outputs.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ steps.get-data.outputs.java-version }}
distribution: "zulu"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Get deploy info
id: deploy-info
run: |
# Also update the mod version in gradle
sed -i "s/^mod_version=.*/mod_version=${{ inputs.version }}/" gradle.properties
release_name="${{ steps.get-data.outputs.mod-name }} v${{ inputs.version }}"
echo "release-name=$release_name" >> "$GITHUB_OUTPUT"
version_slug="v${{ inputs.version }}"
echo "version-slug=$version_slug" >> "$GITHUB_OUTPUT"
icon_url=$(curl -A "secret_online/mod-auto-updater ([email protected])" "https://api.modrinth.com/v2/project/${{ steps.get-data.outputs.modrinth-project-id }}" | jq --raw-output ".icon_url")
echo "icon-url=$icon_url" >> "$GITHUB_OUTPUT"
- name: Parse changelog
id: changelog
uses: release-flow/keep-a-changelog-action@v3
with:
command: query
version: v${{ inputs.version }}
changelog: CHANGELOG.md
- name: Build
run: ./gradlew clean build
- name: Print release details
run: |
echo "name: ${{ steps.deploy-info.outputs.release-name }}"
echo "version: v${{ inputs.version }}"
echo "changelog: ${{ steps.changelog.outputs.release-notes }}"
echo "icon-url: ${{ steps.deploy-info.outputs.icon-url }}"
# - uses: actions/attest-build-provenance@v1
# if: inputs.is-release
# with:
# subject-path: "build/libs/*.jar"
- name: Create GitHub release
if: inputs.is-release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.deploy-info.outputs.version-slug }}
name: ${{ steps.deploy-info.outputs.release-name }}
body: ${{ steps.changelog.outputs.release-notes }}
files: |
build/libs/!(*-sources).jar
build/libs/*-sources.jar
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Modrinth Release
if: inputs.is-release
id: modrinth-release
uses: Kir-Antipov/[email protected]
with:
name: ${{ steps.deploy-info.outputs.release-name }}
version: ${{ steps.deploy-info.outputs.version-slug }}
changelog: ${{ steps.changelog.outputs.release-notes }}
loaders: fabric
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
- name: Update Modrinth decription
if: inputs.is-release
uses: funnyboy-roks/[email protected]
with:
auth-token: ${{ secrets.MODRINTH_TOKEN }}
slug: ${{ steps.get-data.outputs.modrinth-project-id }}
readme: MODRINTH.md
- name: Post release to Discord
if: inputs.is-release
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: |
${{ steps.deploy-info.outputs.release-name }} has been released! https://modrinth.com/mod/${{ steps.get-data.outputs.mod-id }}/version/${{ steps.deploy-info.outputs.version-slug }}