Skip to content

Commit 0620e76

Browse files
authored
Merge pull request #8 from wawa0210/release-process
add hami release process
2 parents 80ad96d + 4c048c1 commit 0620e76

18 files changed

+668
-69
lines changed

.github/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# .github/release.yml
2+
changelog:
3+
exclude:
4+
labels:
5+
- ignore-for-release
6+
categories:
7+
- title: ✨ New Features
8+
labels:
9+
- enhancement
10+
- title: 🐛 Bug Fixes
11+
labels:
12+
- bug
13+
- title: 📚 Documentation
14+
labels:
15+
- documentation
16+
- title: ⬆️ Dependencies
17+
labels:
18+
- dependencies
19+
- title: 💥 Breaking Changes
20+
labels:
21+
- breaking-change
22+
- title: 🔨 Other Changes
23+
labels:
24+
- "*"

.github/workflows/auto-release.yaml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: 1.Release
2+
3+
# it is trigger by tag event:
4+
# 1 build the release image, push images to ghcr.io, and build image like: ghcr.io/xxxx:v1.0.0
5+
# 2 package the chart package, update index.yaml and commit to '/charts' of branch 'github_pages' ( PR with label pr/release/robot_update_githubpage )
6+
# 3 create changelog file, commit to '/changelogs' of branch 'github_pages' for githubPage ( PR with label pr/release/robot_update_githubpage )
7+
# 4 commit '/docs' to '/docs' of branch 'github_pages'
8+
# 5 create a release , attached with the chart and changelog
9+
10+
on:
11+
release:
12+
types:
13+
- prereleased
14+
push:
15+
tags:
16+
- v[0-9]+.[0-9]+.[0-9]+
17+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
18+
workflow_dispatch:
19+
inputs:
20+
tag:
21+
description: 'Tag'
22+
required: true
23+
default: v1.0.0
24+
permissions: write-all
25+
26+
jobs:
27+
pre-release:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: write
31+
outputs:
32+
tag: ${{ env.RUN_TAG }}
33+
steps:
34+
- name: Check Version
35+
run: |
36+
TagVersion="${{ env.RUN_TAG }}"
37+
RecordVersion=` cat VERSION | tr -d ' ' | tr -d '\n' `
38+
if [ "$RecordVersion" != "$TagVersion" ] ; then
39+
echo "error, version $RecordVersion of '/VERSION' is different with Tag $TagVersion "
40+
exit 1
41+
fi
42+
#no need to check chart version, which will auto update to /VERSION by CI
43+
# generate release notes for the new release branch
44+
- name: Generate pre release notes
45+
if: startsWith(github.ref, 'refs/tags/')
46+
uses: softprops/action-gh-release@v2
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
with:
50+
prerelease: true
51+
generate_release_notes: true
52+
53+
ensure-tag:
54+
runs-on: ubuntu-latest
55+
needs: pre-release
56+
outputs:
57+
tag: ${{ env.RUN_TAG }}
58+
steps:
59+
- name: Free disk space
60+
# https://github.com/actions/virtual-environments/issues/709
61+
run: |
62+
echo "=========original CI disk space"
63+
df -h
64+
sudo rm -rf "/usr/local/share/boost"
65+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
66+
echo "=========after clean up, the left CI disk space"
67+
df -h
68+
- name: Get Ref
69+
id: get_ref
70+
run: |
71+
if ${{ github.event_name == 'workflow_dispatch' }} ; then
72+
echo "call by self workflow_dispatch"
73+
echo "RUN_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
74+
YBranchName=` grep -Eo "v[0-9]+\.[0-9]+" <<< "${{ github.event.inputs.tag }}" `
75+
elif ${{ github.event_name == 'push' }} ; then
76+
echo "call by push tag"
77+
echo "RUN_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
78+
YBranchName=` grep -Eo "v[0-9]+\.[0-9]+" <<< "${GITHUB_REF##*/}" `
79+
else
80+
echo "unexpected event: ${{ github.event_name }}"
81+
exit 1
82+
fi
83+
echo "YBranchName=${YBranchName}"
84+
if [ -n "$YBranchName" ] ; then
85+
echo "RUN_YBranchName=${YBranchName}" >> $GITHUB_ENV
86+
else
87+
echo "error, failed to find y branch"
88+
exit 1
89+
fi
90+
- name: Checkout
91+
uses: actions/checkout@v4
92+
with:
93+
ref: ${{ env.RUN_TAG }}
94+
# if branch exists, the action will no fail, and it output created=false
95+
- name: release Y branch
96+
uses: peterjgrainger/action-create-branch@v3.0.0
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
with:
100+
branch: 'release-${{ env.RUN_YBranchName }}'
101+
sha: '${{ github.sha }}'
102+
103+
104+
release-image:
105+
needs: ensure-tag
106+
uses: ./.github/workflows/call-release-image.yaml
107+
with:
108+
ref: ${{ needs.ensure-tag.outputs.tag }}
109+
secrets: inherit
110+
111+
release-chart:
112+
needs: [ensure-tag]
113+
uses: ./.github/workflows/call-release-helm.yaml
114+
with:
115+
ref: ${{ needs.ensure-tag.outputs.tag }}
116+
submit: true
117+
secrets: inherit
118+
119+
# generate changelog and update to github releases pages
120+
release-notes:
121+
needs: [release-chart,release-image]
122+
uses: ./.github/workflows/call-release-notes.yaml
123+
with:
124+
ref: ${{ needs.ensure-tag.outputs.tag }}
125+
126+
release-website:
127+
needs: [release-notes]
128+
uses: ./.github/workflows/call-release-website.yaml
129+
with:
130+
ref: ${{ needs.ensure-tag.outputs.tag }}
131+
# excute a full e2e test when hami release
132+
release-e2e:
133+
needs: [release-notes]
134+
uses: ./.github/workflows/call-e2e.yaml
135+
with:
136+
ref: ${{ needs.ensure-tag.outputs.tag }}
137+
138+
# excute a compatibility test when hami release
139+
release-e2e-upgrade:
140+
needs: [release-notes]
141+
uses: ./.github/workflows/call-e2e-upgrade.yaml
142+
with:
143+
ref: ${{ needs.ensure-tag.outputs.tag }}
144+

