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() { jq -n --arg j "$1" --arg p "$2" --arg n "$3" '{job:$j,path:$p,name:$n}'; }
22assets="$(jq -s . \
23 <(asset package:appimage dist/paperdoll-renderer-x86_64.AppImage "${b}-x86_64.AppImage") \
24 <(asset package:ubuntu dist/paperdoll-renderer_amd64.deb "${b}-amd64.deb") \
25 <(asset package:arch dist/paperdoll-renderer-x86_64.pkg.tar.zst "${b}-x86_64.pkg.tar.zst") \
26 <(asset package:windows dist/paperdoll-renderer-windows-x86_64.zip "${b}-windows-x86_64.zip") \
27 <(asset verify:packages dist/SHA256SUMS "${b}-SHA256SUMS.txt"))"
28desc="Paperdoll Renderer ${version}.
29
30* Linux AppImage (portable).
31* Debian/Ubuntu .deb: /usr/bin/paperdoll-renderer, desktop entry, icons, .ppd MIME type.
32* Arch .pkg.tar.zst, built from packaging/arch/PKGBUILD. AUR: paperdoll-renderer-bin.
33* Windows zip (x86_64, MinGW build).
34* SHA256SUMS of the package files.
35
36The default starter bodies are \"Animated walking Male Base Mesh\" and \"Animated Female Base Mesh\" by assetfactory (Sketchfab Standard licence); see THIRD_PARTY_NOTICES.md."
37body="$(jq -n --arg n "Paperdoll Renderer ${tag}" --arg b "$desc" --argjson a "$assets" '{name:$n,body:$b,assets:$a}')"
38
39echo "Release $tag on $CI_COMMIT_SHA (existing tag, create-only)"
40resp="$(mktemp)"
41code="$(curl -sS -o "$resp" -w '%{http_code}' -X POST \
42 "$CI_API_URL/repos/$CI_PROJECT_PATH/releases/$tag/assets" \
43 -H "Authorization: Bearer $CI_JOB_TOKEN" -H "Content-Type: application/json" -d "$body")" || code=000
44cat "$resp"; echo
45if [[ "$code" != 2* ]]; then
46 echo "release API returned HTTP $code (see response above)" >&2
47 exit 1
48fi