-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (94 loc) · 3.71 KB
/
release.yml
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
name: Release and Publish
on:
push:
branches:
- main
jobs:
release:
name: Release and Publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Helm
uses: azure/[email protected]
- name: Calculate next version
id: version
run: |
# Get the latest tag
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Latest tag: $latest_tag"
# Extract current version
current_version=${latest_tag#v}
echo "Current version: $current_version"
# Default to patch bump unless the commit message specifies "feat" or "BREAKING CHANGE"
bump="patch"
if git log -1 --pretty=%B | grep -iq "feat"; then
bump="minor"
elif git log -1 --pretty=%B | grep -iq "BREAKING CHANGE"; then
bump="major"
fi
# Calculate the new version
IFS='.' read -r major minor patch <<< "$current_version"
case $bump in
patch) patch=$((patch + 1)) ;;
minor) minor=$((minor + 1)); patch=0 ;;
major) major=$((major + 1)); minor=0; patch=0 ;;
esac
new_version="$major.$minor.$patch"
echo "New version: $new_version"
echo "new_version=$new_version" >> $GITHUB_ENV
- name: Configure git
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "[email protected]"
- name: Update Helm Chart version
run: |
sed -i "s/^version:.*/version: ${{ env.new_version }}/" ./charts/homer-operator/Chart.yaml
- name: Run helm-docs
uses: losisin/helm-docs-github-action@v1
- name: Commit and push Helm chart changes
run: |
git add ./charts/homer-operator/
git commit -m "[skip actions] Update Helm chart docs and version to ${{ env.new_version }}"
git push origin main
- name: Tag the release
run: |
git tag -a ${{ env.new_version }} -m "Release ${{ env.new_version }}"
git push origin ${{ env.new_version }}
- name: Log in to GitHub Container Registry for Docker
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to GitHub Container Registry for Helm
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/homer-operator:${{ env.new_version }}
ghcr.io/${{ github.repository_owner }}/homer-operator:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/homer-operator:latest
- name: Package and push Helm chart
run: |
helm package ./charts/homer-operator -d ./artifacts
CHART_NAME=$(ls ./artifacts | grep .tgz)
helm push ./artifacts/$CHART_NAME oci://ghcr.io/${{ github.repository_owner }}/homer-operator
- name: Update Helm repository index
run: |
helm repo index artifacts --url https://arch-anes.github.io/homer-operator
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: artifacts
publish_branch: gh-pages