Skip to content

Commit 03a425b

Browse files
committed
reorg of the publishing details
1 parent 5e43308 commit 03a425b

File tree

2 files changed

+71
-12
lines changed

2 files changed

+71
-12
lines changed

.github/scripts/wait_for_crates.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
3+
# Wait for one or more crates to appear on crates.io at the current workspace version.
4+
#
5+
# Usage:
6+
# ./github/scripts/wait_for_crates.sh crate1 [crate2 ...]
7+
#
8+
# Environment variables:
9+
# MAX_ATTEMPTS - number of attempts (default: 10)
10+
# SLEEP_SECONDS - delay between attempts (default: 30)
11+
12+
set -euo pipefail
13+
14+
if [[ $# -lt 1 ]]; then
15+
echo "Usage: $0 crate1 [crate2 ...]" >&2
16+
exit 1
17+
fi
18+
19+
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
20+
VERSION=$(
21+
awk '
22+
/^\[workspace.package\]/ { in_section=1; next }
23+
/^\[/ { if (in_section) exit; in_section=0 }
24+
in_section && $1 ~ /^version/ {
25+
gsub(/"/, "", $3);
26+
print $3;
27+
exit
28+
}
29+
' "${REPO_ROOT}/Cargo.toml"
30+
)
31+
32+
if [[ -z "${VERSION}" ]]; then
33+
echo "Failed to determine workspace version from Cargo.toml" >&2
34+
exit 1
35+
fi
36+
37+
MAX_ATTEMPTS=${MAX_ATTEMPTS:-10}
38+
SLEEP_SECONDS=${SLEEP_SECONDS:-30}
39+
40+
for crate in "$@"; do
41+
echo "Waiting for ${crate} ${VERSION} to appear on crates.io..."
42+
success=0
43+
for attempt in $(seq 1 "${MAX_ATTEMPTS}"); do
44+
if curl --silent --fail "https://crates.io/api/v1/crates/${crate}/${VERSION}" >/dev/null; then
45+
echo "Found ${crate} ${VERSION} on attempt ${attempt}."
46+
success=1
47+
break
48+
fi
49+
echo "Attempt ${attempt}/${MAX_ATTEMPTS}: ${crate} ${VERSION} not visible yet; retrying in ${SLEEP_SECONDS}s..."
50+
sleep "${SLEEP_SECONDS}"
51+
done
52+
if [[ "${success}" -ne 1 ]]; then
53+
echo "Timed out waiting for ${crate} ${VERSION} to propagate to crates.io." >&2
54+
exit 1
55+
fi
56+
done

.github/workflows/artifacts.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ jobs:
4242
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
4343
- uses: actions/upload-artifact@v4
4444
with:
45-
name: ontoenv_x86_64_linux_gnu
45+
name: ontoenv_x86_64_linux_gnu_${{ github.run_attempt }}
4646
path: target/release/ontoenv
4747
- uses: actions/upload-artifact@v4
4848
with:
49-
name: ontoenv_aarch64_linux_gnu
49+
name: ontoenv_aarch64_linux_gnu_${{ github.run_attempt }}
5050
path: target/aarch64-unknown-linux-gnu/release/ontoenv
5151
- run: mv target/release/ontoenv ontoenv_${{ github.event.release.tag_name }}_x86_64_linux_gnu
5252
if: github.event_name == 'release'
@@ -75,11 +75,11 @@ jobs:
7575
working-directory: ./cli
7676
- uses: actions/upload-artifact@v4
7777
with:
78-
name: ontoenv_x86_64_apple
78+
name: ontoenv_x86_64_apple_${{ github.run_attempt }}
7979
path: target/release/ontoenv
8080
- uses: actions/upload-artifact@v4
8181
with:
82-
name: ontoenv_aarch64_apple
82+
name: ontoenv_aarch64_apple_${{ github.run_attempt }}
8383
path: target/aarch64-apple-darwin/release/ontoenv
8484
- run: mv target/release/ontoenv ontoenv_${{ github.event.release.tag_name }}_x86_64_apple
8585
if: github.event_name == 'release'
@@ -107,7 +107,7 @@ jobs:
107107
working-directory: ./cli
108108
- uses: actions/upload-artifact@v4
109109
with:
110-
name: ontoenv_x86_64_windows_msvc
110+
name: ontoenv_x86_64_windows_msvc_${{ github.run_attempt }}
111111
path: target/release/ontoenv.exe
112112
- run: mv target/release/ontoenv.exe ontoenv_${{ github.event.release.tag_name }}_x86_64_windows_msvc.exe
113113
if: github.event_name == 'release'
@@ -137,7 +137,7 @@ jobs:
137137
- run: maturin sdist -m python/Cargo.toml
138138
- uses: actions/upload-artifact@v4
139139
with:
140-
name: ontoenv_dist
140+
name: pyontoenv_dist_${{ github.run_attempt }}
141141
path: target/wheels/*.tar.gz
142142
python_pyontoenv_alias:
143143
runs-on: ubuntu-latest
@@ -165,7 +165,7 @@ jobs:
165165
working-directory: ./pyontoenv-shim
166166
- uses: actions/upload-artifact@v4
167167
with:
168-
name: ontoenv_pyontoenv_alias
168+
name: pyontoenv_alias_${{ github.run_attempt }}
169169
path: pyontoenv-shim/dist/*
170170

171171
wheel_linux:
@@ -190,7 +190,7 @@ jobs:
190190
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true') || matrix.architecture == 'x86_64'
191191
- uses: actions/upload-artifact@v4
192192
with:
193-
name: ontoenv_${{ matrix.architecture }}_linux_gnu
193+
name: pyontoenv_${{ matrix.architecture }}_linux_gnu_${{ github.run_attempt }}
194194
path: target/wheels/*.whl
195195

196196
wheel_linux_musl:
@@ -216,7 +216,7 @@ jobs:
216216
- run: find .
217217
- uses: actions/upload-artifact@v4
218218
with:
219-
name: ontoenv_${{ matrix.architecture }}_linux_musl
219+
name: pyontoenv_${{ matrix.architecture }}_linux_musl_${{ github.run_attempt }}
220220
path: target/wheels/*.whl
221221

222222
wheel_mac:
@@ -257,7 +257,7 @@ jobs:
257257
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_matrix == 'true')
258258
- uses: actions/upload-artifact@v4
259259
with:
260-
name: ontoenv_macos
260+
name: pyontoenv_macos_${{ github.run_attempt }}
261261
path: target/wheels/*.whl
262262

263263
wheel_windows:
@@ -283,7 +283,7 @@ jobs:
283283
- run: maturin build --release -m python/Cargo.toml --features abi3
284284
- uses: actions/upload-artifact@v4
285285
with:
286-
name: ontoenv_windows
286+
name: pyontoenv_windows_${{ github.run_attempt }}
287287
path: target/wheels/*.whl
288288

289289
publish_pypi:
@@ -304,7 +304,7 @@ jobs:
304304
steps:
305305
- uses: actions/download-artifact@v4
306306
with:
307-
pattern: ontoenv_*
307+
pattern: pyontoenv_*
308308
path: dist
309309
merge-multiple: true
310310
- uses: pypa/gh-action-pypi-publish@release/v1
@@ -336,6 +336,9 @@ jobs:
336336
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
337337
env:
338338
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
339+
- name: Wait for crate availability
340+
if: github.event_name == 'release'
341+
run: ./.github/scripts/wait_for_crates.sh ontoenv ontoenv-cli
339342
full_archive:
340343
if: github.event_name == 'release'
341344
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)