-
-
Notifications
You must be signed in to change notification settings - Fork 423
130 lines (124 loc) · 4.43 KB
/
multi_publish.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
name: Publish Multiple Releases
run-name: Publish v${{ github.event.inputs.wurst_version }} build(s) from ${{ github.event.inputs.branches }}
on:
workflow_dispatch:
inputs:
wurst_version:
description: "Wurst version (without v or -MC)"
required: true
type: string
branches:
description: "Space-separated list of branches to publish from"
required: true
type: string
announce_ports:
description: "Announce as ports on WurstForum"
required: true
type: boolean
default: false
dry_run:
description: "Dry-run mode (don't actually publish anything)"
required: false
type: boolean
default: false
permissions:
# Needed to trigger the publish workflow.
actions: write
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.set_branches.outputs.branches }}
steps:
- name: Convert branches input to JSON array
id: set_branches
run: |
branches_array=(${{ inputs.branches }})
quoted_branches=$(printf '"%s",' "${branches_array[@]}")
JSON_ARRAY="[${quoted_branches%,}]"
echo "branches=$JSON_ARRAY" >> "$GITHUB_OUTPUT"
echo "Branches: $JSON_ARRAY" >> "$GITHUB_STEP_SUMMARY"
publish_each:
runs-on: ubuntu-latest
needs: prepare
if: ${{ !fromJson(inputs.dry_run) }}
strategy:
# Each job pushes an automated commit to WurstClient.net@master, so running them all in parallel
# would likely cause conflicts. Also, various servers might hit rate limits if we just upload
# all of the files at once.
max-parallel: 1
# If something goes wrong, all published files have to be manually deleted.
# Best to fail as early as possible.
fail-fast: true
matrix:
branch: ${{ fromJson(needs.prepare.outputs.branches) }}
# TODO: Maybe also verify that the wurst_version in each branch is as expected before publishing?
steps:
- name: Build publish inputs
id: publish_inputs
run: |
JSON_STRING=$(cat << EOF
{
"close_milestone": "true",
"upload_backups": "true",
"publish_github": "true",
"update_website": "true"
}
EOF
)
# Convert to single line and escape quotes
echo "json=${JSON_STRING//$'\n'/}" >> "$GITHUB_OUTPUT"
- name: Trigger publish workflow
id: publish_dispatch
uses: codex-/return-dispatch@v2
with:
token: ${{ github.token }}
owner: Wurst-Imperium
repo: Wurst7
ref: ${{ matrix.branch }}
workflow: publish.yml
workflow_inputs: ${{ steps.publish_inputs.outputs.json }}
- name: Wait for publish workflow to finish (run ${{ steps.publish_dispatch.outputs.run_id }})
uses: codex-/await-remote-run@v1
with:
token: ${{ github.token }}
owner: Wurst-Imperium
repo: Wurst7
run_id: ${{ steps.publish_dispatch.outputs.run_id }}
run_timeout_seconds: 600 # 10 minutes
announce:
runs-on: ubuntu-latest
needs: [prepare, publish_each]
if: ${{ !failure() && !cancelled() && inputs.announce_ports }}
steps:
- name: Build announcement inputs
id: announce_inputs
run: |
JSON_STRING=$(cat << EOF
{
"wurst_version": "${{ inputs.wurst_version }}",
"branches": "${{ inputs.branches }}",
"dry_run": "${{ inputs.dry_run }}"
}
EOF
)
# Convert to single line and escape quotes
echo "json=${JSON_STRING//$'\n'/}" >> "$GITHUB_OUTPUT"
- name: Trigger announce workflow
id: announce_dispatch
uses: codex-/return-dispatch@v2
with:
token: ${{ secrets.WURSTCLIENT_NET_PUBLISH_TOKEN }}
owner: Wurst-Imperium
repo: WurstClient.net
ref: gh-pages
workflow: announce_wurst_ports.yml
workflow_inputs: ${{ steps.announce_inputs.outputs.json }}
- name: Wait for announce workflow to finish (run ${{ steps.announce_dispatch.outputs.run_id }})
uses: codex-/await-remote-run@v1
with:
token: ${{ secrets.WURSTCLIENT_NET_PUBLISH_TOKEN }}
owner: Wurst-Imperium
repo: WurstClient.net
run_id: ${{ steps.announce_dispatch.outputs.run_id }}
run_timeout_seconds: 600 # 10 minutes