Skip to content

Commit a3454e4

Browse files
authored
update chart release action to use CR release v1.4.0 (#106)
* update chart release action to use CR release v1.4.0 Signed-off-by: cpanato <[email protected]> * update based on review Signed-off-by: cpanato <[email protected]>
1 parent 6208805 commit a3454e4

File tree

4 files changed

+99
-20
lines changed

4 files changed

+99
-20
lines changed

.github/workflows/test-action.yml

+33-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: test-chart-releaser
33
on: [pull_request]
44

55
jobs:
6-
test_chart_releaser_action:
6+
test_chart_releaser_install_action:
77
runs-on: ubuntu-latest
88
permissions:
99
actions: none
@@ -21,13 +21,42 @@ jobs:
2121
- uses: actions/checkout@v2
2222
- name: Install chart-releaser
2323
uses: ./
24+
with:
25+
install_only: true
26+
env:
27+
CR_TOKEN: "FAKE_SECRETS"
2428
- name: Check install!
2529
run: cr version
2630
- name: Check root directory
2731
run: |
28-
if [[ $(git diff --stat) != '' ]]; then
32+
if ! git diff --stat --exit-code; then
33+
echo 'should be clean'
34+
exit 1
35+
fi
36+
37+
test_chart_releaser_action:
38+
runs-on: ubuntu-latest
39+
permissions:
40+
actions: none
41+
checks: none
42+
contents: none
43+
deployments: none
44+
issues: none
45+
packages: none
46+
pull-requests: none
47+
repository-projects: none
48+
security-events: none
49+
statuses: none
50+
name: Install chart-releaser and run it
51+
steps:
52+
- uses: actions/checkout@v2
53+
- name: Install chart-releaser
54+
uses: ./
55+
env:
56+
CR_TOKEN: "FAKE_SECRETS"
57+
- name: Check root directory
58+
run: |
59+
if ! git diff --stat --exit-code; then
2960
echo 'should be clean'
3061
exit 1
31-
else
32-
exit 0
3362
fi

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, usi
66

77
### Pre-requisites
88

9-
1. A GitHub repo containing a directory with your Helm charts (default is a folder named `/charts`, if you want to
9+
1. A GitHub repo containing a directory with your Helm charts (default is a folder named `/charts`, if you want to
1010
maintain your charts in a different directory, you must include a `charts_dir` input in the workflow).
1111
1. A GitHub branch called `gh-pages` to store the published charts. See `charts_repo_url` for alternatives.
1212
1. In your repo, go to Settings/Pages. Change the `Source` `Branch` to `gh-pages`.
@@ -15,7 +15,7 @@ maintain your charts in a different directory, you must include a `charts_dir` i
1515

1616
### Inputs
1717

18-
- `version`: The chart-releaser version to use (default: v1.3.0)
18+
- `version`: The chart-releaser version to use (default: v1.4.0)
1919
- `config`: Optional config file for chart-releaser. For more information on the config file, see the [documentation](https://github.com/helm/chart-releaser#config-file)
2020
- `charts_dir`: The charts directory
2121
- `charts_repo_url`: The GitHub Pages URL to the charts repo (default: `https://<owner>.github.io/<project>`)
@@ -55,10 +55,10 @@ jobs:
5555
- name: Install Helm
5656
uses: azure/setup-helm@v1
5757
with:
58-
version: v3.7.1
58+
version: v3.8.1
5959

6060
- name: Run chart-releaser
61-
uses: helm/chart-releaser-action@v1.3.0
61+
uses: helm/chart-releaser-action@v1.4.0
6262
env:
6363
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
6464
```
@@ -71,7 +71,7 @@ It does this – during every push to `main` – by checking each chart in your
7171
`workflow.yml`:
7272
```yaml
7373
- name: Run chart-releaser
74-
uses: helm/chart-releaser-action@v1.2.0
74+
uses: helm/chart-releaser-action@v1.4.0
7575
with:
7676
charts_dir: charts
7777
config: cr.yaml
@@ -81,6 +81,7 @@ It does this – during every push to `main` – by checking each chart in your
8181
```
8282

8383
`cr.yaml`:
84+
8485
```yaml
8586
owner: myaccount
8687
git-base-url: https://api.github.com/

action.yml

+26-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,26 @@ branding:
66
icon: anchor
77
inputs:
88
version:
9-
description: "The chart-releaser version to use (default: v1.3.0)"
9+
description: "The chart-releaser version to use (default: v1.4.0)"
10+
required: false
11+
default: v1.4.0
1012
config:
1113
description: "The relative path to the chart-releaser config file"
14+
required: false
1215
charts_dir:
1316
description: The charts directory
17+
required: false
1418
default: charts
1519
charts_repo_url:
1620
description: "The GitHub Pages URL to the charts repo (default: https://<owner>.github.io/<repo>)"
21+
required: false
22+
install_dir:
23+
description: 'Where to install the cr tool'
24+
required: false
25+
install_only:
26+
description: 'Just install cr tool'
27+
required: false
28+
1729
runs:
1830
using: composite
1931
steps:
@@ -36,5 +48,18 @@ runs:
3648
args+=(--charts-repo-url "${{ inputs.charts_repo_url }}")
3749
fi
3850
51+
if [[ -z "${{ inputs.install_dir }}" ]]; then
52+
install="$RUNNER_TOOL_CACHE/cr/${{ inputs.version }}/$(uname -m)"
53+
echo "$install" >> "$GITHUB_PATH"
54+
args+=(--install-dir "$install")
55+
else
56+
echo ${{ inputs.install_dir }} >> "$GITHUB_PATH"
57+
args+=(--install-dir "${{ inputs.install_dir }}")
58+
fi
59+
60+
if [[ -n "${{ inputs.install_only }}" ]]; then
61+
args+=(--install-only "${{ inputs.install_only }}")
62+
fi
63+
3964
"$GITHUB_ACTION_PATH/cr.sh" "${args[@]}"
4065
shell: bash

cr.sh

+34-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21-
DEFAULT_CHART_RELEASER_VERSION=v1.3.0
21+
DEFAULT_CHART_RELEASER_VERSION=v1.4.0
2222

2323
show_help() {
2424
cat << EOF
@@ -31,6 +31,8 @@ Usage: $(basename "$0") <options>
3131
-u, --charts-repo-url The GitHub Pages URL to the charts repo (default: https://<owner>.github.io/<repo>)
3232
-o, --owner The repo owner
3333
-r, --repo The repo name
34+
-n, --install-dir The Path to install the cr tool
35+
-i, --install-only Just install the cr tool
3436
EOF
3537
}
3638

@@ -41,6 +43,8 @@ main() {
4143
local owner=
4244
local repo=
4345
local charts_repo_url=
46+
local install_dir=
47+
local install_only=
4448

4549
parse_command_line "$@"
4650

@@ -151,6 +155,18 @@ parse_command_line() {
151155
exit 1
152156
fi
153157
;;
158+
-n|--install-dir)
159+
if [[ -n "${2:-}" ]]; then
160+
install_dir="$2"
161+
shift
162+
fi
163+
;;
164+
-i|--install-only)
165+
if [[ -n "${2:-}" ]]; then
166+
install_only="$2"
167+
shift
168+
fi
169+
;;
154170
*)
155171
break
156172
;;
@@ -174,6 +190,18 @@ parse_command_line() {
174190
if [[ -z "$charts_repo_url" ]]; then
175191
charts_repo_url="https://$owner.github.io/$repo"
176192
fi
193+
194+
if [[ -z "$install_dir" ]]; then
195+
local arch
196+
arch=$(uname -m)
197+
install_dir="$RUNNER_TOOL_CACHE/cr/$version/$arch"
198+
fi
199+
200+
if [[ -n "$install_only" ]]; then
201+
echo "Will install cr tool and not run it..."
202+
install_chart_releaser
203+
exit 0
204+
fi
177205
}
178206

179207
install_chart_releaser() {
@@ -182,21 +210,17 @@ install_chart_releaser() {
182210
exit 1
183211
fi
184212

185-
local arch
186-
arch=$(uname -m)
187-
188-
local cache_dir="$RUNNER_TOOL_CACHE/ct/$version/$arch"
189-
if [[ ! -d "$cache_dir" ]]; then
190-
mkdir -p "$cache_dir"
213+
if [[ ! -d "$install_dir" ]]; then
214+
mkdir -p "$install_dir"
191215

192-
echo "Installing chart-releaser..."
216+
echo "Installing chart-releaser on $install_dir..."
193217
curl -sSLo cr.tar.gz "https://github.com/helm/chart-releaser/releases/download/$version/chart-releaser_${version#v}_linux_amd64.tar.gz"
194-
tar -xzf cr.tar.gz -C "$cache_dir"
218+
tar -xzf cr.tar.gz -C "$install_dir"
195219
rm -f cr.tar.gz
196220
fi
197221

198222
echo 'Adding cr directory to PATH...'
199-
export PATH="$cache_dir:$PATH"
223+
export PATH="$install_dir:$PATH"
200224
}
201225

202226
lookup_latest_tag() {

0 commit comments

Comments
 (0)