Skip to content

Commit 45874d7

Browse files
authored
Merge pull request #7 from opsta/feat-opsta
feat: add document and improve github actions
2 parents 8730d9d + 9fac9cd commit 45874d7

File tree

3 files changed

+758
-52
lines changed

3 files changed

+758
-52
lines changed

.github/workflows/release.yml

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -26,45 +26,44 @@ jobs:
2626
run: |
2727
tag=${GITHUB_REF/refs\/tags\//}
2828
tag=${tag#v}
29-
echo ::set-output name=tag_version::$tag
29+
echo "tag_version=$tag" >> $GITHUB_OUTPUT
3030
31-
- name: Extract chart version
32-
id: chart_version
31+
- name: Extract chart versions
32+
id: chart_versions
3333
run: |
34-
CHART_VERSION=$(cat charts/onechart/Chart.yaml | grep ^version:)
35-
CHART_VERSION=${CHART_VERSION#version: }
36-
echo $CHART_VERSION
37-
echo ::set-output name=chart_version::$CHART_VERSION
38-
39-
CHART_VERSION=$(cat charts/cron-job/Chart.yaml | grep ^version:)
40-
CHART_VERSION=${CHART_VERSION#version: }
41-
echo $CHART_VERSION
42-
echo ::set-output name=cron_job_chart_version::$CHART_VERSION
43-
44-
CHART_VERSION=$(cat charts/static-site/Chart.yaml | grep ^version:)
45-
CHART_VERSION=${CHART_VERSION#version: }
46-
echo $CHART_VERSION
47-
echo ::set-output name=static_site_chart_version::$CHART_VERSION
48-
49-
- name: Ensure tag and chart version matches
34+
ONECHART_VERSION=$(grep '^version:' charts/onechart/Chart.yaml | awk '{print $2}')
35+
CRON_JOB_VERSION=$(grep '^version:' charts/cron-job/Chart.yaml | awk '{print $2}')
36+
STATIC_SITE_VERSION=$(grep '^version:' charts/static-site/Chart.yaml | awk '{print $2}')
37+
38+
echo "onechart_version=$ONECHART_VERSION" >> $GITHUB_OUTPUT
39+
echo "cron_job_version=$CRON_JOB_VERSION" >> $GITHUB_OUTPUT
40+
echo "static_site_version=$STATIC_SITE_VERSION" >> $GITHUB_OUTPUT
41+
42+
- name: Ensure tag and chart versions match
5043
run: |
51-
echo "$TAG_VERSION"
52-
echo "$CHART_VERSION"
53-
echo "$CRON_JOB_CHART_VERSION"
54-
if [ "$TAG_VERSION" != "$CHART_VERSION" ]
55-
then
56-
echo "Tag version does not match chart version"
44+
echo "Tag version: $TAG_VERSION"
45+
echo "onechart version: $ONECHART_VERSION"
46+
echo "cron-job version: $CRON_JOB_VERSION"
47+
echo "static-site version: $STATIC_SITE_VERSION"
48+
49+
if [ "$TAG_VERSION" != "$ONECHART_VERSION" ]; then
50+
echo "::error::Tag version ($TAG_VERSION) does not match onechart version ($ONECHART_VERSION)"
51+
exit 1
52+
fi
53+
if [ "$TAG_VERSION" != "$CRON_JOB_VERSION" ]; then
54+
echo "::error::Tag version ($TAG_VERSION) does not match cron-job version ($CRON_JOB_VERSION)"
55+
exit 1
56+
fi
57+
if [ "$TAG_VERSION" != "$STATIC_SITE_VERSION" ]; then
58+
echo "::error::Tag version ($TAG_VERSION) does not match static-site version ($STATIC_SITE_VERSION)"
5759
exit 1
5860
fi
59-
if [ "$TAG_VERSION" != "$CRON_JOB_CHART_VERSION" ]
60-
then
61-
echo "Tag version does not match cron-job chart version"
62-
exit 1
63-
fi
61+
echo "All versions match!"
6462
env:
6563
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}
66-
CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }}
67-
CRON_JOB_CHART_VERSION: ${{ steps.chart_version.outputs.cron_job_chart_version }}
64+
ONECHART_VERSION: ${{ steps.chart_versions.outputs.onechart_version }}
65+
CRON_JOB_VERSION: ${{ steps.chart_versions.outputs.cron_job_version }}
66+
STATIC_SITE_VERSION: ${{ steps.chart_versions.outputs.static_site_version }}
6867

6968
- name: Create a Release
7069
uses: elgohr/Github-Release-Action@v5
@@ -84,40 +83,41 @@ jobs:
8483
git push origin main
8584
env:
8685
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}
87-
title: Release ${{ github.ref }}
8886

89-
- name: Publish to to GHCR
87+
- name: Publish to GHCR
9088
run: |
9189
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io \
9290
--username ${{ github.repository_owner }} \
9391
--password-stdin
94-
helm push docs/onechart-${CHART_VERSION}.tgz oci://ghcr.io/${{ github.repository }}
95-
helm push docs/cron-job-${CHART_VERSION}.tgz oci://ghcr.io/${{ github.repository }}
96-
helm push docs/static-site-${STATIC_SITE_CHART_VERSION}.tgz oci://ghcr.io/${{ github.repository }}
92+
93+
helm push docs/onechart-${{ env.TAG_VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}
94+
helm push docs/cron-job-${{ env.TAG_VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}
95+
helm push docs/static-site-${{ env.TAG_VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}
9796
env:
98-
CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }}
99-
STATIC_SITE_CHART_VERSION: ${{ steps.chart_version.outputs.static_site_chart_version }}
97+
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}
98+
10099
- name: Preparing the next release version
101100
run: |
102101
git config --global user.email "action@github.com"
103102
git config --global user.name "Github Action"
104103
git checkout main
105104
106-
without_major_version=${CHART_VERSION#*.}
107-
without_patch_version=${without_major_version%.*}
108-
increased_minor_version=$(($without_patch_version + 1))
109-
major_version=${CHART_VERSION%%.*}
110-
increased_version="$major_version.$increased_minor_version.0"
111-
echo "The new version will be $increased_version"
105+
CURRENT_VERSION=${{ env.TAG_VERSION }}
106+
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{printf "%d.%d.0", $1, $2+1}')
112107
113-
sed -i "s/version: $CHART_VERSION/version: $increased_version/" charts/onechart/Chart.yaml
114-
sed -i "s/version: $CHART_VERSION/version: $increased_version/" charts/cron-job/Chart.yaml
115-
sed -i "s/version: $CHART_VERSION/version: $increased_version/" charts/static-site/Chart.yaml
116-
sed -i "s/--version $CHART_VERSION/--version $increased_version/" README.md
108+
echo "Current version: $CURRENT_VERSION"
109+
echo "New version will be $NEW_VERSION"
110+
111+
sed -i "s/^\(version:\s*\)$CURRENT_VERSION/\1$NEW_VERSION/" charts/onechart/Chart.yaml
112+
sed -i "s/^\(version:\s*\)$CURRENT_VERSION/\1$NEW_VERSION/" charts/cron-job/Chart.yaml
113+
sed -i "s/^\(version:\s*\)$CURRENT_VERSION/\1$NEW_VERSION/" charts/static-site/Chart.yaml
114+
115+
sed -i "s/$CURRENT_VERSION/$NEW_VERSION/" README.md
116+
sed -i "s/$CURRENT_VERSION/$NEW_VERSION/" docs/onechart.md
117117
118118
git status
119119
git add .
120-
git commit -m "The next release version will be $increased_version"
120+
git commit -m "Prepare next release version $NEW_VERSION"
121121
git push origin main
122122
env:
123-
CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }}
123+
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A generic Helm chart for your application deployments.
66

77
Because no-one can remember the Kubernetes yaml syntax.
88

9-
https://gimlet.io/docs/reference/onechart-reference
9+
https://github.com/opsta/onechart/blob/main/docs/onechart.md
1010

1111
## Getting started
1212

0 commit comments

Comments
 (0)