Skip to content

Commit da035b7

Browse files
committed
prepare helm 4 support
related #105 Signed-off-by: Markus Blaschke <[email protected]>
1 parent 265a5fd commit da035b7

File tree

13 files changed

+431
-37
lines changed

13 files changed

+431
-37
lines changed

.github/workflows/release-assets.yaml

Lines changed: 86 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ concurrency:
88
group: ${{ github.workflow }}-${{ github.ref }}
99
cancel-in-progress: false
1010

11+
env:
12+
RELEASE_TAG: ${{ github.ref_name }}
13+
14+
1115
jobs:
12-
release:
13-
name: "${{ matrix.task }}"
16+
executables:
17+
name: "assets/executables"
1418
runs-on: ubuntu-latest
15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
include:
19-
- task: release-assets-linux
20-
- task: release-assets-darwin
21-
- task: release-assets-windows
2219
steps:
2320
- uses: actions/checkout@v5
2421

@@ -28,9 +25,87 @@ jobs:
2825
- name: Setup go
2926
uses: ./.github/actions/setup-go
3027

31-
- name: Build
28+
- name: Build linux
29+
run: |
30+
make release-assets-linux
31+
32+
- name: Build darwin
33+
run: |
34+
make release-assets-darwin
35+
36+
- name: Build windows
37+
run: |
38+
make release-assets-windows
39+
40+
- name: Upload assets to release
41+
uses: svenstaro/upload-release-action@v2
42+
with:
43+
repo_token: ${{ secrets.GITHUB_TOKEN }}
44+
file: ./release-assets/*
45+
tag: ${{ github.ref }}
46+
overwrite: true
47+
file_glob: true
48+
49+
plugins:
50+
name: "assets/plugins"
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v5
54+
55+
- name: Setup runner
56+
uses: ./.github/actions/setup-runner
57+
58+
- name: Setup Helm
59+
uses: azure/setup-helm@4
60+
61+
- name: Set up ORAS
62+
uses: oras-project/[email protected]
63+
64+
- name: Build plugins
65+
run: |
66+
make plugins
67+
env:
68+
GITHUB_TAG: ${{ github.ref }}
69+
70+
- name: Login to DockerHub
71+
uses: docker/login-action@v3
72+
with:
73+
username: ${{ secrets.DOCKERHUB_USERNAME }}
74+
password: ${{ secrets.DOCKERHUB_TOKEN }}
75+
76+
- name: Login to Quay
77+
uses: docker/login-action@v3
78+
with:
79+
registry: quay.io
80+
username: ${{ secrets.QUAY_USERNAME }}
81+
password: ${{ secrets.QUAY_TOKEN }}
82+
83+
- name: Publish azure-tpl-cli
84+
run: |
85+
oras push \
86+
ghcr.io/${{ github.repository }}/azure-tpl-cli:${RELEASE_TAG} \
87+
ghcr.io/${{ github.repository }}/azure-tpl-cli:latest \
88+
--artifact-type application/vnd.helm.plugin.v1+json \
89+
azure-tpl-cli.tgz
90+
working-directory: release-assets/
91+
92+
- name: Publish azure-tpl-getter
93+
run: |
94+
oras push \
95+
ghcr.io/${{ github.repository }}/azure-tpl-getter:${RELEASE_TAG} \
96+
ghcr.io/${{ github.repository }}/azure-tpl-getter:latest \
97+
--artifact-type application/vnd.helm.plugin.v1+json \
98+
azure-tpl-getter.tgz
99+
working-directory: release-assets/
100+
101+
- name: Publish azure-tpl-legacy
32102
run: |
33-
make "${{ matrix.task }}"
103+
oras push \
104+
ghcr.io/${{ github.repository }}/azure-tpl-legacy:${RELEASE_TAG} \
105+
ghcr.io/${{ github.repository }}/azure-tpl-legacy:latest \
106+
--artifact-type application/vnd.helm.plugin.v1+json \
107+
azure-tpl-legacy.tgz
108+
working-directory: release-assets/
34109

35110
- name: Upload assets to release
36111
uses: svenstaro/upload-release-action@v2

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ lint: $(GOLANGCI_LINT_BIN)
6262
$(GOLANGCI_LINT_BIN):
6363
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(FIRST_GOPATH)/bin
6464

65+
#######################################
66+
# release assets
67+
#######################################
68+
.PHONY: plugins
69+
plugins: plugin/azure-tpl-legacy plugin/azure-tpl-cli plugin/azure-tpl-getter
70+
71+
plugin/%: $(SOURCE)
72+
echo 'package plugin $(call word-dot,$*,1)'
73+
rm -rf ./tmp
74+
mkdir -p ./tmp
75+
helm plugin package 'plugins/$(call word-dot,$*,1)' -d ./tmp --sign=false
76+
mv tmp/azure-tpl*.tgz 'release-assets/$(call word-dot,$*,1).tgz'
77+
rm -rf ./tmp
78+
6579
#######################################
6680
# release assets
6781
#######################################
File renamed without changes.

plugin.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ platformCommand:
3131
arch: arm64
3232
command: "$HELM_PLUGIN_DIR/helm-azure-tpl.exe"
3333
hooks:
34-
install: "bash $HELM_PLUGIN_DIR/helm-plugin-install.sh"
35-
update: "bash $HELM_PLUGIN_DIR/helm-plugin-install.sh"
36-
34+
install: "bash $HELM_PLUGIN_DIR/install.sh"
35+
update: "bash $HELM_PLUGIN_DIR/install.sh"
3736
downloaders:
3837
- command: "plugin.sh"
3938
protocols:

plugin4.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

plugins/azure-tpl-cli/install.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
HELM_AZURE_TPL_VERSION=$(sed -n -e 's/version:[ "]*\([^"]*\).*/\1/p' "${HELM_PLUGIN_DIR}/plugin.yaml")
6+
7+
HOST_OS=$(uname -s | tr '[:upper:]' '[:lower:]')
8+
HOST_ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
9+
10+
FILE_SUFFIX=""
11+
12+
case "${HOST_OS}" in
13+
cygwin*)
14+
HOST_OS="windows"
15+
FILE_SUFFIX=".exe"
16+
;;
17+
mingw*)
18+
HOST_OS="windows"
19+
FILE_SUFFIX=".exe"
20+
;;
21+
esac
22+
23+
case "$HOST_ARCH" in
24+
"x86_64")
25+
## translate to amd64
26+
HOST_ARCH="amd64"
27+
;;
28+
"aarch64")
29+
## translate to arm64
30+
HOST_ARCH="arm64"
31+
;;
32+
esac
33+
34+
PLUGIN_DOWNLOAD_FILE="helm-azure-tpl.${HOST_OS}.${HOST_ARCH}${FILE_SUFFIX}"
35+
PLUGIN_DOWNLOAD_URL="https://github.com/webdevops/helm-azure-tpl/releases/download/${HELM_AZURE_TPL_VERSION}/${PLUGIN_DOWNLOAD_FILE}"
36+
PLUGIN_TARGET_PATH="${HELM_PLUGIN_DIR}/helm-azure-tpl${FILE_SUFFIX}"
37+
38+
echo "starting download (via curl)"
39+
echo " platform: ${HOST_OS}/${HOST_ARCH}"
40+
echo " url: $PLUGIN_DOWNLOAD_URL"
41+
echo " target: $PLUGIN_TARGET_PATH"
42+
43+
rm -f -- "$PLUGIN_TARGET_PATH"
44+
curl --fail --location "$PLUGIN_DOWNLOAD_URL" -o "$PLUGIN_TARGET_PATH"
45+
if [ "$?" -ne 0 ]; then
46+
>&2 echo "[ERROR] failed to download plugin executable"
47+
exit 1
48+
fi
49+
50+
if [[ ! -f "$PLUGIN_TARGET_PATH" ]]; then
51+
>&2 echo "[ERROR] installation of executable failed, please report issue"
52+
exit 1
53+
fi
54+
55+
chmod +x "$PLUGIN_TARGET_PATH"
56+
57+
echo "successfully downloaded executable"

