From 00791964f33fdc2cd30d899e52f7f368dd4dafba Mon Sep 17 00:00:00 2001 From: Shohei Maeda <11495867+smaeda-ks@users.noreply.github.com> Date: Thu, 12 May 2022 14:57:23 +0900 Subject: [PATCH] Use HashiCorp Releases API to get latest version (#8) * Use HashiCorp Releases API to get latest version * move `orbs` stanza to top-level --- src/@orb.yml | 5 ++--- src/commands/install.yml | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/@orb.yml b/src/@orb.yml index 2282945..ef19dc3 100755 --- a/src/@orb.yml +++ b/src/@orb.yml @@ -9,6 +9,5 @@ description: | display: source_url: https://github.com/smaeda-ks/orb-hashicorp-vault-cli -# If your orb requires other orbs, you can import them like this. Otherwise remove the "orbs" stanza. -# orbs: -# hello: circleci/hello-build@0.0.5 +orbs: + jq: circleci/jq@2.2.0 diff --git a/src/commands/install.yml b/src/commands/install.yml index 6c4834e..6bc493d 100755 --- a/src/commands/install.yml +++ b/src/commands/install.yml @@ -9,6 +9,7 @@ parameters: description: Directory in which to install vault type: string steps: + - jq/install - run: command: | # Quietly try to make the install directory. @@ -35,7 +36,7 @@ steps: if [ ! "$PARAM_VAULT_VERSION" = "latest" ]; then export VAULT_VER_STRING="$PARAM_VAULT_VERSION" else - PARAM_VAULT_VERSION=$(basename $(curl -fs -o /dev/null -w %{redirect_url} https://github.com/hashicorp/vault/releases/latest) | sed 's/v//') + PARAM_VAULT_VERSION=$(curl -fs https://api.releases.hashicorp.com/v1/releases/vault/latest | jq -r '.version') export VAULT_VER_STRING="$PARAM_VAULT_VERSION" fi