From 030fcfe0e8efc43cf936c6dd1742bfb34351b872 Mon Sep 17 00:00:00 2001 From: Mateusz Urbanek Date: Thu, 31 Oct 2024 15:42:58 +0100 Subject: [PATCH] fix: move gpg to file Signed-off-by: Mateusz Urbanek --- .github/workflows/release.yaml | 12 ++++-------- hack/gpg.sh | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100755 hack/gpg.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e607a25..c1a2c01 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,14 +23,10 @@ jobs: ffb60bb8-8422-4d3b-95a1-b20700fb5232 > GPG_PASSPHRASE - name: Prepare GPG key run: | - gpg_dir=.cr-gpg - mkdir "$gpg_dir" - keyring="$gpg_dir/secring.gpg" - base64 -d <<< "$GPG_KEYRING_BASE64" > "$keyring" - passphrase_file="$gpg_dir/passphrase" - echo "$GPG_PASSPHRASE" > "$passphrase_file" - echo "CR_PASSPHRASE_FILE=$passphrase_file" >> "$GITHUB_ENV" - echo "CR_KEYRING=$keyring" >> "$GITHUB_ENV" + ./hack/gpg.sh \ + "${GPG_KEYRING_BASE64}" \ + "${GPG_PASSPHRASE}" \ + "${GITHUB_ENV}" - uses: azure/setup-helm@v4 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/hack/gpg.sh b/hack/gpg.sh new file mode 100755 index 0000000..8a7a867 --- /dev/null +++ b/hack/gpg.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -eou + +GPG_KEYRING_BASE64="$1" +GPG_PASSPHRASE="$2" +GITHUB_ENV="$3" + +gpg_dir=.cr-gpg +rm -rf "$gpg_dir" +mkdir "$gpg_dir" +keyring="$gpg_dir/secring.gpg" +base64 -d <<< "${GPG_KEYRING_BASE64:?Keyring not set or empty}" > "$keyring" +passphrase_file="$gpg_dir/passphrase" +echo -n "${GPG_PASSPHRASE:?Passphrase not set or empty}" > "$passphrase_file" +echo "CR_PASSPHRASE_FILE=$passphrase_file" >> "$GITHUB_ENV" +echo "CR_KEYRING=$keyring" >> "$GITHUB_ENV"