Files
desktop-edge-win/scripts/publish-release.sh
T
Christopher Britton b16e80acf2 Switch release notes back to a single release-notes.md file (#1022)
* Switch release notes back to a single release-notes.md file

* Add CI check that GitHub's latest release matches latest.json

* Fix prepare-beta release note preview

* Get release note version number from version file, check win32 crypto 'latest' against latest.json in CI

* Split release notes archive into yearly release notes
2026-06-25 09:20:36 -04:00

119 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
version="$1"
if ! grep -qE "^# Release ${version}\$" release-notes.md; then
echo "❌ Version ${version} not found in release-notes.md!"
exit 1
fi
release_notes=$(awk -v ver="# Release ${version}" '
grab && /^# Release / && $0 != ver {exit}
$0 == ver {grab=1}
grab' release-notes.md)
if [[ "$release_notes" != \#\ Release\ "$version"* ]]; then
echo "❌ release_notes does not start with '# Release $version'" >&2
exit 1
fi
action_id="$2"
repo="openziti/desktop-edge-win"
tmp_dir="/tmp/zdew-artifacts"
rm -rf "/tmp/zdew-artifacts"
mkdir -p "${tmp_dir}"
if ! json=$(gh api "repos/${repo}/actions/runs/${action_id}/artifacts" --jq '.artifacts[] | {name, url: .archive_download_url}'); then
echo "❌ Failed to fetch artifacts" >&2
exit 1
fi
echo "$json" | jq -c '.' | while read -r artifact; do
#echo "$json" | jq -c 'select(.name | test("win32crypto"))' | while read -r artifact; do
name=$(echo "$artifact" | jq -r .name)
url=$(echo "$artifact" | jq -r .url)
[[ -z "$url" ]] && {
echo "⚠️ Skipping artifact with missing URL: $name" >&2
continue
}
zip_path="${tmp_dir}/${name}.zip"
if ! gh api "$url" > "$zip_path"; then
echo "❌ Failed to download $url" >&2
exit 1
fi
echo "📂 Unzipping to ${tmp_dir}/${name}"
unzip -oq "$zip_path" -d "${tmp_dir}/${name}" || {
echo "❌ Failed to unzip to ${tmp_dir}/${name}" >&2
exit 1
}
done
rm "${tmp_dir}"/*.zip
artifact_version=$(find "${tmp_dir}" -name "*.exe" | grep -oP '\d+\.\d+\.\d+(\.\d+)?' | sort | uniq )
count=$(echo "${artifact_version}" | wc -l)
if [[ "$count" -eq 1 ]]; then
echo "✅ All artifact versions matched: ${artifact_version}. Uploading..."
else
echo "❌ Version mismatch detected:"
echo "${artifact_version}"
exit 1
fi
if [[ "${artifact_version}" == "${version}" ]]; then
echo "✅ artifact version ${artifact_version} matched supplied version: ${version}. Uploading can continue..."
else
echo "❌ artifact version ${artifact_version} does not match supplied version: ${version}:"
exit 1
fi
for f in "${tmp_dir}/ZitiDesktopEdgeClient-${artifact_version}-win32crypto"/*; do
new="$(dirname "$f")/$(basename "$f" | tr ' ' '.')"
echo "renaming $f"
echo " to $new"
mv "$f" "$new"
echo "---------"
done
repo="downloads"
base_path="${tmp_dir}/ZitiDesktopEdgeClient-${artifact_version}-win32crypto"
for file in "$base_path"/*; do
name=$(basename "$file")
url="https://netfoundry.jfrog.io/artifactory/$repo/desktop-edge-win-win32crypto/${artifact_version}/$name"
echo "⬆️ Uploading $name to $url"
response=$(curl -s -w "%{http_code}" -o /dev/null \
-H "Authorization: Bearer $JFROG_ACCESS_TOKEN" \
-T "$file" "$url")
if [[ "$response" == "201" || "$response" == "200" ]]; then
echo "✅ Uploaded: $name"
else
echo "❌ Failed to upload $name (HTTP $response)" >&2
exit 1
fi
done
echo "Creating a release on GitHub"
gh release create "${version}" \
--target "${GITHUB_REF_NAME}" \
--title "${version}" \
--notes "$release_notes" \
--prerelease
gh release upload "${version}" "${tmp_dir}/ZitiDesktopEdgeClient-${version}"/*
admin_templates_dir="${tmp_dir}/ZDEW-AdminTemplates-${version}"
if [[ -d "${admin_templates_dir}" ]]; then
echo "Uploading admin templates assets to release ${version}"
gh release upload "${version}" "${admin_templates_dir}"/*
else
echo "WARNING: ${admin_templates_dir} not found; admin templates assets NOT uploaded to release"
fi