R3
This commit is contained in:
+6
-2
@@ -25,11 +25,15 @@ references it as `${{ secrets.RELEASE_TOKEN }}`; the value is never committed.
|
|||||||
Each push to `main` runs tests and packaging. The publish script:
|
Each push to `main` runs tests and packaging. The publish script:
|
||||||
|
|
||||||
1. Deletes the existing release associated with `rolling`, if present.
|
1. Deletes the existing release associated with `rolling`, if present.
|
||||||
2. Moves or creates the `rolling` tag at the pushed commit.
|
2. Deletes and recreates the `rolling` tag at the pushed commit using Gitea's
|
||||||
|
repository tag API.
|
||||||
3. Creates a prerelease named with the commit prefix.
|
3. Creates a prerelease named with the commit prefix.
|
||||||
4. Uploads the `.deb`, extension ZIP, and `SHA256SUMS`.
|
4. Uploads the `.deb`, extension ZIP, and `SHA256SUMS`.
|
||||||
|
|
||||||
The moving tag is intentionally mutable. Permanent releases should use reviewed
|
The moving tag is intentionally mutable. This server's Swagger API exposes tag
|
||||||
|
replacement as `DELETE /repos/{owner}/{repo}/tags/{tag}` followed by
|
||||||
|
`POST /repos/{owner}/{repo}/tags`; the publisher uses that contract rather than
|
||||||
|
the unsupported Git refs patch route. Permanent releases should use reviewed
|
||||||
immutable tags after validating a rolling artifact.
|
immutable tags after validating a rolling artifact.
|
||||||
|
|
||||||
## Local rehearsal
|
## Local rehearsal
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ set -euo pipefail
|
|||||||
: "${RELEASE_TOKEN:?RELEASE_TOKEN is required}"
|
: "${RELEASE_TOKEN:?RELEASE_TOKEN is required}"
|
||||||
|
|
||||||
API="${GITEA_SERVER_URL%/}/api/v1/repos/${GITEA_REPOSITORY}"
|
API="${GITEA_SERVER_URL%/}/api/v1/repos/${GITEA_REPOSITORY}"
|
||||||
AUTH=(-H "Authorization: token ${RELEASE_TOKEN}" -H 'Accept: application/json' -H 'Content-Type: application/json')
|
AUTH=(-H "Authorization: token ${RELEASE_TOKEN}" -H 'Accept: application/json')
|
||||||
|
JSON=(-H 'Content-Type: application/json')
|
||||||
TAG="rolling"
|
TAG="rolling"
|
||||||
|
|
||||||
release_json="$(curl -fsS "${AUTH[@]}" "${API}/releases/tags/${TAG}" 2>/dev/null || true)"
|
release_json="$(curl -fsS "${AUTH[@]}" "${API}/releases/tags/${TAG}" 2>/dev/null || true)"
|
||||||
@@ -18,15 +19,16 @@ if [[ -n "${release_json}" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tag_payload="$(jq -nc --arg sha "${GITEA_SHA}" '{new_target:$sha, force:true}')"
|
# This Gitea instance exposes tag replacement through the repository tag API;
|
||||||
if ! curl -fsS -X PATCH "${AUTH[@]}" "${API}/git/refs/tags/${TAG}" --data "${tag_payload}" >/dev/null 2>&1; then
|
# it does not implement PATCH /git/refs/{ref}.
|
||||||
create_tag="$(jq -nc --arg sha "${GITEA_SHA}" --arg ref "refs/tags/${TAG}" '{ref:$ref, sha:$sha}')"
|
curl -fsS -X DELETE "${AUTH[@]}" "${API}/tags/${TAG}" >/dev/null 2>&1 || true
|
||||||
curl -fsS -X POST "${AUTH[@]}" "${API}/git/refs" --data "${create_tag}" >/dev/null
|
tag_payload="$(jq -nc --arg sha "${GITEA_SHA}" --arg tag "${TAG}" \
|
||||||
fi
|
'{tag_name:$tag, target:$sha, message:"Automated rolling tag"}')"
|
||||||
|
curl -fsS -X POST "${AUTH[@]}" "${JSON[@]}" "${API}/tags" --data "${tag_payload}" >/dev/null
|
||||||
|
|
||||||
release_payload="$(jq -nc --arg tag "${TAG}" --arg sha "${GITEA_SHA}" \
|
release_payload="$(jq -nc --arg tag "${TAG}" --arg sha "${GITEA_SHA}" \
|
||||||
'{tag_name:$tag, target_commitish:$sha, name:("Rolling " + ($sha[0:12])), body:"Automated Gitea rolling release from main.", draft:false, prerelease:true}')"
|
'{tag_name:$tag, target_commitish:$sha, name:("Rolling " + ($sha[0:12])), body:"Automated Gitea rolling release from main.", draft:false, prerelease:true}')"
|
||||||
created="$(curl -fsS -X POST "${AUTH[@]}" "${API}/releases" --data "${release_payload}")"
|
created="$(curl -fsS -X POST "${AUTH[@]}" "${JSON[@]}" "${API}/releases" --data "${release_payload}")"
|
||||||
release_id="$(jq -r '.id // empty' <<<"${created}")"
|
release_id="$(jq -r '.id // empty' <<<"${created}")"
|
||||||
test -n "${release_id}"
|
test -n "${release_id}"
|
||||||
|
|
||||||
@@ -34,6 +36,6 @@ for asset in dist/jarvis-qvac_*.deb dist/jarvis-qvac-extension.zip dist/SHA256SU
|
|||||||
[[ -f "${asset}" ]] || continue
|
[[ -f "${asset}" ]] || continue
|
||||||
curl -fsS -X POST "${AUTH[@]}" \
|
curl -fsS -X POST "${AUTH[@]}" \
|
||||||
"${API}/releases/${release_id}/assets?name=$(basename "${asset}")" \
|
"${API}/releases/${release_id}/assets?name=$(basename "${asset}")" \
|
||||||
-H 'Content-Type: application/octet-stream' --data-binary "@${asset}" >/dev/null
|
-F "attachment=@${asset}" >/dev/null
|
||||||
done
|
done
|
||||||
echo "Published Gitea rolling release ${TAG} for ${GITEA_SHA:0:12}"
|
echo "Published Gitea rolling release ${TAG} for ${GITEA_SHA:0:12}"
|
||||||
|
|||||||
Reference in New Issue
Block a user