-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathCI-package-arm64-centos10-genai.yml
More file actions
159 lines (143 loc) · 5.47 KB
/
Copy pathCI-package-arm64-centos10-genai.yml
File metadata and controls
159 lines (143 loc) · 5.47 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
name: CI-package-arm64-centos10-genai
run-name: '${{ github.ref_name }} ${{ github.workflow }} ${{ github.sha }}'
on:
workflow_dispatch:
permissions:
contents: write
checks: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
init_release:
runs-on: ubuntu-latest
# No concurrency group: GitHub's "1 running + 1 pending" rule causes
# mass cancellations when many workflows share a group. Instead we
# run all init jobs in parallel and converge via a race-tolerant
# find-or-create loop; all workers deterministically pick the
# lowest-id draft matching this SHA+tag.
outputs:
release_id: ${{ steps.release.outputs.release_id }}
release_name: ${{ steps.release.outputs.release_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.sha }}
fetch-depth: 0
- name: Find or create draft release
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
GIT_DESC=$(git describe --long --abbrev=7 --tags)
TAG_NAME="${{ github.ref_name }}-head"
RELEASE_NAME="${TAG_NAME} - ${GIT_DESC}"
REPO="${{ github.repository }}"
SHA="${{ github.sha }}"
echo "Target: $RELEASE_NAME (sha $SHA)"
# Stagger start to reduce the thundering-herd on first create
sleep $(( RANDOM % 10 ))
RELEASE_ID=""
for attempt in 1 2 3 4 5 6; do
IDS=$(gh api "repos/${REPO}/releases" --paginate \
--jq ".[] | select(.draft==true and .target_commitish==\"${SHA}\" and .tag_name==\"${TAG_NAME}\") | .id" \
| sort -n)
if [ -n "$IDS" ]; then
RELEASE_ID=$(echo "$IDS" | head -1)
NDUPES=$(echo "$IDS" | wc -l)
echo "attempt ${attempt}: found ${NDUPES} draft(s); using lowest id=${RELEASE_ID}"
break
fi
echo "attempt ${attempt}: no matching draft; creating"
gh api -X POST "repos/${REPO}/releases" \
-f tag_name="${TAG_NAME}" \
-f name="${RELEASE_NAME}" \
-f target_commitish="${SHA}" \
-F draft=true -F prerelease=true >/dev/null 2>&1 || true
sleep $(( (RANDOM % 4) + 2 ))
done
if [ -z "$RELEASE_ID" ]; then
echo "ERROR: could not find or create draft release after retries" >&2
exit 1
fi
echo "release_id=${RELEASE_ID}" >> "$GITHUB_OUTPUT"
echo "release_name=${RELEASE_NAME}" >> "$GITHUB_OUTPUT"
build:
needs: init_release
runs-on: ubuntu-24.04-arm
env:
ARCH: arm64
DIST: centos10
MAKE_TARGET: centos10
MATRIX: '(arm64,centos10-genai)'
BRANCH: ${{ github.ref_name }}
RELEASE_ID: ${{ needs.init_release.outputs.release_id }}
steps:
- uses: LouisBrunner/checks-action@v2.0.0
id: checks
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: '${{ github.workflow }} / ${{ github.job }} ${{ env.MATRIX }}'
repo: ${{ github.repository }}
sha: ${{ github.sha }}
status: 'in_progress'
details_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.sha }}
fetch-depth: 0
- name: Build package
run: |
PROXYSQL40=1 make ${{ env.MAKE_TARGET }}
- name: Verify package installs on clean ${{ env.DISTRO }}
run: |
PKG=$(ls binaries/*.deb binaries/*.rpm 2>/dev/null | head -1)
if [[ -z "$PKG" ]]; then
echo "ERROR: no package file found in binaries/" >&2
ls -la binaries/
exit 1
fi
test/infra/control/verify-package-install.bash "$PKG"
- name: Upload to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
shopt -s nullglob
uploaded=0
for f in binaries/*[mb] binaries/*.id-hash; do
FNAME=$(basename "$f")
EXISTING=$(gh api "repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" \
--jq ".[] | select(.name==\"${FNAME}\") | .id" | head -1)
if [ -n "$EXISTING" ]; then
echo "Replacing existing asset ${FNAME} (id=${EXISTING})"
gh api -X DELETE "repos/${{ github.repository }}/releases/assets/${EXISTING}"
fi
echo "Uploading ${FNAME}"
gh api --method POST \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=${FNAME}" \
--header "Content-Type: application/octet-stream" \
--input "$f"
uploaded=$((uploaded+1))
done
if [ "$uploaded" -eq 0 ]; then
echo "ERROR: no package files matched binaries/*[mb] or binaries/*.id-hash" >&2
ls -la binaries/ || true
exit 1
fi
echo "Uploaded $uploaded asset(s) to release id=${RELEASE_ID}"
- uses: LouisBrunner/checks-action@v2.0.0
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
check_id: ${{ steps.checks.outputs.check_id }}
repo: ${{ github.repository }}
sha: ${{ github.sha }}
conclusion: ${{ job.status }}
details_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'