ci: split prepare and publish into separate release pipelines
All checks were successful
Push Validation / validate (push) Successful in 54s
All checks were successful
Push Validation / validate (push) Successful in 54s
- Remove publish steps (release creation, binary build/upload) from the Prepare Release workflow; it now stops after committing and pushing the tag. - Add Do Release workflow triggered on v*.*.* tag pushes; reads release notes from the tagged changelog section, creates or updates the release, builds linux/amd64 and linux/arm64 binaries, uploads assets, then smoke-tests both binaries in a follow-on validate job. - Remove the standalone Action Validation workflow; binary validation now runs as a second job in Do Release after the release job succeeds, using the exact tag and version just published. - Update README to document the two-workflow release model and add split prepare/publish usage examples for both the composite action and the reusable workflows. - Update changelog unreleased section to reflect the new pipeline split and corrected artifact scope (linux/amd64 and linux/arm64 only).
This commit is contained in:
@@ -111,127 +111,17 @@ jobs:
|
||||
git push origin HEAD
|
||||
git push origin "$tag"
|
||||
|
||||
- name: Create release with changelog notes
|
||||
- name: Summarize prepared release
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
normalized_version="${RELEASE_VERSION#v}"
|
||||
tag="v${normalized_version}"
|
||||
|
||||
release_notes="$(awk -v version="$normalized_version" '
|
||||
$0 ~ "^## \\\\[" version "\\\\] - " {capture=1}
|
||||
capture {
|
||||
if ($0 ~ "^## \\\\[" && $0 !~ "^## \\\\[" version "\\\\] - ") exit
|
||||
print
|
||||
}
|
||||
' changelog.md)"
|
||||
|
||||
if [[ -z "${release_notes//[[:space:]]/}" ]]; then
|
||||
echo "Release notes section for ${normalized_version} was not found in changelog.md" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
escaped_release_notes="$(printf '%s' "$release_notes" | sed 's/\\/\\\\/g; s/"/\\"/g; :a;N;$!ba;s/\n/\\n/g')"
|
||||
release_api="${GITHUB_API_URL:-${GITHUB_SERVER_URL%/}/api/v1}/repos/${GITHUB_REPOSITORY}/releases"
|
||||
release_by_tag_api="${release_api}/tags/${tag}"
|
||||
|
||||
status_code="$(curl -sS -o release-existing.json -w '%{http_code}' \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${release_by_tag_api}")"
|
||||
|
||||
if [[ "$status_code" == "200" ]]; then
|
||||
existing_release_id="$(sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' release-existing.json | head -n 1)"
|
||||
if [[ -z "$existing_release_id" ]]; then
|
||||
echo "Failed to parse existing release id for ${tag}" >&2
|
||||
cat release-existing.json >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl --fail-with-body \
|
||||
-X PATCH \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${release_api}/${existing_release_id}" \
|
||||
--data "{\"tag_name\":\"${tag}\",\"target\":\"${GITHUB_SHA}\",\"name\":\"${tag}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
||||
--output release.json
|
||||
elif [[ "$status_code" != "404" ]]; then
|
||||
echo "Unexpected response while checking release ${tag}: HTTP ${status_code}" >&2
|
||||
cat release-existing.json >&2
|
||||
exit 1
|
||||
else
|
||||
curl --fail-with-body \
|
||||
-X POST \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${release_api}" \
|
||||
--data "{\"tag_name\":\"${tag}\",\"target\":\"${GITHUB_SHA}\",\"name\":\"${tag}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
||||
--output release.json
|
||||
fi
|
||||
|
||||
release_id="$(sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' release.json | head -n 1)"
|
||||
if [[ -z "$release_id" ]]; then
|
||||
echo "Failed to parse release id from API response" >&2
|
||||
cat release.json >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "RELEASE_ID=$release_id" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
normalized_version="${RELEASE_VERSION#v}"
|
||||
mkdir -p dist
|
||||
|
||||
for target in linux/amd64 linux/arm64; do
|
||||
os="${target%/*}"
|
||||
arch="${target#*/}"
|
||||
|
||||
bin="vociferate_${normalized_version}_${os}_${arch}"
|
||||
GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags="-s -w" -o "dist/${bin}" ./cmd/vociferate
|
||||
done
|
||||
|
||||
(
|
||||
cd dist
|
||||
shasum -a 256 * > checksums.txt
|
||||
)
|
||||
|
||||
- name: Upload release binaries
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "${RELEASE_ID:-}" ]]; then
|
||||
echo "RELEASE_ID is not available for asset upload" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
release_api="${GITHUB_API_URL:-${GITHUB_SERVER_URL%/}/api/v1}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets"
|
||||
|
||||
for asset in dist/*; do
|
||||
name="$(basename "$asset")"
|
||||
|
||||
assets_json="$(curl -sS --fail-with-body \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${release_api}")"
|
||||
|
||||
escaped_name="$(printf '%s' "$name" | sed 's/[][(){}.^$*+?|\\/]/\\&/g')"
|
||||
existing_asset_id="$(printf '%s' "$assets_json" | tr -d '\n' | sed -n "s/.*{\"id\":\([0-9][0-9]*\)[^}]*\"name\":\"${escaped_name}\".*/\1/p")"
|
||||
|
||||
if [[ -n "$existing_asset_id" ]]; then
|
||||
curl --fail-with-body \
|
||||
-X DELETE \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${release_api}/${existing_asset_id}"
|
||||
fi
|
||||
|
||||
curl --fail-with-body \
|
||||
-X POST \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
"${release_api}?name=${name}" \
|
||||
--data-binary "@${asset}"
|
||||
done
|
||||
{
|
||||
echo "## Release Prepared"
|
||||
echo
|
||||
echo "- Updated files were committed to main."
|
||||
echo "- Tag pushed: ${tag}"
|
||||
echo "- The tag-triggered Do Release workflow will create or update the release and publish binaries."
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
Reference in New Issue
Block a user