-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathmanual-github-release.sh
More file actions
executable file
·62 lines (48 loc) · 1.43 KB
/
Copy pathmanual-github-release.sh
File metadata and controls
executable file
·62 lines (48 loc) · 1.43 KB
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
#!/usr/bin/env bash
#
# Manually perform a GitHub release for a broken automated release that otherwise went out.
#
# PLEASE USE WITH CAUTION.
#
# It can take a while to download all the artifacts.
#
# Requires the `gh` CLI.
set -euo pipefail
if [ -z "${COMMIT:-}" ]; then
echo "COMMIT is required."
exit 1
fi
if [ -z "${RUN_ID:-}" ]; then
echo "RUN_ID is required."
exit 1
fi
# Create directory for artifacts
mkdir -p "release_$RUN_ID"
cd "release_$RUN_ID"
REPO=$(gh repo view --json nameWithOwner | jq .nameWithOwner -r)
# Download all artifacts for the workflow run
gh run download "$RUN_ID" --repo "$REPO" --pattern 'artifacts-*'
MANIFEST="artifacts-dist-manifest/dist-manifest.json"
# Extract values from manifest
TAG=$(jq -r '.announcement_tag // .tag' "$MANIFEST")
TITLE=$(jq -r '.announcement_title' "$MANIFEST")
BODY=$(jq -r '.announcement_github_body' "$MANIFEST")
PRERELEASE=$(jq -r '.announcement_is_prerelease' "$MANIFEST")
# Write body to temp file
echo "$BODY" > /tmp/notes.txt
# Merge artifacts-* directories into artifacts/ (like CI does)
mkdir -p artifacts
cp -r artifacts-*/* artifacts/
# Remove the granular manifests (like CI does)
rm -f artifacts/*-dist-manifest.json
# Create release
release_args=(
"$TAG"
--target "$COMMIT"
--title "$TITLE"
--notes-file /tmp/notes.txt
)
if [ "$PRERELEASE" = "true" ]; then
release_args+=(--prerelease)
fi
gh release create "${release_args[@]}" artifacts/*