forked from knative/eventing
-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (142 loc) · 6.41 KB
/
knative-releasability.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
# Copyright 2020 The Knative Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is automagically synced here from github.com/knative-sandbox/.github
# repo by knobots: https://github.com/knative-sandbox/knobots and will be overwritten.
name: 'Releasability'
on:
schedule:
- cron: '0 1 * * 1-5' # 6am Pacific, weekdays.
workflow_dispatch: # Manual trigger.
inputs:
releaseFamily:
description: 'Release? (vX.Y)'
moduleReleaseFamily:
description: 'Module Release? (vX.Y)'
slackChannel:
description: 'Slack Channel? (release-#)'
jobs:
releasability:
name: Releasability
runs-on: 'ubuntu-latest'
env:
#########################################
# Update this section each release. #
RELEASE: 'v1.2'
MODULE_RELEASE: 'v0.29'
SLACK_CHANNEL: 'release-1dot2'
#########################################
steps:
- name: Defaults
run: |
# If manual trigger sent releaseFamily, moduleReleaseFamily and slackChannel, then override them
if [[ "${{ github.event.inputs.releaseFamily }}" != "" ]]; then
echo "RELEASE=${{ github.event.inputs.releaseFamily }}" >> $GITHUB_ENV
fi
if [[ "${{ github.event.inputs.moduleReleaseFamily }}" != "" ]]; then
echo "MODULE_RELEASE=${{ github.event.inputs.moduleReleaseFamily }}" >> $GITHUB_ENV
fi
if [[ "${{ github.event.inputs.slackChannel }}" != "" ]]; then
echo "SLACK_CHANNEL=${{ github.event.inputs.slackChannel }}" >> $GITHUB_ENV
fi
if [[ "${{ secrets.SLACK_WEBHOOK }}" != "" ]]; then
echo "SLACK_WEBHOOK=exists" >> $GITHUB_ENV
fi
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Install Dependencies
run: go install knative.dev/test-infra/buoy@main
- name: Check out code
uses: actions/checkout@v2
- name: Exists
id: exists
run: |
EXISTS=0
buoy exists go.mod --release ${RELEASE} --module-release ${MODULE_RELEASE} --verbose || EXISTS=$?
if [[ "$EXISTS" -eq "0" ]]; then
EXISTS=true
else
EXISTS=false
fi
echo ::set-output name=release-branch::${EXISTS}
- name: Check
if: steps.exists.outputs.release-branch == 'false'
run: |
# The following pushes the stdout of buoy into $CHECK_MESSAGE
CHECK=0
echo 'CHECK_MESSAGE<<EOF' >> $GITHUB_ENV
buoy check go.mod --release ${RELEASE} --module-release ${MODULE_RELEASE} --domain knative.dev --verbose >> $GITHUB_ENV 2>&1 || CHECK=$?
echo 'EOF' >> $GITHUB_ENV
# We just captured the return code of the buoy call, test it to see
# if we should continue validating. The next steps short circuit if
# we already know we are not ready for a release.
if [[ "$CHECK" -eq "0" ]]; then
echo 'current=true' >> $GITHUB_ENV
else
echo 'current=false' >> $GITHUB_ENV
fi
- name: Upgrade
if: steps.exists.outputs.release-branch == 'false' && env.current == 'true'
run: |
# if update deps returns un-successful, then mark current to false.
if ! ./hack/update-deps.sh --release ${RELEASE} --module-release ${MODULE_RELEASE} --upgrade; then
echo "VERIFY_MESSAGE=Unable to update deps for ${{ github.repository }}." >> $GITHUB_ENV
echo 'current=false' >> $GITHUB_ENV
fi
- name: Verify
if: steps.exists.outputs.release-branch == 'false' && env.current == 'true'
run: |
# If we don't run `git status` before the "git diff-index" it seems
# to list every file that's been touched by codegen.
git status
CHANGED="$(git diff-index --name-only HEAD --)"
# If we see no changes after the upgrade, then we are up to date.
if [[ "$CHANGED" == "" ]]; then
echo "VERIFY_MESSAGE=${{ github.repository }} up to date." >> $GITHUB_ENV
else
echo "VERIFY_MESSAGE=${{ github.repository }} is out of date." >> $GITHUB_ENV
echo "The following files are changed: $CHANGED"
echo 'current=false' >> $GITHUB_ENV
fi
- name: Status GO
if: steps.exists.outputs.release-branch == 'false' && env.current == 'true'
run: |
echo 'SLACK_COLOR=#098e00' >> $GITHUB_ENV
echo 'SLACK_TITLE=Releasability for ${{ github.repository }} @ ${{ env.RELEASE }} is GO!' >> $GITHUB_ENV
- name: Status NO-GO
if: steps.exists.outputs.release-branch == 'false' && env.current == 'false'
run: |
echo 'SLACK_COLOR=#8E1600' >> $GITHUB_ENV
echo 'SLACK_TITLE=Releasability for ${{ github.repository }} @ ${{ env.RELEASE }} is NO-GO!' >> $GITHUB_ENV
- name: Post status to Slack
# Note: using env.SLACK_WEBHOOK here because secrets are not allowed in the if block.
if: env.SLACK_WEBHOOK != '' && steps.exists.outputs.release-branch == 'false'
uses: rtCamp/action-slack-notify@v2.1.0
env:
SLACK_ICON: http://github.com/knative.png?size=48
SLACK_USERNAME: github-actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: 'true'
SLACK_MESSAGE: |
${{ env.CHECK_MESSAGE }}
${{ env.VERIFY_MESSAGE }}
For detailed logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Fail if NO-GO
if: steps.exists.outputs.release-branch == 'false' && env.current == 'false'
run: |
# When we have figured out that things are NO-GO, we intentionally fail the job
# so that the status badge shows up red and we can use the badges to create a
# releasability dashboard for all of the repos.
exit 1