4949 with :
5050 fetch-depth : 0
5151
52+ - name : Resolve version from tag
53+ shell : bash
54+ run : |
55+ ref="${GITHUB_REF_NAME}"
56+ echo "H5CPP_VERSION=${ref#v}" >> "$GITHUB_ENV"
57+
5258 - name : Install LLVM toolchain (Linux)
5359 if : runner.os == 'Linux'
5460 shell : bash
@@ -156,7 +162,8 @@ jobs:
156162 -DCMAKE_BUILD_TYPE=Release \
157163 -DLLVM_DIR="$LLVM_DIR" \
158164 -DClang_DIR="$Clang_DIR" \
159- -DH5CPP_STATIC_LINK_LLVM=ON
165+ -DH5CPP_STATIC_LINK_LLVM=ON \
166+ -DH5CPP_VERSION_OVERRIDE="${H5CPP_VERSION:-}"
160167
161168 - name : Configure (Windows)
162169 if : runner.os == 'Windows'
@@ -167,7 +174,8 @@ jobs:
167174 -DCMAKE_BUILD_TYPE=Release `
168175 -DLLVM_DIR="$env:LLVM_DIR" `
169176 -DClang_DIR="$env:Clang_DIR" `
170- -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
177+ -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
178+ -DH5CPP_VERSION_OVERRIDE="$env:H5CPP_VERSION"
171179
172180 - name : Build
173181 shell : bash
@@ -187,7 +195,12 @@ jobs:
187195 uses : actions/upload-artifact@v4
188196 with :
189197 name : h5cpp-compiler-${{ matrix.os }}-${{ matrix.format }}
190- path : build/h5cpp-compiler-*
198+ if-no-files-found : error
199+ path : |
200+ build/h5cpp-compiler-*.deb
201+ build/h5cpp-compiler-*.rpm
202+ build/h5cpp-compiler-*.exe
203+ build/h5cpp-compiler-*.pkg
191204
192205 publish :
193206 name : Publish Release
@@ -208,10 +221,51 @@ jobs:
208221 - name : Create Release and upload assets
209222 shell : bash
210223 run : |
211- set -euxo pipefail
224+ set -euo pipefail
212225 tag="${GITHUB_REF_NAME}"
213- gh release create "$tag" --generate-notes || true
214- find artifacts -type f -name "h5cpp-compiler-*" -print0 | \
215- xargs -0 gh release upload "$tag" --clobber
226+
227+ # Ensure release exists. Idempotent: create only if missing,
228+ # so a re-run of the workflow against the same tag does not 422.
229+ if ! gh release view "$tag" >/dev/null 2>&1; then
230+ gh release create "$tag" \
231+ --title "h5cpp-compiler-${tag}" \
232+ --generate-notes
233+ fi
234+
235+ # Collect installer artifacts only. Defensive against stray
236+ # CMake-generated files (e.g. h5cpp-compiler-dev.sln on Windows).
237+ shopt -s globstar nullglob
238+ files=( artifacts/**/*.deb artifacts/**/*.rpm artifacts/**/*.exe artifacts/**/*.pkg )
239+ if (( ${#files[@]} == 0 )); then
240+ echo "no installer artifacts found under artifacts/" >&2
241+ exit 1
242+ fi
243+
244+ # Upload each file with bounded retries. uploads.github.com is
245+ # eventually consistent right after release creation and
246+ # occasionally 404s on first POST.
247+ failed=()
248+ for f in "${files[@]}"; do
249+ [[ -f "$f" ]] || continue
250+ echo "::group::upload $(basename "$f")"
251+ ok=0
252+ for attempt in 1 2 3 4 5; do
253+ if gh release upload "$tag" "$f" --clobber; then
254+ ok=1
255+ break
256+ fi
257+ backoff=$(( attempt * attempt * 2 ))
258+ echo "attempt ${attempt} failed; retrying in ${backoff}s"
259+ sleep "${backoff}"
260+ done
261+ echo "::endgroup::"
262+ (( ok == 1 )) || failed+=( "$f" )
263+ done
264+
265+ if (( ${#failed[@]} > 0 )); then
266+ echo "Upload failed for:" >&2
267+ printf ' - %s\n' "${failed[@]}" >&2
268+ exit 1
269+ fi
216270 env :
217271 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments