1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/usr/bin/env bash
# Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
#
# local-ci-00-common.sh — what the local-ci-*.sh steps share. Sourced, not run.
#
# The steps, in order:
# ./local-ci-01-check.sh gofmt, vet, tests
# ./local-ci-02-build.sh the packages, in release/<TAG>/ (scripts/build-release.sh);
# signs and notarizes the macOS app and the dmg
# when SIGN_IDENTITY is set (docs/en/how-to/sign-and-notarize-on-macos.md)
# ./local-ci-03-create-draft.sh the tag and a draft prerelease
# ./local-ci-04-upload.sh the packages, through a temporary branch
# ./local-ci-05-publish.sh the draft becomes public; asks first
# ./local-ci-06-promote.sh optional: the prerelease becomes a release; asks first
#
# Reads TAG, ABOUT, OWNER, REPO, SIGN_IDENTITY and NOTARY_PROFILE from
# .release.env, and CI_TOKEN from
# .ci.cd.token.env. The token never reaches argv: curl and git read it from
# files of mode 600 in a temporary folder.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
# shellcheck disable=SC1090
source "${LOCAL_CI_ENV_FILE:-./.release.env}"
: "${TAG:?TAG is not set in .release.env}"
OWNER="${OWNER:-bots-garden}"
REPO="${REPO:-sidekicks}"
handle="${RICKUB_HANDLE:-k33g}"
web="https://rickub.com/${OWNER}/${REPO}"
api="https://rickub.com/api/v1/repos/${OWNER}/${REPO}"
git_url="https://${handle}@git.rickub.com/${OWNER}/${REPO}.git"
assets_dir="release/${TAG}"
work="$(mktemp -d)"
cleanup_work() { rm -rf "${work}"; }
trap cleanup_work EXIT
# load_token prepares the token for curl and git.
load_token() {
# shellcheck disable=SC1091
source ./.ci.cd.token.env
[ -n "${CI_TOKEN:-}" ] || { echo "❌ CI_TOKEN is not set in .ci.cd.token.env"; exit 2; }
export CI_TOKEN
( umask 077; printf 'header = "Authorization: Bearer %s"\n' "${CI_TOKEN}" > "${work}/curl.conf" )
( umask 077; printf '#!/bin/sh\nprintf "%%s" "$CI_TOKEN"\n' > "${work}/askpass.sh" )
chmod 700 "${work}/askpass.sh"
export GIT_ASKPASS="${work}/askpass.sh" GIT_TERMINAL_PROMPT=0
}
# call METHOD PATH [curl args]: the body lands in ${work}/body, the status is printed.
call() {
local method="$1" path="$2"
shift 2
curl -sS -m 60 -o "${work}/body" -w '%{http_code}' -K "${work}/curl.conf" -X "${method}" "$@" "${api}${path}"
}
# release_field FIELD prints a field of the release of TAG, or nothing.
release_field() {
local status
status="$(call GET /releases)"
[ "${status}" = "200" ] || { echo "❌ HTTP ${status} listing the releases: $(cat "${work}/body")" >&2; exit 1; }
# Not `// empty`: jq's // also drops false, and "draft": false would read as nothing.
jq -r --arg tag "${TAG}" --arg field "$1" '[.[] | select(.tag == $tag)][0][$field] | if . == null then empty else tostring end' "${work}/body"
}
# latest_location prints where /releases/latest redirects to.
latest_location() {
curl -sI -m 20 "${web}/releases/latest" | tr -d '\r' | awk 'tolower($1) == "location:" {print $2}'
}
|