5
5
branches :
6
6
- main
7
7
8
+ permissions :
9
+ contents : read
10
+ packages : write
11
+ attestations : write
12
+ id-token : write
13
+
14
+ concurrency :
15
+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16
+ cancel-in-progress : true
17
+
8
18
jobs :
9
- release :
10
- permissions :
11
- contents : write
12
- packages : write
19
+ publish-chart :
13
20
runs-on : ubuntu-latest
14
21
steps :
15
22
- name : Checkout
16
- uses : actions/checkout@v5.0.0
23
+ uses : actions/checkout@v5
17
24
with :
18
25
fetch-depth : 0
19
26
@@ -22,91 +29,47 @@ jobs:
22
29
git config user.name "$GITHUB_ACTOR"
23
30
git config user.email "[email protected] "
24
31
25
- - name : Login to Registry
26
- uses : docker/login-action@v3
27
- with :
28
- registry : ${{ vars.REGISTRY }}
29
- username : ${{ secrets.REGISTRY_USER }}
30
- password : ${{ secrets.REGISTRY_PASSWORD }}
31
-
32
- - name : Login to GHCR
33
- uses : docker/login-action@v3
34
- with :
35
- registry : ghcr.io
36
- username : ${{ github.actor }}
37
- password : ${{ secrets.GITHUB_TOKEN }}
32
+ - name : Login to GHCR Helm registry
33
+ shell : bash
34
+ run : |
35
+ echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login \
36
+ ghcr.io \
37
+ --username ${{ github.actor }} \
38
+ --password-stdin
38
39
39
40
- name : Run chart-releaser
40
41
id : chart-releaser
41
42
42
43
with :
43
44
skip_existing : true
45
+ skip_packaging : true
46
+ skip_upload : true
44
47
env :
45
48
CR_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
46
49
47
- - name : Install cosign
48
-
49
- if : ${{ steps.chart-releaser.outputs.changed_charts }}
50
-
51
- - id : github-repo-owner-name
52
- uses : ASzc/change-string-case-action@v6
53
- with :
54
- string : ${{ github.repository_owner }}
55
-
56
- - name : Upload charts to OCI registries
50
+ - name : Upload charts to OCI GHCR
57
51
id : upload
58
52
if : ${{ steps.chart-releaser.outputs.changed_charts }}
59
- env :
60
- COSIGN_KEY : ${{ secrets.COSIGN_KEY }}
61
- COSIGN_PASSWORD : ${{ secrets.COSIGN_PASSWORD }}
62
- REGISTRY_USER : ${{ secrets.REGISTRY_USER }}
63
53
run : |
64
54
CHANGED_CHARTS="${{ steps.chart-releaser.outputs.changed_charts }}"
65
55
66
- # Login to primary registry
67
- helm registry login --username $REGISTRY_USER --password ${{ secrets.REGISTRY_PASSWORD }} https://${{ vars.REGISTRY }}
68
-
69
- # Login to GHCR
70
- helm registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} https://ghcr.io
71
-
72
56
RELEASED_CHARTS=""
73
57
for chart_directory in ${CHANGED_CHARTS//,/ }; do
74
58
CHART_NAME=${chart_directory#charts/}
75
59
76
60
cd $chart_directory
77
61
78
- # Extract version and appVersion from Chart.yaml
79
62
CHART_VERSION=$(yq eval '.version' "Chart.yaml")
80
63
APP_VERSION=$(yq eval '.appVersion' "Chart.yaml")
81
64
82
- # Push to primary registry (Docker Hub)
83
- echo "Pushing Helm chart $CHART_NAME-$CHART_VERSION.tgz to oci://${{ vars.REGISTRY }}/${{ vars.REPOSITORY }}"
84
- if helm push ${{ github.workspace }}/.cr-release-packages/${CHART_NAME}-${CHART_VERSION}.tgz oci://${{ vars.REGISTRY }}/${{ vars.REPOSITORY }} 2>&1 | tee ${CHART_NAME}-output.log; then
85
-
86
- # Extract digest and sign chart
87
- DIGEST=$(cat ${CHART_NAME}-output.log | awk -F '[, ]+' '/Digest/{print $NF}')
88
- cosign sign -y --key env://COSIGN_KEY ${{ vars.REGISTRY }}/${{ vars.REPOSITORY }}/${CHART_NAME}:${CHART_VERSION}@$DIGEST
89
-
90
- RELEASED_CHARTS="$RELEASED_CHARTS ${CHART_NAME}"
91
- echo "Successfully released $CHART_NAME-$CHART_VERSION to primary registry"
92
- else
93
- echo "Failed to push $CHART_NAME-$CHART_VERSION to primary registry"
94
- cat ${CHART_NAME}-output.log
95
- exit 1
96
- fi
65
+ helm package . --app-version=${APP_VERSION} --version=${CHART_VERSION}
97
66
98
67
# Push to GHCR
99
- echo "Pushing Helm chart $CHART_NAME-$CHART_VERSION.tgz to oci://ghcr.io/${{ steps.github-repo-owner-name.outputs.lowercase }}/helm-charts"
100
- if helm push ${{ github.workspace }}/.cr-release-packages/${CHART_NAME}-${CHART_VERSION}.tgz oci://ghcr.io/${{ steps.github-repo-owner-name.outputs.lowercase }}/helm-charts 2>&1 | tee ${CHART_NAME}-ghcr-output.log; then
101
-
102
- # Extract digest and sign GHCR chart
103
- GHCR_DIGEST=$(cat ${CHART_NAME}-ghcr-output.log | awk -F '[, ]+' '/Digest/{print $NF}')
104
- cosign sign -y --key env://COSIGN_KEY ghcr.io/${{ steps.github-repo-owner-name.outputs.lowercase }}/helm-charts/${CHART_NAME}:${CHART_VERSION}@$GHCR_DIGEST
105
-
68
+ echo "Pushing Helm chart $CHART_NAME-$CHART_VERSION.tgz to oci://ghcr.io/${{ github.event.repository.name }}"
69
+ if helm push ${{ github.workspace }}/$CHART_NAME-$CHART_VERSION.tgz oci://ghcr.io/${{ github.event.repository.name }}; then
106
70
echo "Successfully released $CHART_NAME-$CHART_VERSION to GHCR"
107
71
else
108
72
echo "Failed to push $CHART_NAME-$CHART_VERSION to GHCR"
109
- cat ${CHART_NAME}-ghcr-output.log
110
73
exit 1
111
74
fi
112
75
0 commit comments