.github/workflows/build-helm-release.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Call e2e upgrade test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
required: true
8+
type: string
9+
permissions: write-all
10+
11+
jobs:
12+
upgrade-e2e:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: e2e upgrade test
16+
# https://github.com/actions/virtual-environments/issues/709
17+
run: |
18+
echo "Need to add e2e upgrade test"

.github/workflows/call-e2e.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Call e2e test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
required: true
8+
type: string
9+
permissions: write-all
10+
11+
jobs:
12+
e2e:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: e2e test
16+
# https://github.com/actions/virtual-environments/issues/709
17+
run: |
18+
echo "Need to add e2e test"
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Call Release Helm Charts
2+
3+
# must set branch 'github_pages' as github page
4+
# this workflow will create the tgz from "/charts/*" of branch main,
5+
# and deploy to "/charts" of branch "github_pages"
6+
# and on branch "github_pages", update '/index.yaml' for '/charts/*.tgz'
7+
8+
env:
9+
HELM_VERSION: v3.8.1
10+
MERGE_BRANCH: gh-pages
11+
on:
12+
workflow_call:
13+
inputs:
14+
ref:
15+
required: true
16+
type: string
17+
submit:
18+
required: true
19+
type: string
20+
outputs:
21+
artifact:
22+
description: "name of artifact"
23+
value: chart_package_artifact
24+
workflow_dispatch:
25+
inputs:
26+
ref:
27+
description: 'tag, sha, branch'
28+
required: true
29+
default: v1.0.0
30+
31+
permissions: write-all
32+
33+
jobs:
34+
get_ref:
35+
runs-on: ubuntu-latest
36+
outputs:
37+
ref: ${{ env.REF }}
38+
submit: ${{ env.SUBMIT }}
39+
steps:
40+
- name: Get Original Ref
41+
id: get_original_ref
42+
run: |
43+
if ${{ inputs.ref != '' }} ; then
44+
echo "call by workflow_call"
45+
echo "REF=${{ inputs.ref }}" >> $GITHUB_ENV
46+
echo "SUBMIT=${{ inputs.submit }}" >> $GITHUB_ENV
47+
elif ${{ github.event_name == 'workflow_dispatch' }} ; then
48+
echo "call by self workflow_dispatch"
49+
echo "REF=${{ inputs.ref }}" >> $GITHUB_ENV
50+
echo "SUBMIT=true" >> $GITHUB_ENV
51+
else
52+
echo "unexpected event: ${{ github.event_name }}"
53+
exit 1
54+
fi
55+
56+
# packages tgz from /charts of original branch, deploy to /charts of target branch
57+
package_chart:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
with:
63+
fetch-depth: 0
64+
ref: ${{ needs.get_ref.outputs.ref }}
65+
- name: Configure Git
66+
run: |
67+
git config user.name "$GITHUB_ACTOR"
68+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
69+
- name: Install Helm
70+
uses: azure/setup-helm@v4
71+
with:
72+
version: ${{ env.HELM_VERSION }}
73+
74+
- name: Lint helm chart
75+
run: |
76+
make lint_chart
77+
- name: Package Chart
78+
continue-on-error: false
79+
run: |
80+
cd charts
81+
make clean
82+
make
83+
if ! ls *.tgz &>/dev/null ; then
84+
echo "failed to generate chart"
85+
exit 1
86+
fi
87+
cd ..
88+
mkdir -p tmp
89+
mv charts/*.tgz tmp
90+
- name: Upload Artifact
91+
uses: actions/upload-artifact@v3.1.3
92+
with:
93+
name: chart_package_artifact
94+
path: tmp/*
95+
retention-days: 1
96+
if-no-files-found: error
97+
98+
# update /index.yaml in the target branch
99+
update_githubpage:
100+
runs-on: ubuntu-latest
101+
needs: [package_chart, get_ref]
102+
if: ${{ needs.get_ref.outputs.submit == 'true' }}
103+
steps:
104+
- name: Get Base Chart URL
105+
id: get_base_url
106+
run: |
107+
name=${{ github.repository }}
108+
proj=${name#*/}
109+
url=https://${{ github.repository_owner }}.github.io/${proj}
110+
echo "URL=${url}" >> $GITHUB_ENV
111+
112+
- name: Checkout Code
113+
uses: actions/checkout@v4
114+
with:
115+
ref: ${{ env.MERGE_BRANCH }}
116+
persist-credentials: "true"
117+
118+
- name: Download Artifact
119+
uses: actions/download-artifact@v3
120+
with:
121+
name: chart_package_artifact
122+
path: charts/
123+
124+
- name: Update Chart Yaml
125+
run: |
126+
helm repo index ./charts --url ${{ env.URL }}/charts
127+
mv ./charts/index.yaml ./index.yaml
128+
- name: update helm release
129+
id: push_directory
130+
uses: cpina/github-action-push-to-another-repository@v1.7.2
131+
env:
132+
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
133+
with:
134+
source-directory: .
135+
destination-github-username: ${{ github.repository_owner }}
136+
destination-repository-name: hami
137+
user-email: xiaozhang0210@hotmail.com
138+
commit-message: sync ORIGIN_COMMIT from $GITHUB_REF
139+
target-branch: ${{ env.MERGE_BRANCH }}

0 commit comments

Comments
 (0)