-
Notifications
You must be signed in to change notification settings - Fork 115
193 lines (177 loc) · 6.1 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Build and Release
on:
# checkov:skip=CKV_GHA_7
workflow_dispatch:
inputs:
type:
description: "Release type"
required: true
type: choice
options:
- "Stable"
- "Pre-release"
cf_type:
description: "CF Release Type"
required: true
type: choice
options:
- "release"
- "beta"
- "alpha"
default: "alpha"
draft:
description: "Draft GitHub release (CF release will always be normal)"
type: boolean
default: true
generate_release_notes:
description: "Auto generate release notes"
type: boolean
default: true
required: false
skip_build:
description: "Skip build/test step"
type: boolean
default: false
run_id:
description: "Run ID to grab artifacts from if skipping build"
type: number
required: false
skip_github_release:
description: "Skip GitHub release"
type: boolean
default: false
required: false
skip_cf_release:
description: "Skip CurseForge release"
type: boolean
default: false
required: false
permissions: {}
jobs:
pre-build:
uses: ./.github/workflows/get_version_info.yml
build:
needs: pre-build
if: inputs.skip_build != true
permissions:
id-token: write
contents: read
packages: write
uses: ./.github/workflows/build_pr.yml
with:
target: build-all
secrets: inherit
release:
permissions:
contents: write
packages: read
statuses: write
needs: [build, pre-build]
runs-on: ubuntu-latest
if: success() || needs.build.result == 'skipped'
steps:
- name: Check Build or Skip
if: ${{ needs.build.result == 'failure' || needs.pre-build.result == 'failure'}}
run: exit 1
shell: bash
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Determine tag
id: tag
run: |
tag="${{needs.pre-build.outputs.version_tag}}"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
shell: bash
- name: Determine name
id: name
run: |
if [[ "${{ github.event.inputs.cf_type }}" != "" ]]; then
# Get prefix first char capitalized
prefix=$(echo "${{ github.event.inputs.cf_type }}" | awk '{print toupper(substr($0, 1, 1)) tolower(substr($0, 2))}')
name="${prefix} ${{needs.pre-build.outputs.version}}"
else
name="${{needs.pre-build.outputs.version}}"
fi
echo "Release name will be $name"
echo "name=$name" >> "$GITHUB_OUTPUT"
shell: bash
- name: Download artifacts - Current Flow
if: ${{ inputs.skip_build == false }}
uses: actions/[email protected]
with:
path: artifacts
- name: Download artifacts - Previous Flow
if: ${{ inputs.skip_build == true}}
uses: actions/[email protected]
with:
path: artifacts
run-id: ${{ github.event.inputs.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Rename artifacts
id: artifacts
run: |
cd artifacts/build-zipzip
for file in ./*; do
if [[ $file == *.zip ]]; then
base=$(basename $file)
versioned_file="Monifactory-${{steps.name.outputs.name}}-$base"
mv "$file" "$versioned_file"
fi
done
wait
echo "Cleaning up - Removing non-zip files"
shopt -s extglob
rm -rf !(*.zip)
shell: bash
- name: Create body
id: body
run: |
ACTION_RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
message="${{ github.event.inputs.type }} release ${{needs.pre-build.outputs.version}}.
The latest commit is ${{ needs.pre-build.outputs.current_commit }}.
Refer to the [action run]($ACTION_RUN_URL) that created this release."
echo "body<<EOF"$'\n'"$message"$'\n'EOF >> "$GITHUB_OUTPUT"
shell: bash
- name: Create GitHub Release
uses: ncipollo/[email protected]
id: release
if: ${{ inputs.skip_github_release == false }}
with:
artifacts: artifacts/build-zipzip/*
name: ${{ steps.name.outputs.name }}
tag: ${{ steps.tag.outputs.tag }}
generateReleaseNotes: ${{ inputs.generate_release_notes }}
prerelease: ${{ github.event.inputs.type == 'Pre-release' }}
draft: ${{ github.event.inputs.draft }}
body: ${{ steps.body.outputs.body }}
allowUpdates: true
updateOnlyUnreleased: true
removeArtifacts: true
commit: ${{ needs.pre-build.outputs.current_commit }}
- name: Echo Release URL
run: |
echo "Release URL: ${{ steps.release.outputs.html_url }}"
shell: bash
- name: Get server and client file paths
id: filepaths
run: |
server_file=$(ls artifacts/build-zipzip/*server*.zip)
client_file=$(ls artifacts/build-zipzip/*client*.zip)
echo "server_file=$server_file" >> "$GITHUB_OUTPUT"
echo "client_file=$client_file" >> "$GITHUB_OUTPUT"
shell: bash
- uses: henkelmax/[email protected]
if: ${{ inputs.skip_cf_release == false }}
with:
api-token: ${{ secrets.RELEASE_TOKEN }}
project-id: ${{vars.CF_PROJECT_ID}}
modpack-path: "${{steps.filepaths.outputs.client_file}}"
modpack-server-path: "${{steps.filepaths.outputs.server_file}}"
changelog: "For a detailed changelog, see the GitHub release: ${{ steps.release.outputs.html_url }}"
changelog-format: "text"
game-version: "1.20.1"
display-name: "Monifactory-${{steps.name.outputs.name}}"
server-display-name: "Monifactory-${{steps.name.outputs.name}} Server"
release-type: ${{ github.event.inputs.cf_type }}