-
Notifications
You must be signed in to change notification settings - Fork 812
178 lines (166 loc) · 5.66 KB
/
Copy pathauto-release.yaml
File metadata and controls
178 lines (166 loc) · 5.66 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
name: 1.Release
# it is trigger by tag event:
# 1 build the release image, push images to ghcr.io, and build image like: ghcr.io/xxxx:v1.0.0
# 2 package the chart package, update index.yaml and commit to '/charts' of branch 'github_pages' ( PR with label pr/release/robot_update_githubpage )
# 3 create changelog file, commit to '/changelogs' of branch 'github_pages' for githubPage ( PR with label pr/release/robot_update_githubpage )
# 4 commit '/docs' to '/docs' of branch 'github_pages'
# 5 create a release , attached with the chart and changelog
on:
release:
types:
- prereleased
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:
inputs:
tag:
description: 'Tag'
required: true
default: v1.0.0
permissions: read-all
jobs:
pre-release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ env.RUN_TAG }}
steps:
- name: Check Version
run: |
TagVersion="${{ env.RUN_TAG }}"
RecordVersion=` cat VERSION | tr -d ' ' | tr -d '\n' `
if [ "$RecordVersion" != "$TagVersion" ] ; then
echo "error, version $RecordVersion of '/VERSION' is different with Tag $TagVersion "
exit 1
fi
#no need to check chart version, which will auto update to /VERSION by CI
# generate release notes for the new release branch
- name: Generate pre release notes
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: true
generate_release_notes: true
ensure-tag:
runs-on: ubuntu-latest
needs: pre-release
# creates the release-vX.Y branch
permissions:
contents: write
outputs:
tag: ${{ env.RUN_TAG }}
steps:
- name: Free disk space
# https://github.com/actions/virtual-environments/issues/709
run: |
echo "=========original CI disk space"
df -h
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "=========after clean up, the left CI disk space"
df -h
- name: Get Ref
id: get_ref
run: |
if ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "call by self workflow_dispatch"
echo "RUN_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
YBranchName=` grep -Eo "v[0-9]+\.[0-9]+" <<< "${{ github.event.inputs.tag }}" `
elif ${{ github.event_name == 'push' }} ; then
echo "call by push tag"
echo "RUN_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
YBranchName=` grep -Eo "v[0-9]+\.[0-9]+" <<< "${GITHUB_REF##*/}" `
else
echo "unexpected event: ${{ github.event_name }}"
exit 1
fi
echo "YBranchName=${YBranchName}"
if [ -n "$YBranchName" ] ; then
echo "RUN_YBranchName=${YBranchName}" >> $GITHUB_ENV
else
echo "error, failed to find y branch"
exit 1
fi
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ env.RUN_TAG }}
persist-credentials: false
# if branch exists, the action will no fail, and it output created=false
- name: release Y branch
uses: peterjgrainger/action-create-branch@4b81ce657e255acd677cc6c55c9c763654be3aef # v4.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: 'release-${{ env.RUN_YBranchName }}'
sha: '${{ github.sha }}'
release-image-hamicore:
needs: ensure-tag
# pushes to ghcr and signs with keyless cosign
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/call-release-image-hamicore.yaml
with:
ref: ${{ needs.ensure-tag.outputs.tag }}
secrets: inherit
release-image:
needs: [ensure-tag,release-image-hamicore]
# pushes to ghcr and signs with keyless cosign
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/call-release-image.yaml
with:
ref: ${{ needs.ensure-tag.outputs.tag }}
secrets: inherit
release-chart:
needs: [ensure-tag]
# pushes to github_pages with API_TOKEN_GITHUB, not GITHUB_TOKEN
permissions:
contents: read
uses: ./.github/workflows/call-release-helm.yaml
with:
ref: ${{ needs.ensure-tag.outputs.tag }}
submit: true
secrets: inherit
# generate changelog and update to github releases pages
release-notes:
needs: [ensure-tag,release-chart,release-image]
# updates the github release page
permissions:
contents: write
uses: ./.github/workflows/call-release-notes.yaml
with:
ref: ${{ needs.ensure-tag.outputs.tag }}
release-website:
needs: [ensure-tag,release-notes]
permissions:
contents: read
uses: ./.github/workflows/call-release-website.yaml
with:
ref: ${{ needs.ensure-tag.outputs.tag }}
# excute a full e2e test when hami release
release-e2e:
needs: [ensure-tag,release-notes]
permissions:
contents: read
uses: ./.github/workflows/call-e2e.yaml
with:
ref: ${{ needs.ensure-tag.outputs.tag }}
type: "release"
# excute a compatibility test when hami release
release-e2e-upgrade:
needs: [ensure-tag,release-notes]
permissions:
contents: read
uses: ./.github/workflows/call-e2e-upgrade.yaml
with:
ref: ${{ needs.ensure-tag.outputs.tag }}