Skip to content

Commit 6ef036a

Browse files
authored
Merge pull request #5671 from sysown/v3.0-fix-macos-release-upload
ci: fix macOS package naming and release upload
2 parents 0ef544c + 78f06fc commit 6ef036a

6 files changed

Lines changed: 612 additions & 30 deletions

.github/workflows/CI-build-macos-macos-13-genai.yml

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,77 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
init_release:
17+
runs-on: ubuntu-latest
18+
# No concurrency group: GitHub's "1 running + 1 pending" rule causes
19+
# mass cancellations when many workflows share a group. Instead we
20+
# run all init jobs in parallel and converge via a race-tolerant
21+
# find-or-create loop; all workers deterministically pick the
22+
# lowest-id draft matching this SHA+tag.
23+
outputs:
24+
release_id: ${{ steps.release.outputs.release_id }}
25+
release_name: ${{ steps.release.outputs.release_name }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
repository: ${{ github.repository }}
31+
ref: ${{ github.sha }}
32+
fetch-depth: 0
33+
34+
- name: Find or create draft release
35+
id: release
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
set -euo pipefail
40+
GIT_DESC=$(git describe --long --abbrev=7 --tags)
41+
TAG_NAME="${{ github.ref_name }}-head"
42+
RELEASE_NAME="${TAG_NAME} - ${GIT_DESC}"
43+
REPO="${{ github.repository }}"
44+
SHA="${{ github.sha }}"
45+
echo "Target: $RELEASE_NAME (sha $SHA)"
46+
47+
sleep $(( RANDOM % 10 ))
48+
49+
RELEASE_ID=""
50+
for attempt in 1 2 3 4 5 6; do
51+
IDS=$(gh api "repos/${REPO}/releases" --paginate \
52+
--jq ".[] | select(.draft==true and .target_commitish==\"${SHA}\" and .tag_name==\"${TAG_NAME}\") | .id" \
53+
| sort -n)
54+
if [ -n "$IDS" ]; then
55+
RELEASE_ID=$(echo "$IDS" | head -1)
56+
NDUPES=$(echo "$IDS" | wc -l)
57+
echo "attempt ${attempt}: found ${NDUPES} draft(s); using lowest id=${RELEASE_ID}"
58+
break
59+
fi
60+
echo "attempt ${attempt}: no matching draft; creating"
61+
gh api -X POST "repos/${REPO}/releases" \
62+
-f tag_name="${TAG_NAME}" \
63+
-f name="${RELEASE_NAME}" \
64+
-f target_commitish="${SHA}" \
65+
-F draft=true -F prerelease=true >/dev/null 2>&1 || true
66+
sleep $(( (RANDOM % 4) + 2 ))
67+
done
68+
69+
if [ -z "$RELEASE_ID" ]; then
70+
echo "ERROR: could not find or create draft release after retries" >&2
71+
exit 1
72+
fi
73+
74+
echo "release_id=${RELEASE_ID}" >> "$GITHUB_OUTPUT"
75+
echo "release_name=${RELEASE_NAME}" >> "$GITHUB_OUTPUT"
76+
1677
build:
78+
needs: init_release
1779
runs-on: macos-13
1880
env:
1981
ARCH: x86_64
2082
MATRIX: '(macos-x86_64-genai)'
2183
BRANCH: ${{ github.ref_name }}
84+
RELEASE_ID: ${{ needs.init_release.outputs.release_id }}
85+
PROXYSQL31: "0"
86+
PROXYSQLGENAI: "1"
2287
PKG_CONFIG_PATH: "/usr/local/opt/openssl@3/lib/pkgconfig"
2388
OPENSSL_ROOT_DIR: "/usr/local/opt/openssl@3"
2489

@@ -52,16 +117,48 @@ jobs:
52117
53118
- name: Package binary
54119
run: |
55-
GIT_VERSION=$(git describe --long --abbrev=7 --tags 2>/dev/null || echo "unknown")
56-
tar -C src -czf proxysql-${GIT_VERSION}-macos-x86_64.tar.gz proxysql
57-
shasum -a 256 proxysql-${GIT_VERSION}-macos-x86_64.tar.gz > proxysql-${GIT_VERSION}-macos-x86_64.tar.gz.sha256
120+
set -euo pipefail
121+
# Mirror Makefile tier-version bump so tarball matches the built binary's version.
122+
BASE=$(git describe --long --abbrev=7 --tags | sed 's/^v//')
123+
if [ "${PROXYSQLGENAI:-0}" = "1" ]; then
124+
VERSION=$(echo "$BASE" | awk -F. '{printf "%d.%s", $1+1, substr($0, length($1)+2)}')
125+
elif [ "${PROXYSQL31:-0}" = "1" ]; then
126+
VERSION=$(echo "$BASE" | awk -F. '{printf "%s.%d.%s", $1, $2+1, substr($0, length($1)+length($2)+3)}')
127+
else
128+
VERSION="$BASE"
129+
fi
130+
echo "Packaging as version: $VERSION"
131+
tar -C src -czf proxysql-${VERSION}-macos-x86_64.tar.gz proxysql
132+
shasum -a 256 proxysql-${VERSION}-macos-x86_64.tar.gz > proxysql-${VERSION}-macos-x86_64.tar.gz.sha256
58133
59134
- name: Upload to release
60135
env:
61136
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62137
run: |
63-
gh release create ${{ env.BRANCH }}-head --repo ${{ github.repository }} --title "${{ env.BRANCH }}-head" --target ${{ github.sha }} --draft --prerelease 2>/dev/null || true
64-
gh release upload ${{ env.BRANCH }}-head --repo ${{ github.repository }} --clobber proxysql-*-macos-x86_64.tar.gz proxysql-*-macos-x86_64.tar.gz.sha256
138+
set -euo pipefail
139+
shopt -s nullglob
140+
uploaded=0
141+
for f in proxysql-*-macos-x86_64.tar.gz proxysql-*-macos-x86_64.tar.gz.sha256; do
142+
FNAME=$(basename "$f")
143+
EXISTING=$(gh api "repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" \
144+
--jq ".[] | select(.name==\"${FNAME}\") | .id" | head -1)
145+
if [ -n "$EXISTING" ]; then
146+
echo "Replacing existing asset ${FNAME} (id=${EXISTING})"
147+
gh api -X DELETE "repos/${{ github.repository }}/releases/assets/${EXISTING}"
148+
fi
149+
echo "Uploading ${FNAME}"
150+
gh api --method POST \
151+
"https://uploads.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=${FNAME}" \
152+
--header "Content-Type: application/octet-stream" \
153+
--input "$f"
154+
uploaded=$((uploaded+1))
155+
done
156+
if [ "$uploaded" -eq 0 ]; then
157+
echo "ERROR: no macOS tarballs matched proxysql-*-macos-x86_64.tar.gz[.sha256]" >&2
158+
ls -la || true
159+
exit 1
160+
fi
161+
echo "Uploaded $uploaded asset(s) to release id=${RELEASE_ID}"
65162
66163
- uses: LouisBrunner/checks-action@v2.0.0
67164
if: always()

.github/workflows/CI-build-macos-macos-13-v31.yml

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,77 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
init_release:
17+
runs-on: ubuntu-latest
18+
# No concurrency group: GitHub's "1 running + 1 pending" rule causes
19+
# mass cancellations when many workflows share a group. Instead we
20+
# run all init jobs in parallel and converge via a race-tolerant
21+
# find-or-create loop; all workers deterministically pick the
22+
# lowest-id draft matching this SHA+tag.
23+
outputs:
24+
release_id: ${{ steps.release.outputs.release_id }}
25+
release_name: ${{ steps.release.outputs.release_name }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
repository: ${{ github.repository }}
31+
ref: ${{ github.sha }}
32+
fetch-depth: 0
33+
34+
- name: Find or create draft release
35+
id: release
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
set -euo pipefail
40+
GIT_DESC=$(git describe --long --abbrev=7 --tags)
41+
TAG_NAME="${{ github.ref_name }}-head"
42+
RELEASE_NAME="${TAG_NAME} - ${GIT_DESC}"
43+
REPO="${{ github.repository }}"
44+
SHA="${{ github.sha }}"
45+
echo "Target: $RELEASE_NAME (sha $SHA)"
46+
47+
sleep $(( RANDOM % 10 ))
48+
49+
RELEASE_ID=""
50+
for attempt in 1 2 3 4 5 6; do
51+
IDS=$(gh api "repos/${REPO}/releases" --paginate \
52+
--jq ".[] | select(.draft==true and .target_commitish==\"${SHA}\" and .tag_name==\"${TAG_NAME}\") | .id" \
53+
| sort -n)
54+
if [ -n "$IDS" ]; then
55+
RELEASE_ID=$(echo "$IDS" | head -1)
56+
NDUPES=$(echo "$IDS" | wc -l)
57+
echo "attempt ${attempt}: found ${NDUPES} draft(s); using lowest id=${RELEASE_ID}"
58+
break
59+
fi
60+
echo "attempt ${attempt}: no matching draft; creating"
61+
gh api -X POST "repos/${REPO}/releases" \
62+
-f tag_name="${TAG_NAME}" \
63+
-f name="${RELEASE_NAME}" \
64+
-f target_commitish="${SHA}" \
65+
-F draft=true -F prerelease=true >/dev/null 2>&1 || true
66+
sleep $(( (RANDOM % 4) + 2 ))
67+
done
68+
69+
if [ -z "$RELEASE_ID" ]; then
70+
echo "ERROR: could not find or create draft release after retries" >&2
71+
exit 1
72+
fi
73+
74+
echo "release_id=${RELEASE_ID}" >> "$GITHUB_OUTPUT"
75+
echo "release_name=${RELEASE_NAME}" >> "$GITHUB_OUTPUT"
76+
1677
build:
78+
needs: init_release
1779
runs-on: macos-13
1880
env:
1981
ARCH: x86_64
2082
MATRIX: '(macos-x86_64-v31)'
2183
BRANCH: ${{ github.ref_name }}
84+
RELEASE_ID: ${{ needs.init_release.outputs.release_id }}
85+
PROXYSQL31: "1"
86+
PROXYSQLGENAI: "0"
2287
PKG_CONFIG_PATH: "/usr/local/opt/openssl@3/lib/pkgconfig"
2388
OPENSSL_ROOT_DIR: "/usr/local/opt/openssl@3"
2489

@@ -52,16 +117,48 @@ jobs:
52117
53118
- name: Package binary
54119
run: |
55-
GIT_VERSION=$(git describe --long --abbrev=7 --tags 2>/dev/null || echo "unknown")
56-
tar -C src -czf proxysql-${GIT_VERSION}-macos-x86_64.tar.gz proxysql
57-
shasum -a 256 proxysql-${GIT_VERSION}-macos-x86_64.tar.gz > proxysql-${GIT_VERSION}-macos-x86_64.tar.gz.sha256
120+
set -euo pipefail
121+
# Mirror Makefile tier-version bump so tarball matches the built binary's version.
122+
BASE=$(git describe --long --abbrev=7 --tags | sed 's/^v//')
123+
if [ "${PROXYSQLGENAI:-0}" = "1" ]; then
124+
VERSION=$(echo "$BASE" | awk -F. '{printf "%d.%s", $1+1, substr($0, length($1)+2)}')
125+
elif [ "${PROXYSQL31:-0}" = "1" ]; then
126+
VERSION=$(echo "$BASE" | awk -F. '{printf "%s.%d.%s", $1, $2+1, substr($0, length($1)+length($2)+3)}')
127+
else
128+
VERSION="$BASE"
129+
fi
130+
echo "Packaging as version: $VERSION"
131+
tar -C src -czf proxysql-${VERSION}-macos-x86_64.tar.gz proxysql
132+
shasum -a 256 proxysql-${VERSION}-macos-x86_64.tar.gz > proxysql-${VERSION}-macos-x86_64.tar.gz.sha256
58133
59134
- name: Upload to release
60135
env:
61136
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62137
run: |
63-
gh release create ${{ env.BRANCH }}-head --repo ${{ github.repository }} --title "${{ env.BRANCH }}-head" --target ${{ github.sha }} --draft --prerelease 2>/dev/null || true
64-
gh release upload ${{ env.BRANCH }}-head --repo ${{ github.repository }} --clobber proxysql-*-macos-x86_64.tar.gz proxysql-*-macos-x86_64.tar.gz.sha256
138+
set -euo pipefail
139+
shopt -s nullglob
140+
uploaded=0
141+
for f in proxysql-*-macos-x86_64.tar.gz proxysql-*-macos-x86_64.tar.gz.sha256; do
142+
FNAME=$(basename "$f")
143+
EXISTING=$(gh api "repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" \
144+
--jq ".[] | select(.name==\"${FNAME}\") | .id" | head -1)
145+
if [ -n "$EXISTING" ]; then
146+
echo "Replacing existing asset ${FNAME} (id=${EXISTING})"
147+
gh api -X DELETE "repos/${{ github.repository }}/releases/assets/${EXISTING}"
148+
fi
149+
echo "Uploading ${FNAME}"
150+
gh api --method POST \
151+
"https://uploads.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=${FNAME}" \
152+
--header "Content-Type: application/octet-stream" \
153+
--input "$f"
154+
uploaded=$((uploaded+1))
155+
done
156+
if [ "$uploaded" -eq 0 ]; then
157+
echo "ERROR: no macOS tarballs matched proxysql-*-macos-x86_64.tar.gz[.sha256]" >&2
158+
ls -la || true
159+
exit 1
160+
fi
161+
echo "Uploaded $uploaded asset(s) to release id=${RELEASE_ID}"
65162
66163
- uses: LouisBrunner/checks-action@v2.0.0
67164
if: always()

.github/workflows/CI-build-macos-macos-13.yml

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,77 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
init_release:
17+
runs-on: ubuntu-latest
18+
# No concurrency group: GitHub's "1 running + 1 pending" rule causes
19+
# mass cancellations when many workflows share a group. Instead we
20+
# run all init jobs in parallel and converge via a race-tolerant
21+
# find-or-create loop; all workers deterministically pick the
22+
# lowest-id draft matching this SHA+tag.
23+
outputs:
24+
release_id: ${{ steps.release.outputs.release_id }}
25+
release_name: ${{ steps.release.outputs.release_name }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
repository: ${{ github.repository }}
31+
ref: ${{ github.sha }}
32+
fetch-depth: 0
33+
34+
- name: Find or create draft release
35+
id: release
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
set -euo pipefail
40+
GIT_DESC=$(git describe --long --abbrev=7 --tags)
41+
TAG_NAME="${{ github.ref_name }}-head"
42+
RELEASE_NAME="${TAG_NAME} - ${GIT_DESC}"
43+
REPO="${{ github.repository }}"
44+
SHA="${{ github.sha }}"
45+
echo "Target: $RELEASE_NAME (sha $SHA)"
46+
47+
sleep $(( RANDOM % 10 ))
48+
49+
RELEASE_ID=""
50+
for attempt in 1 2 3 4 5 6; do
51+
IDS=$(gh api "repos/${REPO}/releases" --paginate \
52+
--jq ".[] | select(.draft==true and .target_commitish==\"${SHA}\" and .tag_name==\"${TAG_NAME}\") | .id" \
53+
| sort -n)
54+
if [ -n "$IDS" ]; then
55+
RELEASE_ID=$(echo "$IDS" | head -1)
56+
NDUPES=$(echo "$IDS" | wc -l)
57+
echo "attempt ${attempt}: found ${NDUPES} draft(s); using lowest id=${RELEASE_ID}"
58+
break
59+
fi
60+
echo "attempt ${attempt}: no matching draft; creating"
61+
gh api -X POST "repos/${REPO}/releases" \
62+
-f tag_name="${TAG_NAME}" \
63+
-f name="${RELEASE_NAME}" \
64+
-f target_commitish="${SHA}" \
65+
-F draft=true -F prerelease=true >/dev/null 2>&1 || true
66+
sleep $(( (RANDOM % 4) + 2 ))
67+
done
68+
69+
if [ -z "$RELEASE_ID" ]; then
70+
echo "ERROR: could not find or create draft release after retries" >&2
71+
exit 1
72+
fi
73+
74+
echo "release_id=${RELEASE_ID}" >> "$GITHUB_OUTPUT"
75+
echo "release_name=${RELEASE_NAME}" >> "$GITHUB_OUTPUT"
76+
1677
build:
78+
needs: init_release
1779
runs-on: macos-13
1880
env:
1981
ARCH: x86_64
2082
MATRIX: '(macos-x86_64)'
2183
BRANCH: ${{ github.ref_name }}
84+
RELEASE_ID: ${{ needs.init_release.outputs.release_id }}
85+
PROXYSQL31: "0"
86+
PROXYSQLGENAI: "0"
2287
PKG_CONFIG_PATH: "/usr/local/opt/openssl@3/lib/pkgconfig"
2388
OPENSSL_ROOT_DIR: "/usr/local/opt/openssl@3"
2489

@@ -52,16 +117,48 @@ jobs:
52117
53118
- name: Package binary
54119
run: |
55-
GIT_VERSION=$(git describe --long --abbrev=7 --tags 2>/dev/null || echo "unknown")
56-
tar -C src -czf proxysql-${GIT_VERSION}-macos-x86_64.tar.gz proxysql
57-
shasum -a 256 proxysql-${GIT_VERSION}-macos-x86_64.tar.gz > proxysql-${GIT_VERSION}-macos-x86_64.tar.gz.sha256
120+
set -euo pipefail
121+
# Mirror Makefile tier-version bump so tarball matches the built binary's version.
122+
BASE=$(git describe --long --abbrev=7 --tags | sed 's/^v//')
123+
if [ "${PROXYSQLGENAI:-0}" = "1" ]; then
124+
VERSION=$(echo "$BASE" | awk -F. '{printf "%d.%s", $1+1, substr($0, length($1)+2)}')
125+
elif [ "${PROXYSQL31:-0}" = "1" ]; then
126+
VERSION=$(echo "$BASE" | awk -F. '{printf "%s.%d.%s", $1, $2+1, substr($0, length($1)+length($2)+3)}')
127+
else
128+
VERSION="$BASE"
129+
fi
130+
echo "Packaging as version: $VERSION"
131+
tar -C src -czf proxysql-${VERSION}-macos-x86_64.tar.gz proxysql
132+
shasum -a 256 proxysql-${VERSION}-macos-x86_64.tar.gz > proxysql-${VERSION}-macos-x86_64.tar.gz.sha256
58133
59134
- name: Upload to release
60135
env:
61136
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62137
run: |
63-
gh release create ${{ env.BRANCH }}-head --repo ${{ github.repository }} --title "${{ env.BRANCH }}-head" --target ${{ github.sha }} --draft --prerelease 2>/dev/null || true
64-
gh release upload ${{ env.BRANCH }}-head --repo ${{ github.repository }} --clobber proxysql-*-macos-x86_64.tar.gz proxysql-*-macos-x86_64.tar.gz.sha256
138+
set -euo pipefail
139+
shopt -s nullglob
140+
uploaded=0
141+
for f in proxysql-*-macos-x86_64.tar.gz proxysql-*-macos-x86_64.tar.gz.sha256; do
142+
FNAME=$(basename "$f")
143+
EXISTING=$(gh api "repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" \
144+
--jq ".[] | select(.name==\"${FNAME}\") | .id" | head -1)
145+
if [ -n "$EXISTING" ]; then
146+
echo "Replacing existing asset ${FNAME} (id=${EXISTING})"
147+
gh api -X DELETE "repos/${{ github.repository }}/releases/assets/${EXISTING}"
148+
fi
149+
echo "Uploading ${FNAME}"
150+
gh api --method POST \
151+
"https://uploads.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=${FNAME}" \
152+
--header "Content-Type: application/octet-stream" \
153+
--input "$f"
154+
uploaded=$((uploaded+1))
155+
done
156+
if [ "$uploaded" -eq 0 ]; then
157+
echo "ERROR: no macOS tarballs matched proxysql-*-macos-x86_64.tar.gz[.sha256]" >&2
158+
ls -la || true
159+
exit 1
160+
fi
161+
echo "Uploaded $uploaded asset(s) to release id=${RELEASE_ID}"
65162
66163
- uses: LouisBrunner/checks-action@v2.0.0
67164
if: always()

0 commit comments

Comments
 (0)