-
Notifications
You must be signed in to change notification settings - Fork 35
169 lines (159 loc) · 6.34 KB
/
release.yaml
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
---
name: Release
on:
push:
branches:
- "release/*"
jobs:
print-debug-info:
name: Print debug info for Release workflow
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v2
get-tag:
name: Tag
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag-step.outputs.tag }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Tag env
run: |
branch=${{ github.event.ref }}
echo '::set-output name=tag::'${branch#refs/heads/release/}
id: tag-step
check-images:
name: Check images
needs: get-tag
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Check images
run: |
git fetch origin
git checkout origin/release/${{ needs.get-tag.outputs.tag }}
pattern="ghcr\.io\/networkservicemesh\/ci\/.*:[a-z0-9]\{7\}"
grep -roh 'apps' -e ${pattern} || exit 0;
exit 1;
- name: Check that images are pullable
run: |
images=$(grep -roh 'apps' -e "ghcr\.io\/networkservicemesh\/.*:v.*..*..*")
for image in $images; do
echo pulling $image...
docker pull $image
done
replace-params:
name: Replacing release specific parameters
needs: [get-tag, check-images]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.ref }}
- name: Git config
run: |
git config --global user.email "nsmbot@networkservicmesh.io"
git config --global user.name "NSMBot"
- name: Replace logging level with INFO
run: |
sed -r -i '/name: NSM_LOG_LEVEL/{ n; s/value: .*/value: INFO/g }' `grep 'NSM_LOG_LEVEL' -rl *`
sed -r -i 's/NSM_LOG_LEVEL: .*/NSM_LOG_LEVEL: INFO/g' `grep 'NSM_LOG_LEVEL' -rl *`
sed -r -i 's/NSM_LOG_LEVEL=TRACE/NSM_LOG_LEVEL=INFO/g' `grep 'NSM_LOG_LEVEL' -rl *`
git add -- .
git commit -s -m "Replace logging level with INFO"
- name: Update references to the latest tag
run: |
sed -r -i '/github.com\/networkservicemesh\/deployments-k8s/ s/(\?ref=[a-z0-9.]*)/\?ref='"${{ needs.get-tag.outputs.tag }}"'/g' `grep '?ref=' -rl *`
sed -r -i '/raw.githubusercontent.com\/networkservicemesh\/deployments-k8s/ s/(deployments-k8s\/[a-z0-9.]*)/deployments-k8s\/'"${{ needs.get-tag.outputs.tag }}"'/g' `grep 'raw.githubusercontent.com' -rl *`
git add -- .
git commit -s -m "Update references to the latest tag"
ref=${{ github.event.ref }}
git push origin ${ref#refs/heads/}
create-release:
name: Create release
needs: [get-tag, replace-params]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{github.event.ref}}
- name: Push tag ${{ needs.get-tag.outputs.tag }}
run: |
git status
git tag ${{ needs.get-tag.outputs.tag }}
git push origin ${{ needs.get-tag.outputs.tag }} -f
- name: Create release ${{ needs.get-tag.outputs.tag }}
run: |
gh release create ${{ needs.get-tag.outputs.tag }} --title ${{ needs.get-tag.outputs.tag }} --target ${{github.event.workflow_run.head_branch}} --generate-notes
env:
GH_TOKEN: ${{ secrets.token }}
update-dependent-repositories:
strategy:
matrix:
repository:
- integration-tests
name: Update ${{ matrix.repository }}
needs: [get-tag, create-release]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
with:
go-version: 1.20.5
- name: Setup envs
run: |
echo GOPATH=$GITHUB_WORKSPACE >> $GITHUB_ENV
echo GO111MODULE=on >> $GITHUB_ENV
echo $GITHUB_WORKSPACE/bin >> $GITHUB_PATH
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v2
with:
path: ${{ github.workspace }}/src/github.com/${{ github.repository }}
repository: ${{ github.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
ref: release/${{ needs.get-tag.outputs.tag }}
- name: Install gotestmd
run: |
go install github.com/networkservicemesh/gotestmd@main
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
- name: Install goimports
run: |
go install golang.org/x/tools/cmd/goimports@latest
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
- uses: actions/setup-go@v1
with:
go-version: 1.20.5
- name: Checkout networkservicemesh/${{ matrix.repository }}
uses: actions/checkout@v2
with:
path: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
repository: networkservicemesh/${{ matrix.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- name: Update ${{ matrix.repository }} locally
working-directory: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
run: |
go generate ./...
go mod tidy
- uses: benjlevesque/short-sha@v1.2
id: short-sha
with:
length: 8
- name: Push update to the ${{ matrix.repository }}
working-directory: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
run: |
sed -r -i 's/sha = "[a-z0-9]*"/sha = "tags\/${{ needs.get-tag.outputs.tag }}"/g' extensions/base/suite.gen.go
git add -- .
echo Starting to update repositotry ${{ matrix.repository }}
if ! [ -n "$(git diff --cached --exit-code)" ]; then
echo ${{ matrix.repository }} is up to date
exit 0;
fi
git config --global user.email "nsmbot@networkservicmesh.io"
git config --global user.name "NSMBot"
echo "Update to ${{ github.repository }}@${{ needs.get-tag.outputs.tag }}" >> /tmp/commit-message
git commit -s -F /tmp/commit-message
git checkout -b release/${{ needs.get-tag.outputs.tag }}
git push -f origin release/${{ needs.get-tag.outputs.tag }}