Skip to content

Commit

Permalink
use goreleaser hook to set the right version in plugin.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
vbehar committed May 11, 2020
1 parent 23c2af3 commit 68ec735
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 40 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,10 @@ jobs:
token: ${{ secrets.GH_TOKEN }}
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Next Version
id: nextversion
uses: ./.github/actions/autotag/
with:
dry_run: true
- name: Update plugin.yaml version
uses: mikefarah/yq@master
with:
cmd: yq w -i plugin.yaml 'version' "${{ steps.nextversion.outputs.version }}"
- name: Commit
uses: EndBug/add-and-commit@v4
with:
add: plugin.yaml
message: 'Release ${{ steps.nextversion.outputs.version }}'
ref: "release/${{ steps.nextversion.outputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Tag
uses: ./.github/actions/autotag/
with:
branch: "release/${{ steps.nextversion.outputs.version }}"
- name: Push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_TOKEN }}
branch: "release/${{ steps.nextversion.outputs.version }}"
tags: true
4 changes: 4 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Configuration file for http://goreleaser.com

before:
hooks:
- ./update_version.sh {{.Version}}

builds:
- goos:
- linux
Expand Down
33 changes: 14 additions & 19 deletions install_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,36 @@ if [ -n "${HELM_LINTER_PLUGIN_NO_INSTALL_HOOK}" ]; then
exit 0
fi

version="$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null)"
if [ -n "$version" ]; then
version="${version:1}"
else
version="$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)"
fi
echo "Downloading and installing helm3-unittest v${version} ..."
version="$(git describe --tags --exact-match 2>/dev/null)"
echo "Downloading and installing helm3-unittest ${version} ..."

url=""
if [ "$(uname)" = "Darwin" ]; then
url="https://github.com/vbehar/helm3-unittest/releases/download/v${version}/helm3-unittest_${version}_darwin_amd64.tar.gz"
url="https://github.com/vbehar/helm3-unittest/releases/download/${version}/helm3-unittest_${version:1}_darwin_amd64.tar.gz"
elif [ "$(uname)" = "Linux" ] ; then
if [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ]; then
url="https://github.com/vbehar/helm3-unittest/releases/download/v${version}/helm3-unittest_${version}_linux_arm64.tar.gz"
url="https://github.com/vbehar/helm3-unittest/releases/download/${version}/helm3-unittest_${version:1}_linux_arm64.tar.gz"
else
url="https://github.com/vbehar/helm3-unittest/releases/download/v${version}/helm3-unittest_${version}_linux_amd64.tar.gz"
url="https://github.com/vbehar/helm3-unittest/releases/download/${version}/helm3-unittest_${version:1}_linux_amd64.tar.gz"
fi
else
url="https://github.com/vbehar/helm3-unittest/releases/download/v${version}/helm3-unittest_${version}_windows_amd64.tar.gz"
url="https://github.com/vbehar/helm3-unittest/releases/download/${version}/helm3-unittest_${version:1}_windows_amd64.tar.gz"
fi

echo "$url"

mkdir -p "bin"
mkdir -p "releases/v${version}"
mkdir -p "releases/${version}"

# Download with curl if possible.
# shellcheck disable=SC2230
if [ -x "$(which curl 2>/dev/null)" ]; then
curl -sSL "${url}" -o "releases/v${version}.tar.gz"
curl -sSL "${url}" -o "releases/${version}.tar.gz"
else
wget -q "${url}" -O "releases/v${version}.tar.gz"
wget -q "${url}" -O "releases/${version}.tar.gz"
fi
tar xzf "releases/v${version}.tar.gz" -C "releases/v${version}"
mv "releases/v${version}/helm3-unittest" "bin/unittest" || \
mv "releases/v${version}/helm3-unittest.exe" "bin/unittest"
mv "releases/v${version}/plugin.yaml" .
mv "releases/v${version}/README.md" .
tar xzf "releases/${version}.tar.gz" -C "releases/${version}"
mv "releases/${version}/helm3-unittest" "bin/unittest" || \
mv "releases/${version}/helm3-unittest.exe" "bin/unittest"
mv "releases/${version}/plugin.yaml" .
mv "releases/${version}/README.md" .
1 change: 0 additions & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: "unittest"
version: 1.0.4
usage: "unittest for helm 3 charts"
description: "Unit test for helm 3 charts in YAML with ease to keep your chart functional
and robust."
Expand Down
5 changes: 5 additions & 0 deletions update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# script used by goreleaser - see .goreleaser.yml

echo "version: $1" >> plugin.yaml

0 comments on commit 68ec735

Please sign in to comment.