plugins/azure-tpl-cli/plugin.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
apiVersion: v1
3+
type: cli/v1
4+
name: "azure-tpl-cli"
5+
version: "0.62.0"
6+
runtime: subprocess
7+
config:
8+
usage: azure-tpl
9+
shortHelp: helm-azure-tpl is a helm plugin for Azure template functions.
10+
runtimeConfig:
11+
platformCommand:
12+
- os: windows
13+
command: >-
14+
cmd.exe /D /E:ON /V:ON /C !HELM_PLUGIN_DIR!\helm-azure-tpl.exe
15+
- os: linux
16+
command: "$HELM_PLUGIN_DIR/helm-azure-tpl"
17+
- os: darwin
18+
command: "$HELM_PLUGIN_DIR/helm-azure-tpl"
19+
- command: "$HELM_PLUGIN_DIR/helm-azure-tpl"
20+
platformHooks:
21+
install:
22+
- os: linux
23+
command: "$HELM_PLUGIN_DIR/install.sh"
24+
- os: darwin
25+
command: "$HELM_PLUGIN_DIR/install.sh"
26+
update:
27+
- os: linux
28+
command: "$HELM_PLUGIN_DIR/install.sh"
29+
- os: darwin
30+
command: "$HELM_PLUGIN_DIR/install.sh"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
HELM_AZURE_TPL_VERSION=$(sed -n -e 's/version:[ "]*\([^"]*\).*/\1/p' "${HELM_PLUGIN_DIR}/plugin.yaml")
6+
7+
HOST_OS=$(uname -s | tr '[:upper:]' '[:lower:]')
8+
HOST_ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
9+
10+
FILE_SUFFIX=""
11+
12+
case "${HOST_OS}" in
13+
cygwin*)
14+
HOST_OS="windows"
15+
FILE_SUFFIX=".exe"
16+
;;
17+
mingw*)
18+
HOST_OS="windows"
19+
FILE_SUFFIX=".exe"
20+
;;
21+
esac
22+
23+
case "$HOST_ARCH" in
24+
"x86_64")
25+
## translate to amd64
26+
HOST_ARCH="amd64"
27+
;;
28+
"aarch64")
29+
## translate to arm64
30+
HOST_ARCH="arm64"
31+
;;
32+
esac
33+
34+
PLUGIN_DOWNLOAD_FILE="helm-azure-tpl.${HOST_OS}.${HOST_ARCH}${FILE_SUFFIX}"
35+
PLUGIN_DOWNLOAD_URL="https://github.com/webdevops/helm-azure-tpl/releases/download/${HELM_AZURE_TPL_VERSION}/${PLUGIN_DOWNLOAD_FILE}"
36+
PLUGIN_TARGET_PATH="${HELM_PLUGIN_DIR}/helm-azure-tpl${FILE_SUFFIX}"
37+
38+
echo "starting download (via curl)"
39+
echo " platform: ${HOST_OS}/${HOST_ARCH}"
40+
echo " url: $PLUGIN_DOWNLOAD_URL"
41+
echo " target: $PLUGIN_TARGET_PATH"
42+
43+
rm -f -- "$PLUGIN_TARGET_PATH"
44+
curl --fail --location "$PLUGIN_DOWNLOAD_URL" -o "$PLUGIN_TARGET_PATH"
45+
if [ "$?" -ne 0 ]; then
46+
>&2 echo "[ERROR] failed to download plugin executable"
47+
exit 1
48+
fi
49+
50+
if [[ ! -f "$PLUGIN_TARGET_PATH" ]]; then
51+
>&2 echo "[ERROR] installation of executable failed, please report issue"
52+
exit 1
53+
fi
54+
55+
chmod +x "$PLUGIN_TARGET_PATH"
56+
57+
echo "successfully downloaded executable"

