forked from temporalio/temporal
-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (186 loc) · 7.4 KB
/
create-tag.yml
File metadata and controls
213 lines (186 loc) · 7.4 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
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
name: "Create a tag"
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to be tagged"
required: true
tag:
description: "Tag for new version (1.23.4)"
required: true
skip_deps_check:
type: boolean
description: "Skip dependencies version check (you can skip only when creating non-release tags)"
default: false
release_notes:
type: boolean
description: "Create draft release notes"
default: false
base_tag:
description: "Base tag to generate commit list for release notes"
required: false
update_deps:
type: boolean
description: "Create PR updating dependencies post-release"
default: false
jobs:
create-tag:
name: "Create a tag"
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: true
token: ${{ steps.generate_token.outputs.token }}
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0
fetch-tags: true
- name: Set up Github credentials
run: |
git config --local user.name 'Temporal Data'
git config --local user.email 'commander-data@temporal.io'
- name: Get current version
id: get_current_version
run: |
CURRENT_VERSION=$(grep '^\s*ServerVersion = ".*"$' common/headers/version_checker.go | sed 's/^.*"\(.*\)"$/\1/')
[ -z "$CURRENT_VERSION" ] && exit 1
echo "CURRENT_VERSION=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
- name: Prepare new version string
id: new_version
env:
TAG: '${{ github.event.inputs.tag }}'
run: |
if [[ "${TAG}" =~ ^v.* ]]; then
echo "tag_with_v=${TAG}" >> "$GITHUB_OUTPUT"
echo "tag_no_v=${TAG#v}" >> "$GITHUB_OUTPUT"
else
echo "tag_with_v=v${TAG}" >> "$GITHUB_OUTPUT"
echo "tag_no_v=${TAG}" >> "$GITHUB_OUTPUT"
fi
- name: Validate API and SDK dependencies
env:
SKIP_CHECK: ${{ github.event.inputs.skip_deps_check }}
TAG: ${{ steps.new_version.outputs.tag_with_v }}
run: |
SEMVER_RE='^v[0-9]+\.[0-9]+\.[0-9]+$'
if [[ "$SKIP_CHECK" == "true" ]]; then
if [[ ! "$TAG" =~ $SEMVER_RE ]]; then
echo "::notice::Skipping dependencies check"
exit 0
fi
echo "::warning::Cannot skip dependencies check when creating a potential release tag $TAG"
fi
MODULES=( "go.temporal.io/api" "go.temporal.io/sdk" )
for module in "${MODULES[@]}"; do
version=$(go list -f '{{.Version}}' -m "$module")
if [[ ! "$version" =~ $SEMVER_RE ]]; then
echo "::error::Using non-tagged version of module $module with version $version"
exit 1
fi
replace=$(go list -f '{{.Replace}}' -m "$module")
if [[ "$replace" != "<nil>" ]]; then
echo "::error::Module $module is replaced with $replace"
exit 1
fi
done
- name: Update Server version
if: ${{ steps.get_current_version.outputs.CURRENT_VERSION != github.event.inputs.tag }}
env:
TAG: ${{ steps.new_version.outputs.tag_no_v }}
BRANCH: ${{ github.event.inputs.branch }}
run: |
sed -i -e "s/ServerVersion = \".*\"$/ServerVersion = \"$TAG\"/g" common/headers/version_checker.go
git add .
git commit -m "Bump Server version to $TAG"
git push origin "$BRANCH"
- name: Create and push tag
env:
TAG: ${{ steps.new_version.outputs.tag_with_v }}
BRANCH: ${{ github.event.inputs.branch }}
run: |
if [ -z "$(git tag -l "$TAG")" ]; then
git tag "$TAG"
git push origin "$TAG"
elif [ "$(git rev-list -n 1 "$TAG")" != "$(git rev-parse HEAD)" ]; then
echo "::error::Tag already exists and it doesn't reference current HEAD of branch $BRANCH"
exit 1
fi
- name: Create draft release notes
if: ${{ github.event.inputs.release_notes == 'true' }}
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
BASE_TAG: ${{ github.event.inputs.base_tag }}
TAG: ${{ steps.new_version.outputs.tag_with_v }}
run: |
if [ -z "$BASE_TAG" ] || [ -z "$(git tag -l "$BASE_TAG")" ]; then
echo "::error::Base tag not specified or does not exist"
exit 1
fi
TEMPFILE=$(mktemp)
cat > "$TEMPFILE" <<- EOF
## Breaking Changes
Document them here, if any
## Deprecation Announcements
Document them here, if any.
## Release Highlights
Add highlights if any.
### Helpful links to get you started with Temporal
[Temporal Docs](https://docs.temporal.io/)
[Server](https://github.com/temporalio/temporal)
[Docker Compose](https://github.com/temporalio/docker-compose)
[Helm Chart](https://github.com/temporalio/helm-charts)
### Docker images for this release (use the tag \`${TAG#v}\`)
[Server](https://hub.docker.com/r/temporalio/server)
[Server With Auto Setup](https://hub.docker.com/r/temporalio/auto-setup) ([what is Auto-Setup?](https://docs.temporal.io/blog/auto-setup))
[Admin-Tools](https://hub.docker.com/r/temporalio/admin-tools)
**Full Changelog**: https://github.com/temporalio/temporal/compare/${BASE_TAG}...${TAG}
EOF
gh repo set-default ${{ github.repository }}
gh release create "$TAG" --verify-tag --draft --title "$TAG" -F "$TEMPFILE"
update-deps:
name: "Update dependencies in main branch"
runs-on: ubuntu-latest
needs: [create-tag]
if: ${{ github.event.inputs.update_deps == 'true' }}
defaults:
run:
shell: bash
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: true
token: ${{ steps.generate_token.outputs.token }}
ref: main
- name: Set up Github credentials
run: |
git config --local user.name 'Temporal Data'
git config --local user.email 'commander-data@temporal.io'
- name: Create PR updating dependencies
run: |
make update-dependencies
make go-generate
BRANCH="temporal-data/update-dependencies-$(git rev-parse --short HEAD)"
git checkout -b "${BRANCH}"
git add .
git commit -m "Update dependencies" --author ${{ github.actor }}
git push origin "${BRANCH}"
gh pr create --fill --reviewer ${{ github.actor }},${{ github.triggering_actor }}