BlueGit

golden-age paperdoll-renderer

Files

paperdoll-renderer / scripts / ci / release.sh

release.sh

release.sh 2.4 KiB Download Raw
1#!/usr/bin/env bash
2# Tag-pipeline publish step (design.md, "v0.1.0 release" decision).
3#
4# Publishes the release for the tag that started this pipeline with
5# POST $CI_API_URL/repos/{owner}/{repo}/releases/{tag}/assets — BlueGit's
6# create-only route for an existing tag: an existing release is HTTP 409, it
7# never creates, moves or deletes the tag, and the assets are artifacts of
8# successful jobs of this same pipeline. `replace` is never sent and the
9# tag-creating route POST .../releases is never called.
10set -euo pipefail
11
12: "${CI_API_URL:?}" "${CI_JOB_TOKEN:?}" "${CI_COMMIT_SHA:?}" "${CI_PROJECT_PATH:?}" "${CI_COMMIT_TAG:?}"
13
14root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
15cd "$root"
16version="$(bash scripts/ci/package-version.sh)"
17tag="$CI_COMMIT_TAG"
18[[ "$tag" == "v$version" ]] || { echo "tag $tag does not match package version $version" >&2; exit 1; }
19
20b="paperdoll-renderer-${tag}"
21asset() { printf '{"job":"%s","path":"%s","name":"%s"}' "$1" "$2" "$3"; }
22assets="$(asset package:appimage dist/paperdoll-renderer-x86_64.AppImage "${b}-x86_64.AppImage"),$(asset package:ubuntu dist/paperdoll-renderer_amd64.deb "${b}-amd64.deb"),$(asset package:arch dist/paperdoll-renderer-x86_64.pkg.tar.zst "${b}-x86_64.pkg.tar.zst"),$(asset package:windows dist/paperdoll-renderer-windows-x86_64.zip "${b}-windows-x86_64.zip"),$(asset verify:packages dist/SHA256SUMS "${b}-SHA256SUMS.txt")"
23# JSON-escaped already (\n, no double quotes inside).
24desc="Paperdoll Renderer ${version}.\n\n* Linux AppImage (portable).\n* Debian/Ubuntu .deb: /usr/bin/paperdoll-renderer, desktop entry, icons, .ppd MIME type.\n* Arch .pkg.tar.zst, built from packaging/arch/PKGBUILD. AUR: paperdoll-renderer-bin.\n* Windows zip (x86_64, MinGW build).\n* SHA256SUMS of the package files.\n\nThe default starter bodies are Animated walking Male Base Mesh and Animated Female Base Mesh by assetfactory (Sketchfab Standard licence); see THIRD_PARTY_NOTICES.md."
25body="$(printf '{"name":"Paperdoll Renderer %s","body":"%s","assets":[%s]}' "$tag" "$desc" "$assets")"
26
27echo "Release $tag on $CI_COMMIT_SHA (existing tag, create-only)"
28resp="$(mktemp)"
29code="$(curl -sS -o "$resp" -w '%{http_code}' -X POST \
30 "$CI_API_URL/repos/$CI_PROJECT_PATH/releases/$tag/assets" \
31 -H "Authorization: Bearer $CI_JOB_TOKEN" -H "Content-Type: application/json" -d "$body")" || code=000
32cat "$resp"; echo
33if [[ "$code" != 2* ]]; then
34 echo "release API returned HTTP $code (see response above)" >&2
35 exit 1
36fi