forked from nrfconnect/sdk-nrf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtag_west_repos.sh
executable file
·218 lines (171 loc) · 5.08 KB
/
tag_west_repos.sh
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash
# ----------------------------------------------------------------------
# Helper script for creating and pushing release tags in west.yml
# repositories.
#
# IMPORTANT:
#
# ONLY USE THIS IF YOU ARE AUTHORIZED TO MAKE SIGNED RELEASE TAGS.
# Contact the NCS release team if you need more information.
#
# To use:
#
# 1. Fill in the PROJECT_TAGS data below.
#
# 2. Go to your nrf repository clone, and update your workspace
# to match the manifest you want to tag:
#
# cd ~/ncs/nrf
# git checkout $SDK_NRF_REVISION_YOU_WANT
# west update
#
# 3. Create tags matching PROJECT_TAGS:
#
# ./scripts/tag_west_repos.sh tag-all
#
# 4. Push those tags to GitHub:
#
# ./scripts/tag_west_repos.sh push-all
#
# If you make a mistake and want to delete your local tags before
# pushing them and starting over, run 'tag_west_repos.sh remove-all'.
# ----------------------------------------------------------------------
# Configure the tags by editing this section.
declare -A PROJECT_TAGS
# Set the tag names for all the projects below.
#
# - keys are project names in west.yml
# - values are the tags you want to make
#
# nrfx/nRF/srcx repositories: vX.Y.Z(-rcN)
PROJECT_TAGS[nrfxlib]=""
PROJECT_TAGS[find-my]=""
PROJECT_TAGS[homekit]=""
PROJECT_TAGS[matter]=""
PROJECT_TAGS[nrf-802154]=""
# OSS repositories: vX.Y.Z-ncsN(-I)(-rcM)
PROJECT_TAGS[zephyr]=""
PROJECT_TAGS[mcuboot]=""
PROJECT_TAGS[trusted-firmware-m]=""
PROJECT_TAGS[mbedtls]=""
# ----------------------------------------------------------------------
# Everything below this line is implementation details.
SCRIPT=$(basename "$0")
hline() {
# Helper function for printing a horizontal line
printf '%*s\n' "$(tput cols)" '' | tr ' ' -
}
tag() {
# Synopsis:
#
# tag <project-name> <tag-name>
#
# Create a tag named <tag-name> in the west.yml project named
# <project-name>, at the current manifest-rev.
#
# The tag message is '<repository-path> <tag-name>', where
# <repository-path> is something like 'sdk-foo' for project 'foo'.
project="$1"
tagname="$2"
if [ -z "$project" ] || [ -z "$tagname" ]; then
echo "empty project or tagname" 1>&2
return
fi
hline
sha=$(west list -f '{sha}' "$project")
remote_basename=$(west list -f '{url}' "$project" | xargs basename)
local_path=$(west list -f '{abspath}' "$project")
message="$remote_basename $tagname"
echo "$project": creating tag "$tagname" for "$sha" in "$local_path"
git -C "$local_path" tag -s -a -m "$message" "$tagname" "$sha" || exit 1
echo "$project": verifying tag
git -C "$local_path" tag -v "$tagname" || exit 1
}
push_tag() {
# Synopsis:
#
# push_tag <project-name> <tag-name>
#
# Push the tag named <tag-name> into the remote URL
# for the west.yml project named <project-name>.
project="$1"
tagname="$2"
if [ -z "$project" ] || [ -z "$tagname" ]; then
echo "empty project or tagname" 1>&2
return
fi
hline
local_path=$(west list -f '{abspath}' "$project")
url=$(west list -f '{url}' "$project")
echo "$project": pushing tag "$tagname" to "$url"
git -C "$local_path" push "$url" "$tagname"
echo "$project": pushed tag "$url/releases/tag/$tagname"
}
remove_tag() {
# Synopsis:
#
# remove_tag <project-name> <tag-name>
#
# Locally delete the tag named <tag-name> in the
# west.yml project named <project-name>
project="$1"
tagname="$2"
if [ -z "$project" ] || [ -z "$tagname" ]; then
echo "empty project or tagname" 1>&2
return
fi
hline
local_path=$(west list -f '{abspath}' "$project")
echo "$project": removing tag "$tagname" in "$local_path"
git -C "$local_path" tag -d "$tagname"
}
check_tags() {
for project in "${!PROJECT_TAGS[@]}"; do
if [ -z "${PROJECT_TAGS[$project]}" ]; then
echo "error: empty tag name" 1>&2
exit 1
fi
done
}
tag_all() {
# Creates all the tags in the PROJECT_TAGS array.
for project in "${!PROJECT_TAGS[@]}"; do
tag "$project" "${PROJECT_TAGS[$project]}"
done
}
push_all() {
# Pushes all the tags in the PROJECT_TAGS array
# to the main nrfconnect repositories on GitHub.
for project in "${!PROJECT_TAGS[@]}"; do
push_tag "$project" "${PROJECT_TAGS[$project]}"
done
}
remove_all() {
# Removes all the tags in the PROJECT_TAGS array.
for project in "${!PROJECT_TAGS[@]}"; do
remove_tag "$project" "${PROJECT_TAGS[$project]}"
done
}
command="$1"
shift
check_tags
case "$command" in
tag-all)
# Create tags in all the repositories in the local working trees.
# Verify the GPG signatures on each tag. Failed verification is a fatal error.
tag_all
;;
remove-all)
# Remove any tags created by 'tag-all' from local repositories (for debugging)
remove_all
;;
push-all)
# Push tags created by 'tag-all' to the remote.
push_all
;;
*)
echo unknown or missing command
echo example: \'"$SCRIPT" tag-all\'
echo all commands: tag-all remove-all push-all
;;
esac