-
Notifications
You must be signed in to change notification settings - Fork 14
181 lines (157 loc) · 6.21 KB
/
chart-releaser.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
name: Chart Release
on:
workflow_dispatch:
inputs:
plane-ce:
description: 'Build Plane CE'
type: boolean
default: false
plane-ee:
description: 'Build Plane EE'
type: boolean
default: false
env:
CR_CONFIGFILE: "${{ github.workspace }}/cr.yaml"
CR_TOOL_PATH: "${{ github.workspace }}/.cr-tool"
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GNUPGHOME: ${{ github.workspace }}/.gnupg
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
TARGET_BRANCH: "${{ github.ref_name }}"
CHART_NAME_CE: "plane-ce"
CHART_NAME_ENTERPRISE: "plane-enterprise"
MARK_AS_LATEST: true
MARK_AS_PRERELASE: false
PAGES_INDEX_PATH: ""
jobs:
setup:
if: ${{ github.event.inputs.plane-ce == 'true' || github.event.inputs.plane-ee == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v4
- name: Prepare GPG key #this step is for using exported keys and make your github runner
env:
CR_PASSPHRASE_FILE: ${{env.GNUPGHOME}}/gpg-passphrase
run: |
gpg --version
mkdir -p ${{env.GNUPGHOME}}
chmod 700 ${{env.GNUPGHOME}}
# Disable the use of the gpg-agent
echo "use-agent" >> ${{env.GNUPGHOME}}/gpg.conf
echo "pinentry-mode loopback" >> ${{env.GNUPGHOME}}/gpg.conf
echo "no-tty" >> ${{env.GNUPGHOME}}/gpg.conf
echo "no-autostart" >> ${{env.GNUPGHOME}}/gpg-agent.conf
echo "allow-loopback-pinentry" >> ${{env.GNUPGHOME}}/gpg-agent.conf
echo "${{env.GPG_PASSPHRASE}}" > ${{env.CR_PASSPHRASE_FILE}}
# Import the GPG key
echo "${{ env.GPG_PRIVATE_KEY }}" | gpg --batch --yes --pinentry-mode loopback --passphrase ${{ env.GPG_PASSPHRASE }} --import
# Re-create keyring in legacy format for Helm compatibility
gpg --export-secret-keys --passphrase ${{env.GPG_PASSPHRASE}} > ${{env.GNUPGHOME}}/secring.gpg
gpg --export --passphrase ${{env.GPG_PASSPHRASE}} > ${{env.GNUPGHOME}}/pubring.gpg
chmod 400 ${{env.GNUPGHOME}}/secring.gpg
- name: Remove unwanted charts
run: |
if [ "${{ github.event.inputs.plane-ce }}" = "false" ]; then
rm -rf charts/${{ env.CHART_NAME_CE }}
fi
if [ "${{ github.event.inputs.plane-ee }}" = "false" ]; then
rm -rf charts/${{ env.CHART_NAME_ENTERPRISE }}
fi
- name: Rename Chart
if: github.ref_name != 'master'
run: |
flatBranchName=$(echo "${{ env.TARGET_BRANCH }}" | sed 's/\//\-/g')
if [ "${{ github.event.inputs.plane-ce }}" = "true" ]; then
sed -i "s/name: \(.*\)/name: \1-${flatBranchName}/" charts/${{ env.CHART_NAME_CE }}/Chart.yaml
fi
if [ "${{ github.event.inputs.plane-ee }}" = "true" ]; then
sed -i "s/name: \(.*\)/name: \1-${flatBranchName}/" charts/${{ env.CHART_NAME_ENTERPRISE }}/Chart.yaml
fi
echo "MARK_AS_LATEST=false" >> $GITHUB_ENV
echo "MARK_AS_PRERELASE=true" >> $GITHUB_ENV
echo "PAGES_INDEX_PATH=${flatBranchName}" >> $GITHUB_ENV
- name: Release Charts
uses: mguptahub/[email protected]
with:
charts_dir: charts
config: cr.yaml
packages_with_index: false
skip_existing: true
mark_as_latest: ${{ env.MARK_AS_LATEST }}
prerelease: ${{ env.MARK_AS_PRERELASE }}
pages_index_path: ${{ env.PAGES_INDEX_PATH }}
env:
CR_TOKEN: ${{ env.CR_TOKEN }}
CR_KEY: ${{ env.GPG_KEY_NAME }}
CR_KEYRING: ${{env.GNUPGHOME}}/secring.gpg
CR_PASSPHRASE_FILE: ${{env.GNUPGHOME}}/gpg-passphrase
CR_SIGN: true
- id: publish-plane-enterprise
if: ${{ github.ref_name == 'master' && github.event.inputs.plane-ee == 'true' }}
name: Harbor Publish Plane-Enterprise
env:
CHART_REPO: ${{ env.CHART_NAME_ENTERPRISE }}
HELM_REPO: plane
CR_KEY: ${{ env.GPG_KEY_NAME }}
CR_PASSPHRASE_FILE: ${{env.GNUPGHOME}}/gpg-passphrase
CR_KEYRING: ${{env.GNUPGHOME}}/secring.gpg
run: |
mkdir -p tmp
helm registry login -u ${{ secrets.HARBOR_USERNAME }} -p ${{ secrets.HARBOR_TOKEN }} ${{ vars.HARBOR_REGISTRY }}
helm package --sign --key "$CR_KEY" --keyring "$CR_KEYRING" --passphrase-file "$CR_PASSPHRASE_FILE" charts/$CHART_REPO -u -d tmp
helm push tmp/${{ env.CHART_REPO }}-*.tgz oci://${{ vars.HARBOR_REGISTRY }}/${{env.HELM_REPO}}
rm -rf tmp
publish:
if: ${{ github.ref_name == 'master' }}
needs: setup
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
path: code
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: gh-pages
path: pages
- name: Configure Git
working-directory: pages
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Copy Readme
run: |
if [ "${{ github.event.inputs.plane-ce }}" = "true" ]; then
cp code/charts/plane-ce/README.md pages/content/plane-ce.md
fi
if [ "${{ github.event.inputs.plane-ee }}" = "true" ]; then
cp code/charts/plane-enterprise/README.md pages/content/plane-ee.md
fi
- name: Publish pages
working-directory: pages
run: |
git add .
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
# Commit and push the changes
git commit -m "Updated READMEs"
git push
fi