bots-garden/sidekickspublic Fork
⑂ v1.5.0
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/sidekicks.git
git clone ssh://git@rickub.com/bots-garden/sidekicks.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP
🛟 Updated. 8095158 · on v1.5.0 · k33g · 16d ago
local-ci-03-create-draft.sh · 84 lines · 3.4 KBBash Blame HistoryRaw
 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
#
# local-ci-03-create-draft.sh — the tag and a draft prerelease on Rickub.
#
# Refuses when the packages would not be what the tag names: the working tree
# must be clean and HEAD must be on the remote's main.
source "$(dirname "$0")/local-ci-00-common.sh"
load_token

[ -f "${assets_dir}/SHA256SUMS" ] || { echo "❌ no ${assets_dir}/SHA256SUMS: run local-ci-02-build.sh"; exit 2; }

head_sha="$(git rev-parse HEAD)"
if [ -z "${LOCAL_CI_SKIP_GIT_CHECK:-}" ]; then
	if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
		echo "❌ the working tree is not clean: commit first"
		git status --short --untracked-files=no
		exit 1
	fi
	remote_main="$(git ls-remote "${git_url}" refs/heads/main | cut -f1)"
	if [ "${head_sha}" != "${remote_main}" ]; then
		echo "❌ HEAD (${head_sha}) is not the remote's main (${remote_main}): push first"
		exit 1
	fi
fi

# With the old workflow on that commit, a v* tag would also start a CI release.
case "${TAG}" in
	v*)
		if [ -n "$(git ls-tree "${head_sha}" .github/workflows)" ]; then
			echo "❌ ${head_sha} still has .github/workflows: a tag there would start the old Release workflow. Push the commit that renames it."
			exit 1
		fi
		;;
esac

# The notes have the shape of the ones the old workflow published: version,
# commit, install guides, what is new, then a table of the files.
version="$(scripts/package.sh version)"
base="https://rickub.com/${OWNER}/${REPO}"
whats_new="docs/release-notes/v${version}.md"
{
	printf '## Sidekicks %s\n\n' "${version}"
	[ -z "${ABOUT:-}" ] || printf '%s\n\n' "${ABOUT}"
	printf 'Commit `%s`. Built on a local machine with %s.\n' "${head_sha}" "$(go env GOVERSION)"
	if [ -f "${assets_dir}/macos-signature.txt" ]; then
		printf 'The macOS packages are signed with a Developer ID and notarized by Apple.\n'
	fi
	printf '\nInstall: [English](%s/blob/main/docs/en/how-to/install-sidekicks.md) · [Français](%s/blob/main/docs/fr/how-to/installer-sidekicks.md)\n\n' "${base}" "${base}"
	if [ -f "${whats_new}" ]; then
		tail -n +2 "${whats_new}"
		printf '\n'
	fi
	printf '| File | System |\n| --- | --- |\n'
	while read -r _ name; do
		case "${name}" in
			*macos-arm64*) system="macOS 13 or later, Apple Silicon" ;;
			*windows?amd64*) system="Windows x86-64" ;;
			*windows?arm64*) system="Windows on Arm" ;;
			*) system="" ;;
		esac
		printf '| `%s` | %s |\n' "${name}" "${system}"
	done <"${assets_dir}/SHA256SUMS"
	printf '| `SHA256SUMS` | checksums: `shasum -a 256 -c SHA256SUMS` (macOS), `Get-FileHash` (Windows) |\n'
	printf '\n## Checksums\n\n```\n'
	cat "${assets_dir}/SHA256SUMS"
	printf '```\n'
} >"${work}/notes.md"

# LOCAL_CI_PRINT_NOTES=1 shows the notes and stops: nothing is created.
if [ -n "${LOCAL_CI_PRINT_NOTES:-}" ]; then
	cat "${work}/notes.md"
	exit 0
fi

echo "==> creating the draft prerelease ${TAG} on ${head_sha}"
payload="$(jq -n --arg tag "${TAG}" --arg name "Sidekicks ${TAG}" --arg target "${head_sha}" --rawfile body "${work}/notes.md" \
	'{tag: $tag, title: $name, target: $target, body: $body, prerelease: true, draft: true}')"
status="$(call POST /releases -H 'Content-Type: application/json' -d "${payload}")"
case "${status}" in
	201) echo "✅ draft ${TAG} created" ;;
	409) echo "❌ the release ${TAG} already exists"; exit 1 ;;
	*) echo "❌ HTTP ${status}: $(cat "${work}/body")"; exit 1 ;;
esac