plugins/azure-tpl-getter/plugin.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
println() {
6+
>&2 echo "$*"
7+
}
8+
9+
if [[ -n "$GITHUB_ACTION" ]]; then
10+
println "::group::$4"
11+
else
12+
println " "
13+
fi
14+
15+
println "executing azure-tpl for \"$4\":"
16+
"${HELM_PLUGIN_DIR}/helm-azure-tpl" apply --stdout "$4"
17+
EXIT_CODE="$?"
18+
19+
if [[ -n "$GITHUB_ACTION" ]]; then
20+
println "::endgroup::"
21+
else
22+
println " "
23+
fi
24+
25+
exit "$EXIT_CODE"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
apiVersion: v1
3+
type: getter/v1
4+
name: "azure-tpl-getter"
5+
version: "0.62.0"
6+
runtime: subprocess
7+
config:
8+
protocols:
9+
- "azuretpl"
10+
- "azure-tpl"
11+
runtimeConfig:
12+
protocolCommands:
13+
- protocols:
14+
- "azuretpl"
15+
- "azure-tpl"
16+
platformCommand:
17+
- os: windows
18+
command: >-
19+
cmd.exe /D /E:ON /V:ON /C !HELM_PLUGIN_DIR!\plugin.cmd
20+
- os: linux
21+
command: "plugin.sh"
22+
- os: darwin
23+
command: "plugin.sh"
24+
- command: "plugin.sh"
25+
platformHooks:
26+
install:
27+
- os: linux
28+
command: "$HELM_PLUGIN_DIR/install.sh"
29+
- os: darwin
30+
command: "$HELM_PLUGIN_DIR/install.sh"
31+
- command: "$HELM_PLUGIN_DIR/install.sh"
32+
update:
33+
- os: linux
34+
command: "$HELM_PLUGIN_DIR/install.sh"
35+
- os: darwin
36+
command: "$HELM_PLUGIN_DIR/install.sh"
37+
- command: "$HELM_PLUGIN_DIR/install.sh"

0 commit comments

Comments
 (0)