-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (175 loc) · 6.91 KB
/
releases.yml
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: ArtifactHub Release Charts
on:
push:
branches:
- main
jobs:
# Lint and Test HelmCharts
stage-lint-test:
runs-on: ubuntu-latest
permissions:
contents: read
continue-on-error: false
container:
image: artifacthub/ah
options: --user 1001
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run ah lint
working-directory: charts/alucard
run: ah lint
# Release into ArtifactHub
stage-publisher:
runs-on: ubuntu-latest
permissions:
contents: write
continue-on-error: false
needs: stage-lint-test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Helm tool installer
uses: Azure/setup-helm@v3
- name: Check Helm version
run: helm version
- name: Extract Version and Description from Chart.yaml
id: versioning
run: |
# Extract the version from Chart.yaml
current_version=$(grep '^version:' ./charts/alucard/Chart.yaml | awk '{print $2}')
# Extract the description from Chart.yaml
description=$(grep '^description:' ./charts/alucard/Chart.yaml | sed 's/description: //')
# Set the version and description as outputs
echo "EXIST_VERSION=$current_version" >> $GITHUB_ENV
echo "DESCRIPTION=$description" >> $GITHUB_ENV
echo "::set-output name=version::$current_version"
echo "::set-output name=description::$description"
- name: Delete Existing Tag and Release if Exists
run: |
tag_name="alucard-${{ steps.versioning.outputs.version }}"
release_id=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$tag_name" | jq -r '.id')
if [ "$release_id" != "null" ]; then
echo "Deleting existing release with ID: $release_id"
curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/$release_id"
fi
if git rev-parse "$tag_name" >/dev/null 2>&1; then
echo "Deleting existing tag: $tag_name"
git tag -d "$tag_name"
git push origin --delete "$tag_name"
fi
- name: Create Git Tag
run: |
git config --local user.email ${{ secrets.USER_EMAIL }}
git config --local user.name ${{ secrets.USER_NAME }}
git tag "alucard-${{ steps.versioning.outputs.version }}"
git push -f origin "alucard-${{ steps.versioning.outputs.version }}"
- name: Package Helm Chart
run: |
cd ./stable && helm package --version ${{ steps.versioning.outputs.version }} ../charts/alucard
cd ./stable && helm repo index --url https://sithanos.github.io/alucard/stable --merge index.yaml .
git add .
git commit -m "feat: Update chart index with version ${{ steps.versioning.outputs.version }}"
git push https://${{ secrets.USER_NAME }}:${{ secrets.USER_TOKEN }}@github.com/sithanos/alucard.git
- name: Verify .tgz File Exists
run: |
ls -lah ./stable
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.USER_TOKEN }}
with:
tag_name: "alucard-${{ steps.versioning.outputs.version }}"
release_name: "alucard-${{ steps.versioning.outputs.version }}"
body: "${{ steps.versioning.outputs.description }}"
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.USER_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./stable/alucard-${{ steps.versioning.outputs.version }}.tgz
asset_name: alucard-${{ steps.versioning.outputs.version }}.tgz
asset_content_type: application/gzip
# # Release into ArtifactHub
# stage-publisher:
# runs-on: ubuntu-latest
# permissions:
# contents: write
# continue-on-error: false
# needs: stage-lint-test
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Extract Version from Chart.yaml
# id: versioning
# run: |
# # Extract the version from Chart.yaml
# current_version=$(grep '^version:' ./charts/alucard/Chart.yaml | awk '{print $2}')
# # Set the version as an output
# echo "CURRENT_VERSION=$current_version" >> $GITHUB_ENV
# echo "::set-output name=version::$current_version"
# - name: Helm tool installer
# uses: Azure/setup-helm@v3
# - name: Check Helm version
# run: helm version
# - name: Package Helm Chart
# run: |
# cd ./stable
# helm package --version ${{ steps.versioning.outputs.version }} ../charts/alucard
# helm repo index --url https://sithanos.github.io/alucard/stable --merge index.yaml .
# git config --local user.email ${{ secrets.USER_EMAIL }}
# git config --local user.name ${{ secrets.USER_NAME }}
# git add .
# git commit -m "feat: Update chart index with version ${{ steps.versioning.outputs.version }}"
# git push https://${{ secrets.USER_NAME }}:${{ secrets.USER_TOKEN }}@github.com/sithanos/alucard.git
# # Release into ArtifactHub
# stage-publisher:
# runs-on: ubuntu-latest
# permissions:
# contents: write
# continue-on-error: false
# needs: stage-lint-test
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Publish Helm charts
# uses: stefanprodan/helm-gh-pages@master
# with:
# token: ${{ secrets.USER_TOKEN }}
# charts_dir: charts
# # charts_url: https://sithanos.github.io/alucard
# # owner: sithanos
# # repository: alucard
# branch: main
# target_dir: stable
# # Fetch from ArtifactHub
# stage-fetch:
# runs-on: ubuntu-latest
# permissions:
# contents: write
# continue-on-error: false
# needs: stage-publisher
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Configure Git
# run: |
# git config user.name "$USER_NAME"
# git config user.email "$USER_EMAIL"
# - name: Install Helm
# uses: azure/setup-helm@v4
# env:
# USER_TOKEN: "${{ secrets.USER_TOKEN }}"
# - name: Run chart-releaser
# uses: helm/chart-releaser-action@v1.6.0
# with:
# charts_dir: charts/alucard
# config: charts/assets/cr.yaml
# env:
# CR_TOKEN: "${{ secrets.USER_TOKEN }}"