From ac1c4ba3833743fe0e63c3b3e60a13bdbc8399cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20N=C3=BCtzi?= Date: Sun, 21 Apr 2024 18:56:04 +0200 Subject: [PATCH] fix: Add release tag creation correction :anchor: --- .github/workflows/release.yml | 5 ++-- githooks/.goreleaser-small.yaml | 1 + githooks/.goreleaser.yaml | 1 + tests/steps/step-146.sh | 45 +++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100755 tests/steps/step-146.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da6cd010..700aa440 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -140,9 +140,8 @@ jobs: RELEASE_TAG: ${{ steps.getTag.outputs.releaseTag }} TRIGGER_TAG: ${{ steps.getTag.outputs.triggerTag }} run: | - # go releaser already pushed release tag but it always - # does that on `main` which is wrong so we force update to the commit where it was - git push origin -f "$RELEASE_TAG" + # goreleaser already pushed release tag but do it always. + git push origin "$RELEASE_TAG" git push origin "githooks/$RELEASE_TAG" git push -f origin ":$TRIGGER_TAG" diff --git a/githooks/.goreleaser-small.yaml b/githooks/.goreleaser-small.yaml index 01bd7bb6..433e2109 100644 --- a/githooks/.goreleaser-small.yaml +++ b/githooks/.goreleaser-small.yaml @@ -72,6 +72,7 @@ release: owner: gabyx name: githooks prerelease: auto + target_commitish: "{{ .Commit }}" # Use these values for you own gitea instance... # gitea_urls: # api: "https://git.company.com/api/v1" diff --git a/githooks/.goreleaser.yaml b/githooks/.goreleaser.yaml index 9a5f22a3..d96dfe68 100644 --- a/githooks/.goreleaser.yaml +++ b/githooks/.goreleaser.yaml @@ -92,6 +92,7 @@ release: owner: gabyx name: githooks prerelease: auto + target_commitish: "{{ .Commit }}" # Use these values for you own gitea instance... # gitea_urls: # api: "https://git.company.com/api/v1" diff --git a/tests/steps/step-146.sh b/tests/steps/step-146.sh new file mode 100755 index 00000000..a95d6add --- /dev/null +++ b/tests/steps/step-146.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Test: +# Run install.sh script. +# shellcheck disable=SC2015 + +set -u + +TEST_DIR=$(cd "$(dirname "$0")/.." && pwd) +# shellcheck disable=SC1091 + +. "$TEST_DIR/general.sh" + +init_step + +if [ -n "${GH_COVERAGE_DIR:-}" ]; then + echo "Test cannot run for coverage." + exit 249 +fi + +# mkdir "$GH_TEST_TMP/test-146" && cd "$GH_TEST_TMP/test-146" && +# git clone --single-branch --branch v3.0.0-rc1 http://github.com/gabyx/githooks.git && +# cd githooks && +# git fetch origin refs/tags/v2.10.0:refs/tags/v2.10.0 && +# git checkout -b feature/v3 || exit 1 + +# Install with current script the version 2.10.0 on the `main` branch. +"$GH_SCRIPTS/install.sh" --version 2.10.0 -- \ + \ + --clone-branch "feature/v3" || { + echo "Could not download install.sh from 'main' and install." + exit 1 +} + +# Enable this once pre-release is out on main. +# Update to version 3 and greater, which should fail due to guard. +OUT=$("$GH_INSTALL_BIN_DIR/cli" update --use-pre-release --yes) +# shellcheck disable=SC2181 +if [ $? -eq 0 ] || ! echo "$OUT" | grep -iE "Too much changed. Please uninstall this version"; then + echo "Install should fail because update from v2 to v3 is guarded." + echo "$OUT" + exit 1 +fi + +# Uninstall right away again. +"$GH_INSTALL_BIN_DIR"/cli uninstaller || exit 1