|
1 | | -name: Release |
| 1 | +name: Release Charts |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - tags: |
6 | | - - "v*" |
| 5 | + branches: |
| 6 | + - main |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - release: |
10 | | - name: Release |
| 9 | + build: |
| 10 | + name: Build |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 | steps: |
13 | | - - name: Checkout main |
14 | | - uses: actions/checkout@v4 |
| 13 | + - name: Set up Go |
| 14 | + uses: actions/setup-go@v4 |
15 | 15 | with: |
16 | | - fetch-depth: 0 |
| 16 | + go-version: 1.25 |
| 17 | + cache: false |
17 | 18 |
|
18 | | - - name: Extract tag version |
19 | | - id: versioning |
| 19 | + - name: Deps |
20 | 20 | run: | |
21 | | - tag=${GITHUB_REF/refs\/tags\//} |
22 | | - tag=${tag#v} |
23 | | - echo ::set-output name=tag_version::$tag |
| 21 | + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 |
| 22 | + chmod 700 get_helm.sh |
| 23 | + ./get_helm.sh |
24 | 24 |
|
25 | | - - name: Extract chart version |
26 | | - id: chart_version |
27 | | - run: | |
28 | | - CHART_VERSION=$(cat charts/onechart/Chart.yaml | grep ^version:) |
29 | | - CHART_VERSION=${CHART_VERSION#version: } |
30 | | - echo $CHART_VERSION |
31 | | - echo ::set-output name=chart_version::$CHART_VERSION |
32 | | -
|
33 | | - CHART_VERSION=$(cat charts/cron-job/Chart.yaml | grep ^version:) |
34 | | - CHART_VERSION=${CHART_VERSION#version: } |
35 | | - echo $CHART_VERSION |
36 | | - echo ::set-output name=cron_job_chart_version::$CHART_VERSION |
| 25 | + wget https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz |
| 26 | + tar xf kubeval-linux-amd64.tar.gz |
| 27 | + sudo cp kubeval /usr/local/bin |
37 | 28 |
|
38 | | - CHART_VERSION=$(cat charts/static-site/Chart.yaml | grep ^version:) |
39 | | - CHART_VERSION=${CHART_VERSION#version: } |
40 | | - echo $CHART_VERSION |
41 | | - echo ::set-output name=static_site_chart_version::$CHART_VERSION |
| 29 | + helm plugin install https://github.com/helm-unittest/helm-unittest |
42 | 30 |
|
43 | | - - name: Ensure tag and chart version matches |
44 | | - run: | |
45 | | - echo "$TAG_VERSION" |
46 | | - echo "$CHART_VERSION" |
47 | | - echo "$CRON_JOB_CHART_VERSION" |
48 | | - if [ "$TAG_VERSION" != "$CHART_VERSION" ] |
49 | | - then |
50 | | - echo "Tag version does not match chart version" |
51 | | - exit 1 |
52 | | - fi |
53 | | - if [ "$TAG_VERSION" != "$CRON_JOB_CHART_VERSION" ] |
54 | | - then |
55 | | - echo "Tag version does not match cron-job chart version" |
56 | | - exit 1 |
57 | | - fi |
58 | | - env: |
59 | | - TAG_VERSION: ${{ steps.versioning.outputs.tag_version }} |
60 | | - CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }} |
61 | | - CRON_JOB_CHART_VERSION: ${{ steps.chart_version.outputs.cron_job_chart_version }} |
62 | | - |
63 | | - - name: Create a Release |
64 | | - uses: elgohr/Github-Release-Action@v5 |
65 | | - env: |
66 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + - name: Check out |
| 32 | + uses: actions/checkout@v4 |
67 | 33 | with: |
68 | | - title: Release ${{ github.ref }} |
| 34 | + fetch-depth: 1 |
69 | 35 |
|
70 | | - - name: Publishing to the Helm repository |
| 36 | + - name: Test |
71 | 37 | run: | |
72 | | - git config --global user.email "action@github.com" |
73 | | - git config --global user.name "Github Action" |
74 | | - git checkout main |
75 | | - make package |
76 | | - git add . |
77 | | - git commit -m "Publishing $TAG_VERSION to the Helm repository" |
78 | | - git push origin main |
79 | | - env: |
80 | | - TAG_VERSION: ${{ steps.versioning.outputs.tag_version }} |
81 | | - title: Release ${{ github.ref }} |
| 38 | + make lint |
| 39 | + make kubeval |
| 40 | + make test |
| 41 | + release: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + needs: build |
| 44 | + steps: |
| 45 | + - name: Checkout |
| 46 | + uses: actions/checkout@v5 |
| 47 | + with: |
| 48 | + fetch-depth: 0 |
82 | 49 |
|
83 | | - - name: Publish to to GHCR |
| 50 | + - name: Configure Git |
84 | 51 | run: | |
85 | | - echo ${{ secrets.HELM_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin |
86 | | - helm push docs/onechart-${CHART_VERSION}.tgz oci://ghcr.io/techmagister |
87 | | - helm push docs/cron-job-${CHART_VERSION}.tgz oci://ghcr.io/techmagister |
88 | | - helm push docs/static-site-${STATIC_SITE_CHART_VERSION}.tgz oci://ghcr.io/techmagister |
89 | | - env: |
90 | | - CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }} |
91 | | - STATIC_SITE_CHART_VERSION: ${{ steps.chart_version.outputs.static_site_chart_version }} |
92 | | - - name: Preparing the next release version |
93 | | - run: | |
94 | | - git config --global user.email "action@github.com" |
95 | | - git config --global user.name "Github Action" |
96 | | - git checkout main |
97 | | -
|
98 | | - without_major_version=${CHART_VERSION#*.} |
99 | | - without_patch_version=${without_major_version%.*} |
100 | | - increased_minor_version=$(($without_patch_version + 1)) |
101 | | - major_version=${CHART_VERSION%%.*} |
102 | | - increased_version="$major_version.$increased_minor_version.0" |
103 | | - echo "The new version will be $increased_version" |
| 52 | + git config user.name "$GITHUB_ACTOR" |
| 53 | + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" |
104 | 54 |
|
105 | | - sed -i "s/version: $CHART_VERSION/version: $increased_version/" charts/onechart/Chart.yaml |
106 | | - sed -i "s/version: $CHART_VERSION/version: $increased_version/" charts/cron-job/Chart.yaml |
107 | | - sed -i "s/version: $CHART_VERSION/version: $increased_version/" charts/static-site/Chart.yaml |
| 55 | + - name: Install Helm |
| 56 | + uses: azure/setup-helm@v4 |
| 57 | + with: |
| 58 | + version: v3.18.4 |
108 | 59 |
|
109 | | - git status |
110 | | - git add . |
111 | | - git commit -m "The next release version will be $increased_version" |
112 | | - git push origin main |
| 60 | + - name: Run chart-releaser |
| 61 | + uses: helm/chart-releaser-action@v1.7.0 |
113 | 62 | env: |
114 | | - CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }} |
| 63 | + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 64 | + with: |
| 65 | + packages_with_index: true |
0 commit comments