-
Notifications
You must be signed in to change notification settings - Fork 54
141 lines (125 loc) · 5.11 KB
/
Copy pathrelease.yml
File metadata and controls
141 lines (125 loc) · 5.11 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
name: Package release
on:
push:
tags:
- "v*"
permissions:
actions: read
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
name: Publish ${{ github.ref_name }}
runs-on: ubuntu-22.04
timeout-minutes: 240
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Wait for tested binary packages
shell: bash
run: |
set -euo pipefail
wait_for_workflow() {
local workflow="$1"
local output_name="$2"
local run_json run_id status conclusion
for attempt in $(seq 1 960); do
run_json="$(gh run list \
--repo "${GITHUB_REPOSITORY}" \
--workflow "${workflow}" \
--commit "${GITHUB_SHA}" \
--event push \
--limit 20 \
--json databaseId,status,conclusion,headBranch,createdAt)"
run_id="$(jq -r --arg tag "${GITHUB_REF_NAME}" '
[.[] | select(.headBranch == $tag)]
| sort_by(.createdAt)
| last
| .databaseId // empty
' <<<"${run_json}")"
if [[ -z "${run_id}" ]]; then
echo "Waiting for ${workflow} to start for tag ${GITHUB_REF_NAME}..."
sleep 15
continue
fi
status="$(jq -r --argjson id "${run_id}" '
.[] | select(.databaseId == $id) | .status
' <<<"${run_json}")"
conclusion="$(jq -r --argjson id "${run_id}" '
.[] | select(.databaseId == $id) | .conclusion
' <<<"${run_json}")"
if [[ "${status}" == "completed" ]]; then
if [[ "${conclusion}" != "success" ]]; then
echo "${workflow} run ${run_id} completed with ${conclusion}" >&2
exit 1
fi
echo "${workflow} run ${run_id} succeeded"
echo "${output_name}=${run_id}" >> "${GITHUB_ENV}"
return 0
fi
echo "Waiting for ${workflow} run ${run_id}: ${status}"
sleep 15
done
echo "Timed out waiting for ${workflow}" >&2
exit 1
}
wait_for_workflow linux-x64.yml TESTS_RUN_ID
wait_for_workflow windows-build.yml WINDOWS_RUN_ID
wait_for_workflow linux-arm64.yml LINUX_ARM64_RUN_ID
wait_for_workflow macos-arm64.yml MACOS_ARM64_RUN_ID
- name: Download tested packages
shell: bash
run: |
set -euo pipefail
mkdir -p dist/linux-x64 dist/linux-arm64 dist/macos-arm64 dist/windows
gh run download "${TESTS_RUN_ID}" \
--repo "${GITHUB_REPOSITORY}" \
--pattern 'release-linux-*' \
--dir dist/linux-x64
gh run download "${WINDOWS_RUN_ID}" \
--repo "${GITHUB_REPOSITORY}" \
--pattern 'release-windows-*' \
--dir dist/windows
gh run download "${LINUX_ARM64_RUN_ID}" \
--repo "${GITHUB_REPOSITORY}" \
--pattern 'release-linux-arm64-*' \
--dir dist/linux-arm64
gh run download "${MACOS_ARM64_RUN_ID}" \
--repo "${GITHUB_REPOSITORY}" \
--pattern 'release-macos-arm64-*' \
--dir dist/macos-arm64
test "$(find dist -type f -name 'tpc_v*_linux_x64.tar.gz' | wc -l)" -eq 1
test "$(find dist -type f -name 'tpc_v*_linux_arm64.tar.gz' | wc -l)" -eq 1
test "$(find dist -type f -name 'tpc_v*_macos_arm64.tar.gz' | wc -l)" -eq 1
test "$(find dist -type f -name 'tpc_v*_windows_x64.zip' | wc -l)" -eq 1
- name: Prepare release assets
shell: bash
run: |
set -euo pipefail
mkdir -p release-assets
find dist -type f \( -name '*.tar.gz' -o -name '*.zip' \) \
-exec cp '{}' release-assets/ \;
test "$(find release-assets -maxdepth 1 -type f \( -name '*.tar.gz' -o -name '*.zip' \) | wc -l)" -eq 4
(
cd release-assets
sha256sum ./*.tar.gz ./*.zip > SHA256SUMS
)
ls -lh release-assets
- name: Publish GitHub release
shell: bash
run: |
set -euo pipefail
mapfile -t assets < <(find release-assets -maxdepth 1 -type f | sort)
if gh release view "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
gh release upload "${GITHUB_REF_NAME}" "${assets[@]}" \
--repo "${GITHUB_REPOSITORY}" \
--clobber
else
gh release create "${GITHUB_REF_NAME}" "${assets[@]}" \
--repo "${GITHUB_REPOSITORY}" \
--verify-tag \
--title "TypePHP ${GITHUB_REF_NAME}" \
--generate-notes
fi