forked from cloudevents/sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag-release.sh
executable file
·152 lines (133 loc) · 3.66 KB
/
tag-release.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
#!/usr/bin/env bash
# Copyright 2021 The CloudEvents Authors
# SPDX-License-Identifier: Apache-2.0
set -o errexit
set -o nounset
set -o pipefail
# This is run after the major release is published.
# Uncomment for manual runs.
# VERSION=v2.5.0
if [[ -z "$VERSION" ]]; then
echo "Must provide VERSION in environment" 1>&2
exit 1
fi
# TODO: we could do this dynamically in the future.
MODULES=(
"protocol/amqp"
"protocol/stan"
"protocol/nats"
"protocol/nats_jetstream"
"protocol/pubsub"
"protocol/kafka_sarama"
"protocol/ws"
"observability/opencensus"
"observability/opentelemetry"
"sql"
"binding/format/protobuf"
)
REPOINT=(
"github.com/cloudevents/sdk-go/v2"
)
# TODO: we could do this dynamically in the future.
REPOINT_SAMPLES=(
"github.com/cloudevents/sdk-go/protocol/amqp/v2"
"github.com/cloudevents/sdk-go/protocol/stan/v2"
"github.com/cloudevents/sdk-go/protocol/nats/v2"
"github.com/cloudevents/sdk-go/protocol/nats_jetstream/v2"
"github.com/cloudevents/sdk-go/protocol/pubsub/v2"
"github.com/cloudevents/sdk-go/protocol/kafka_sarama/v2"
"github.com/cloudevents/sdk-go/protocol/ws/v2"
"github.com/cloudevents/sdk-go/observability/opencensus/v2"
"github.com/cloudevents/sdk-go/observability/opentelemetry/v2"
"github.com/cloudevents/sdk-go/sql/v2"
"github.com/cloudevents/sdk-go/binding/format/protobuf/v2"
"github.com/cloudevents/sdk-go/v2" # NOTE: this needs to be last.
)
# Pick one:
REMOTE="origin" # if checked out directly
#REMOTE="upstream" # if checked out with a fork
# It is intended that this file is run locally. For a full release tag, confirm the version is correct, and then:
# ./hack/tag-release.sh --tag --push
# ------------------------------------------------------------------------------
# After this point it is script.
# ------------------------------------------------------------------------------
#
CREATE_TAGS=0 # default is a dry run
PUSH_TAGS=0 # Assumes `upstream` is the remote name for sdk-go.
SAMPLES=0
# Loop through arguments and process them
for arg in "$@"
do
case $arg in
-t|--tag)
CREATE_TAGS=1
shift
;;
-p|--push)
PUSH_TAGS=1
shift
;;
# --samples is used to repoint the dep used for samples to the newly released submodules
--samples)
SAMPLES=1
REPOINT=$REPOINT_SAMPLES
shift
;;
esac
done
echo --- All Modules ---
for gomodule in $(find . | grep "go\.mod" | awk '{gsub(/\/go.mod/,""); print $0}' | grep -v "./v2/test" | grep -v "./test")
do
echo " $gomodule"
if [[ $gomodule == "./v2" ]]
then
echo " skipping main module"
continue
fi
if [ "$SAMPLES" -eq "1" ]; then
if [[ $gomodule != "./samples"* ]]
then
echo " skipping non-sample module"
continue
fi
else
if [[ $gomodule == "./samples"* ]]
then
echo " skipping non-sample module"
continue
fi
fi
pushd $gomodule > /dev/null
for repoint in "${REPOINT[@]}"; do
if grep -Fq "$repoint" go.mod
then
tag="$VERSION"
echo " repointing dep on $repoint@$tag"
go get -d $repoint@$tag
go mod edit -dropreplace $repoint
fi
go mod tidy -compat=1.18
done
popd > /dev/null
done
if [ "$SAMPLES" -eq "1" ]; then
echo "Done."
exit 0
fi
echo --- Tagging ---
for i in "${MODULES[@]}"; do
tag=""
if [ "$i" = "" ]; then
tag="$VERSION"
else
tag="$i/$VERSION"
fi
if [ "$CREATE_TAGS" -eq "1" ]; then
echo " tagging with $tag"
git tag $tag
fi
if [ "$PUSH_TAGS" -eq "1" ]; then
echo " pushing $tag to $REMOTE"
git push $REMOTE $tag
fi
done