Repository navigation
169 lines (153 loc) · 6.12 KB
/
Copy pathpublish.yml
File metadata and controls
169 lines (153 loc) · 6.12 KB
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
name: Publish to Modrinth / CurseForge
# Publishes the jars attached to a GitHub release by release.yml.
# Settings: .github/release.toml [publish]. Helper: .github/scripts/release.py
run-name: Publish ${{ inputs.tag }}${{ inputs.dry_run && ' (dry run)' || '' }}
on:
workflow_dispatch:
inputs:
tag:
description: Release tag to publish
type: string
required: true
modrinth:
description: Publish to Modrinth
type: boolean
default: true
curseforge:
description: Publish to CurseForge
type: boolean
default: true
version_type:
description: Release channel (auto = from the tag name, beta/rc -> beta, alpha/snapshot/pre -> alpha)
type: choice
options:
- auto
- release
- beta
- alpha
default: auto
only:
description: Publish only the jars whose file name matches this pattern, e.g. *mc1.20.1*
type: string
default: '*'
dry_run:
description: Show what would be published without uploading anything
type: boolean
default: false
concurrency:
group: publish-${{ inputs.tag }}
cancel-in-progress: false
permissions:
contents: read
env:
TAG: ${{ inputs.tag }}
jobs:
assets:
name: Read release assets
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
version_type: ${{ inputs.version_type == 'auto' && steps.matrix.outputs.version_type || inputs.version_type }}
steps:
- name: Checkout settings and helper
uses: actions/checkout@v7
- name: Read the version table of the release tag
run: |
set -euo pipefail
FILE=$(python3 .github/scripts/release.py config publish.versions.file)
git fetch --no-tags --depth=1 origin "refs/tags/$TAG:refs/tags/$TAG"
git show "refs/tags/$TAG:$FILE" > release-versions.toml
- name: Resolve publishable jars
id: matrix
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ONLY: ${{ inputs.only }}
run: |
set -euo pipefail
gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json assets > assets.json
python3 .github/scripts/release.py matrix assets.json --tag "$TAG" --only "$ONLY" --versions release-versions.toml ${{ inputs.modrinth && '--modrinth' || '' }}
- name: Save the release description as changelog
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json body --jq '.body // ""' > changelog.md
- name: Keep changelog and version table for the publish jobs
uses: actions/upload-artifact@v7
with:
name: release-info
path: |
changelog.md
release-versions.toml
retention-days: 1
publish:
name: ${{ matrix.entry.file }}
needs: assets
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1 # one upload at a time keeps the version order on the platforms stable
matrix:
entry: ${{ fromJSON(needs.assets.outputs.matrix) }}
env:
FILE: ${{ matrix.entry.file }}
EXTRA: ${{ join(matrix.entry.extra, ' ') }}
steps:
- name: Checkout settings and helper
uses: actions/checkout@v7
- name: Download changelog and version table
uses: actions/download-artifact@v8
with:
name: release-info
- name: Resolve loaders, game versions and dependencies
id: meta
# $EXTRA unquoted on purpose: the classifier jars of this version, space separated
run: python3 .github/scripts/release.py meta "$FILE" $EXTRA --dir dist --versions release-versions.toml --version-type "${{ needs.assets.outputs.version_type }}"
- name: Download the jars
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOWNLOADS: ${{ steps.meta.outputs.downloads }}
run: |
set -euo pipefail
mkdir -p dist
while read -r asset path; do
if [ -n "$asset" ]; then
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern "$asset" --output "$path"
fi
done <<< "$DOWNLOADS"
# fail-mode fail: a rejected upload fails this job. Once fixed, dispatch again with `only` on the failed jars
# (a rerun of the failed jobs checks out the settings of the original run)
- name: Publish to Modrinth
if: ${{ inputs.modrinth && !inputs.dry_run }}
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: ${{ vars.MODRINTH_ID }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
modrinth-featured: false
files: ${{ steps.meta.outputs.files }}
name: ${{ steps.meta.outputs.name }}
version: ${{ steps.meta.outputs.version }}
version-type: ${{ needs.assets.outputs.version_type }}
loaders: ${{ steps.meta.outputs.loaders }}
game-versions: ${{ steps.meta.outputs.game_versions }}
game-version-filter: ${{ steps.meta.outputs.filter }}
java: ${{ steps.meta.outputs.java }}
dependencies: ${{ steps.meta.outputs.dependencies }}
changelog-file: changelog.md
fail-mode: fail
# the main jar only: CurseForge has no Maven for the developer jars
- name: Publish to CurseForge
if: ${{ inputs.curseforge && !inputs.dry_run }}
uses: Kir-Antipov/mc-publish@v3.3
with:
curseforge-id: ${{ vars.CURSEFORGE_ID }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
files: dist/${{ matrix.entry.file }}
name: ${{ steps.meta.outputs.name }}
version: ${{ steps.meta.outputs.version }}
version-type: ${{ needs.assets.outputs.version_type }}
loaders: ${{ steps.meta.outputs.loaders }}
game-versions: ${{ steps.meta.outputs.game_versions }}
game-version-filter: ${{ steps.meta.outputs.filter }}
java: ${{ steps.meta.outputs.java }}
dependencies: ${{ steps.meta.outputs.dependencies }}
changelog-file: changelog.md
fail-mode: fail