-
Notifications
You must be signed in to change notification settings - Fork 2
98 lines (84 loc) · 3.24 KB
/
release.yaml
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
name: Release Cruise Control chart
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "charts/cruise-control/**"
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic_release
with:
dry_run: true
branch: main
tag_format: ${version}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Chart verison
id: chart_version
if: steps.semantic_release.outputs.new_release_published == 'true'
run: |
sed -i 's/^version: .*/version: ${{ steps.semantic_release.outputs.new_release_git_tag }}/g' charts/cruise-control/Chart.yaml
echo "CHART_VERSION=${{ steps.semantic_release.outputs.new_release_git_tag }}" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: tag_exists
if: steps.semantic_release.outputs.new_release_published == 'true'
run: |
TAG_EXISTS=true
if ! [ $(git tag -l "v${{ steps.chart_version.outputs.CHART_VERSION }}") ]; then
TAG_EXISTS=false
fi
echo TAG_EXISTS=$TAG_EXISTS >> $GITHUB_OUTPUT
- name: Run chart-releaser
if: steps.tag_exists.outputs.TAG_EXISTS == 'false'
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: charts
config: .github/cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: true
- name: Login in to the Container registry
if: steps.tag_exists.outputs.TAG_EXISTS == 'false'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cosign
if: steps.tag_exists.outputs.TAG_EXISTS == 'false'
uses: sigstore/cosign-installer@v3
- name: Install Oras
if: steps.tag_exists.outputs.TAG_EXISTS == 'false'
uses: oras-project/setup-oras@v1
# ref: https://github.com/backstage/charts/blob/88240ce7a0726e3773ee0e4866fbe6325c15267b/.github/workflows/release.yml#L50
- name: Publish and Sign OCI Charts
if: steps.tag_exists.outputs.TAG_EXISTS == 'false'
run: |
for chart in `find .cr-release-packages -name '*.tgz' -print`; do
helm push ${chart} oci://ghcr.io/${GITHUB_REPOSITORY} |& tee helm-push-output.log
file_name=${chart##*/}
chart_name=${file_name%-*}
digest=$(awk -F "[, ]+" '/Digest/{print $NF}' < helm-push-output.log)
cosign sign -y "ghcr.io/${GITHUB_REPOSITORY}/${chart_name}@${digest}"
oras push "ghcr.io/${GITHUB_REPOSITORY}/${chart_name}:artifacthub.io" "artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml"
done
env:
COSIGN_EXPERIMENTAL: 1