-
Notifications
You must be signed in to change notification settings - Fork 3
185 lines (164 loc) · 8.5 KB
/
check_new_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
name: qbt-musl-cross-make - check for new releases
on:
workflow_dispatch:
inputs:
skip_rerun:
description: "Skip rerun?"
required: true
default: true
type: boolean
retries:
description: "Number of rerun retries"
required: true
default: "1"
type: choice
options: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
schedule:
- cron: "0 */3 * * *"
permissions:
actions: write
contents: write
checks: read
jobs:
skip_duplicate_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: "always"
cancel_others: "false"
skip_after_successful_duplicate: false
do_not_skip: ""
check_release:
needs: skip_duplicate_job
if: ${{ needs.skip_duplicate_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
name: "Check for latest releases or tags"
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
trigger_workflow: "no"
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install -y ssed
- name: boot strap
run: |
until curl -sLf "https://github.com/userdocs/qbt-musl-cross-make/releases/latest/download/versions.json" > remote_versions.json; do
echo "waiting for URL."
sleep 2
done
declare -A current_versions
eval "$(jq -r 'to_entries[]|@sh"current_versions[\(.key)]=\(.value)"' remote_versions.json)"
declare -A remote_versions
remote_versions[CONFIG_SUB_REV]="$(git ls-remote "https://git.savannah.gnu.org/git/config.git" | head -n1 | awk '{ print substr($1,1,8) }')"
remote_versions[GCC_VER]="$(curl -sL "https://mirrors.dotsrc.org/gnu/gcc/" | ssed -Rn 's|(.*)href="gcc-(.+?)/"(.*)|\2|p' | sort -V | tail -n1)"
remote_versions[BINUTILS_VER]="$(curl -sL "https://mirrors.dotsrc.org/gnu/binutils/" | ssed -Rn 's|(.*)href="binutils-(.+?)\.tar\.xz"(.*)|\2|p' | tail -n1)"
remote_versions[MUSL_VER]=git-"$(git ls-remote "https://git.musl-libc.org/git/musl" | head -n1 | awk '{ print substr($1,1,8) }')"
remote_versions[GMP_VER]="$(curl -sL "https://mirrors.dotsrc.org/gnu/gmp/" | ssed -Rn 's|(.*)href="gmp-(.+?)\.tar\.xz"(.*)|\2|p' | tail -n1)"
remote_versions[MPC_VER]="$(curl -sL "https://mirrors.dotsrc.org/gnu/mpc/" | ssed -Rn 's|(.*)href="mpc-(.+?)\.tar\.gz"(.*)|\2|p' | tail -n1)"
remote_versions[MPFR_VER]="$(curl -sL "https://mirrors.dotsrc.org/gnu/mpfr/" | ssed -Rn 's|(.*)href="mpfr-(.+?)\.tar\.gz"(.*)|\2|p' | tail -n1)"
remote_versions[LINUX_VER]="$(curl -sL "https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/" | ssed -Rn 's|(.*)href="linux-(.+?)\.tar\.gz"(.*)|\2|p' | sort -rV | head -n1)"
remote_versions[ISL_VER]="$(curl -sL https://libisl.sourceforge.io | ssed -Rn 's|(.*)href="isl-(.+?)\.tar\.xz"(.*)|\2|p' | tail -n1)"
# Verify the array entries and exit on failure
for key in "${!remote_versions[@]}"; do
if [[ -z "${remote_versions[$key]}" ]]; then
echo "Error: ${key} is empty"
exit 1
fi
done
declare -A remote_urls_dl
remote_urls_dl[CONFIG_SUB_REV]="https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=${remote_versions[CONFIG_SUB_REV]}"
remote_urls_dl[GCC_VER]="https://mirrors.dotsrc.org/gnu/gcc/gcc-${remote_versions[GCC_VER]}/gcc-${remote_versions[GCC_VER]}.tar.xz"
remote_urls_dl[BINUTILS_VER]="https://mirrors.dotsrc.org/gnu/binutils/binutils-${remote_versions[BINUTILS_VER]}.tar.xz"
remote_urls_dl[MUSL_VER]=""
remote_urls_dl[GMP_VER]="https://mirrors.dotsrc.org/gnu/gmp/gmp-${remote_versions[GMP_VER]}.tar.xz"
remote_urls_dl[MPC_VER]="https://mirrors.dotsrc.org/gnu/mpc/mpc-${remote_versions[MPC_VER]}.tar.gz"
remote_urls_dl[MPFR_VER]="https://mirrors.dotsrc.org/gnu/mpfr/mpfr-${remote_versions[MPFR_VER]}.tar.xz"
remote_urls_dl[LINUX_VER]="https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-${remote_versions[LINUX_VER]}.tar.xz"
remote_urls_dl[ISL_VER]="https://libisl.sourceforge.io/isl-${remote_versions[ISL_VER]}.tar.xz"
ver() {
local test_array
read -ra test_array < <(printf "%s" "${@//./ }")
printf "%d%03d%03d%03d" "${test_array[@]}"
}
for iray in "${!current_versions[@]}"; do
if [[ ! "$iray" =~ ^(CONFIG_SUB_REV|MUSL_VER)$ ]]; then
if [[ "$(ver "${current_versions[$iray]}")" -lt "$(ver "${remote_versions[$iray]}")" ]]; then
printf "%-14s current:%-10s remote:%-10s %s\n" "$iray" "${current_versions[$iray]}" "${remote_versions[$iray]}" "< New version available - workflow will be triggered"
curl -sL "${remote_urls_dl[$iray]}" -o "${remote_urls_dl[$iray]##*/}"
sha1sum "${remote_urls_dl[$iray]##*/}" > "hashes/${remote_urls_dl[$iray]##*/}.sha1"
rm -f "${remote_urls_dl[$iray]##*/}"
echo "trigger_workflow=yes" >> $GITHUB_ENV
else
printf "%-14s current:%-10s remote:%-10s\n" "$iray" "${current_versions[$iray]}" "${remote_versions[$iray]}"
fi
fi
if [[ "$iray" =~ ^(CONFIG_SUB_REV|MUSL_VER)$ ]]; then
if [[ "${current_versions[$iray]}" != "${remote_versions[$iray]}" ]]; then
printf "%-14s current:%-10s remote:%-10s %s\n" "$iray" "${current_versions[$iray]}" "${remote_versions[$iray]}" "< New version available - workflow will be triggered"
if [[ "$iray" != "MUSL_VER" ]]; then
printf '%s' "$(curl -sL "${remote_urls_dl[$iray]}" | sha1sum | sed 's/-/config.sub/')" > "hashes/config.sub.${remote_versions[CONFIG_SUB_REV]}.sha1"
fi
echo "trigger_workflow=yes" >> $GITHUB_ENV
else
printf "%-14s current:%-10s remote:%-10s\n" "$iray" "${current_versions[$iray]}" "${remote_versions[$iray]}"
fi
fi
done
cat > "versions.json" <<- VERSIONS_JSON
{
"CONFIG_SUB_REV": "${remote_versions[CONFIG_SUB_REV]}",
"GCC_VER": "${remote_versions[GCC_VER]}",
"BINUTILS_VER": "${remote_versions[BINUTILS_VER]}",
"MUSL_VER": "${remote_versions[MUSL_VER]}",
"GMP_VER": "${remote_versions[GMP_VER]}",
"MPC_VER": "${remote_versions[MPC_VER]}",
"MPFR_VER": "${remote_versions[MPFR_VER]}",
"LINUX_VER": "${remote_versions[LINUX_VER]}",
"ISL_VER": "${remote_versions[ISL_VER]}"
}
VERSIONS_JSON
cat > "versions.mak" <<- VERSIONS_MAK
CONFIG_SUB_REV = ${remote_versions[CONFIG_SUB_REV]}
GCC_VER = ${remote_versions[GCC_VER]}
BINUTILS_VER = ${remote_versions[BINUTILS_VER]}
MUSL_VER = ${remote_versions[MUSL_VER]}
GMP_VER = ${remote_versions[GMP_VER]}
MPC_VER = ${remote_versions[MPC_VER]}
MPFR_VER = ${remote_versions[MPFR_VER]}
LINUX_VER = ${remote_versions[LINUX_VER]}
ISL_VER = ${remote_versions[ISL_VER]}
VERSIONS_MAK
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Automated Change
file_pattern: "versions.json versions.mak hashes/*.sha1"
- name: Trigger workflow - matrix-mcm-build-and-release.yml
if: env.trigger_workflow == 'yes'
run: gh workflow run matrix-mcm-build-and-release.yml
- name: Await workflow - matrix-mcm-build-and-release.yml
if: env.trigger_workflow == 'yes'
uses: codex-/await-local-workflow-run@v1
with:
token: ${{ github.token }}
workflow: "matrix-mcm-build-and-release.yml"
timeout_mins: 60
poll_interval_ms: 10000
rerun-on-failure:
if: failure() && inputs.skip_rerun == '0'
name: rerun-on-failure
needs: [check_release]
permissions:
actions: write
runs-on: ubuntu-latest
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- uses: actions/checkout@v4
- name: Trigger rerun workflow on job failures
run: |
inputs_retries="${{ inputs.retries }}"
gh workflow run rerun.yml -f run_id=${{ github.run_id }} -f attempts=${{ github.run_attempt }} -f retries=${inputs_retries:-1}