forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprerelease.sh
More file actions
executable file
·100 lines (78 loc) · 2.47 KB
/
Copy pathprerelease.sh
File metadata and controls
executable file
·100 lines (78 loc) · 2.47 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -e # Exit immediately if a command exits with a non-zero status.
# load .env.local if present
if [ -f .env.local ]; then
set -a # automatically export all variables
source .env.local
set +a # stop automatically exporting
fi
# if GH_TOKEN is not set, quit
if [ -z "$GH_TOKEN" ]; then
printf "\e[41m\e[97m!!\e[0m Error: GH_TOKEN is not set\n"
exit 1
fi
# save the current branch
current_branch=$(git branch --show-current)
# quit if the current branch is main
if [ "$current_branch" = "main" ]; then
printf "\e[41m\e[97m!!\e[0m Error: Can't release pre release from main branch\n"
exit 1
fi
# quit if there are uncommitted changes
if [ -n "$(git status --porcelain)" ]; then
printf "\e[41m\e[97m!!\e[0m Error: There are uncommitted changes\n"
exit 1
fi
# replace underscores in current_branch with hyphens
package=$(echo $current_branch | sed 's/_/-/g')
# replace all non-alphanumeric characters except hyphens
package=$(echo $package | sed 's/[^a-zA-Z0-9-]/-/g')
# chop leading and trailing hyphens
package=$(echo $package | sed 's/^-//;s/-$//')
echo ""
echo "Branch: $current_branch"
echo "Package: $package"
echo ""
echo "==============================="
echo "!! Releasing new pre release !!"
echo "==============================="
echo ""
echo "Continue? (y/n)"
read -r response
if [ "$response" != "y" ]; then
printf "\e[41m\e[97m!!\e[0m Error: Aborted"
exit 1
fi
# enter pre mode
pnpm changeset pre enter $package
# select the packages to push an update for
pnpm changeset
# bump the version
pnpm changeset version
echo "Commit and run CI? (y/n)"
read -r response
if [ "$response" != "y" ]; then
printf "\e[41m\e[97m!!\e[0m Error: Aborted"
exit 1
fi
# Stage and commit
git add -A && git commit -m "Pre release $current_branch" && git push
# Sleep a little so that GitHub picks up the change
sleep 3
# Manually trigger the CI
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GH_TOKEN" \
-d "{\"ref\":\"$current_branch\"}" \
https://api.github.com/repos/CopilotKit/CopilotKit/actions/workflows/release.yml/dispatches
# get out of pre mode
echo "=================================================="
echo "!! Automatically exiting pre mode in 30 seconds !!"
echo "=================================================="
echo ""
# wait for 30 seconds
sleep 30
# get out of pre mode
pnpm changeset pre exit
# push the changes
git add -A && git commit -m "Pre release $current_branch - exit pre mode" && git push