forked from gimlet-io/onechart
-
Notifications
You must be signed in to change notification settings - Fork 4
123 lines (103 loc) · 4.38 KB
/
release.yml
File metadata and controls
123 lines (103 loc) · 4.38 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
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract tag version
id: versioning
run: |
tag=${GITHUB_REF/refs\/tags\//}
tag=${tag#v}
echo "tag_version=$tag" >> $GITHUB_OUTPUT
- name: Extract chart versions
id: chart_versions
run: |
ONECHART_VERSION=$(grep '^version:' charts/onechart/Chart.yaml | awk '{print $2}')
CRON_JOB_VERSION=$(grep '^version:' charts/cron-job/Chart.yaml | awk '{print $2}')
STATIC_SITE_VERSION=$(grep '^version:' charts/static-site/Chart.yaml | awk '{print $2}')
echo "onechart_version=$ONECHART_VERSION" >> $GITHUB_OUTPUT
echo "cron_job_version=$CRON_JOB_VERSION" >> $GITHUB_OUTPUT
echo "static_site_version=$STATIC_SITE_VERSION" >> $GITHUB_OUTPUT
- name: Ensure tag and chart versions match
run: |
echo "Tag version: $TAG_VERSION"
echo "onechart version: $ONECHART_VERSION"
echo "cron-job version: $CRON_JOB_VERSION"
echo "static-site version: $STATIC_SITE_VERSION"
if [ "$TAG_VERSION" != "$ONECHART_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match onechart version ($ONECHART_VERSION)"
exit 1
fi
if [ "$TAG_VERSION" != "$CRON_JOB_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match cron-job version ($CRON_JOB_VERSION)"
exit 1
fi
if [ "$TAG_VERSION" != "$STATIC_SITE_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match static-site version ($STATIC_SITE_VERSION)"
exit 1
fi
echo "All versions match!"
env:
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}
ONECHART_VERSION: ${{ steps.chart_versions.outputs.onechart_version }}
CRON_JOB_VERSION: ${{ steps.chart_versions.outputs.cron_job_version }}
STATIC_SITE_VERSION: ${{ steps.chart_versions.outputs.static_site_version }}
- name: Create a Release
uses: elgohr/Github-Release-Action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: Release ${{ github.ref }}
- name: Publishing to the Helm repository
run: |
git config --global user.email "action@github.com"
git config --global user.name "Github Action"
git checkout main
make package
git add .
git commit -m "Publishing $TAG_VERSION to the Helm repository"
git push origin main
env:
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}
- name: Publish to GHCR
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io \
--username ${{ github.repository_owner }} \
--password-stdin
helm push docs/onechart-${{ env.TAG_VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}
helm push docs/cron-job-${{ env.TAG_VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}
helm push docs/static-site-${{ env.TAG_VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}
env:
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}
- name: Preparing the next release version
run: |
git config --global user.email "action@github.com"
git config --global user.name "Github Action"
git checkout main
CURRENT_VERSION=${{ env.TAG_VERSION }}
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{printf "%d.%d.0", $1, $2+1}')
echo "Current version: $CURRENT_VERSION"
echo "New version will be $NEW_VERSION"
sed -i "s/^\(version:\s*\)$CURRENT_VERSION/\1$NEW_VERSION/" charts/onechart/Chart.yaml
sed -i "s/^\(version:\s*\)$CURRENT_VERSION/\1$NEW_VERSION/" charts/cron-job/Chart.yaml
sed -i "s/^\(version:\s*\)$CURRENT_VERSION/\1$NEW_VERSION/" charts/static-site/Chart.yaml
sed -i "s/$CURRENT_VERSION/$NEW_VERSION/" README.md
sed -i "s/$CURRENT_VERSION/$NEW_VERSION/" docs/onechart.md
git status
git add .
git commit -m "Prepare next release version $NEW_VERSION"
git push origin main
env:
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}