From 5a56dc413164d6a40da15ddfb903ef9c6f1e5557 Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Thu, 28 Apr 2022 22:40:38 -0300 Subject: [PATCH 1/2] feat: new install anf run script - move away from deprecated git.io - support distribution - verify checksums and signature closes #3074 Signed-off-by: Carlos A Becker --- www/docs/ci/circle.md | 2 +- www/docs/ci/drone.md | 2 +- www/docs/ci/jenkins.md | 4 ++-- www/docs/ci/semaphore.md | 2 +- www/docs/ci/travis.md | 4 ++-- www/docs/install.md | 19 ++++++++++++++++ www/docs/static/install | 48 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 74 insertions(+), 7 deletions(-) create mode 100755 www/docs/static/install diff --git a/www/docs/ci/circle.md b/www/docs/ci/circle.md index 3091260b185..bd79c4d5cf3 100644 --- a/www/docs/ci/circle.md +++ b/www/docs/ci/circle.md @@ -21,5 +21,5 @@ jobs: - image: cimg/go:1.18 steps: - checkout - - run: curl -sL https://git.io/goreleaser | bash + - run: curl -sL https://goreleaser.com/static/install | bash ``` diff --git a/www/docs/ci/drone.md b/www/docs/ci/drone.md index 5ef7162476c..a3ee5cf0d69 100644 --- a/www/docs/ci/drone.md +++ b/www/docs/ci/drone.md @@ -105,7 +105,7 @@ pipeline: image: golang:1.10 secrets: [github_token] commands: - curl -sL https://git.io/goreleaser | bash + curl -sfL https://goreleaser.com/static/install | bash when: event: tag ``` diff --git a/www/docs/ci/jenkins.md b/www/docs/ci/jenkins.md index 624cd5de7b5..4c6fa8b74c5 100644 --- a/www/docs/ci/jenkins.md +++ b/www/docs/ci/jenkins.md @@ -29,9 +29,9 @@ pipeline { } steps { - sh 'curl -sL https://git.io/goreleaser | bash' + sh 'curl -sfL https://goreleaser.com/static/install | bash' } } } } -``` \ No newline at end of file +``` diff --git a/www/docs/ci/semaphore.md b/www/docs/ci/semaphore.md index 1aa4084368c..58115c489d6 100644 --- a/www/docs/ci/semaphore.md +++ b/www/docs/ci/semaphore.md @@ -63,7 +63,7 @@ blocks: jobs: - name: goreleaser commands: - - curl -sL https://git.io/goreleaser | bash + - curl -sfL https://goreleaser.com/static/install | bash ``` The following YAML file, `createSecret.yml` creates a new secret item that is diff --git a/www/docs/ci/travis.md b/www/docs/ci/travis.md index fb9438faec7..e86d3085177 100644 --- a/www/docs/ci/travis.md +++ b/www/docs/ci/travis.md @@ -19,7 +19,7 @@ services: script: - go test ./... # replace this with your test script - - curl -sfL https://git.io/goreleaser | sh -s -- check # check goreleaser config for deprecations + - curl -sfL https://goreleaser.com/static/install | sh -s -- check # check goreleaser config for deprecations after_success: # Docker login is required if you want to push Docker images. @@ -36,7 +36,7 @@ after_success: deploy: - provider: script skip_cleanup: true - script: curl -sL https://git.io/goreleaser | bash + script: curl -sfL https://goreleaser.com/static/install | bash on: tags: true condition: $TRAVIS_OS_NAME = linux diff --git a/www/docs/install.md b/www/docs/install.md index 07e36a1eb65..51ba53cdafa 100644 --- a/www/docs/install.md +++ b/www/docs/install.md @@ -118,6 +118,25 @@ Below you can find the steps for each of them. go install github.com/goreleaser/goreleaser@latest ``` +### bash script + +This might be useful if you need to run it in a CI or Makefile. +Note that the script will try to download the latest version, verify its +checksums and signagures (if cosign is installed), and run it. + +=== "OSS" + ```sh + curl -sfL https://goreleaser.com/static/install | bash + ``` + +=== "Pro" + ```sh + curl -sfL https://goreleaser.com/static/install | DISTRIBUTION=pro bash + ``` + +You can also set a `VERSION` variable to specify a version instead of using +latest. + ### manually === "OSS" diff --git a/www/docs/static/install b/www/docs/static/install new file mode 100755 index 00000000000..34b6d120c4c --- /dev/null +++ b/www/docs/static/install @@ -0,0 +1,48 @@ +#!/bin/sh +set -e + +if test "$DISTRIBUTION" = "pro"; then + echo "Using Pro distribution..." + RELEASES_URL="https://github.com/goreleaser/goreleaser-pro/releases" + FILE_BASENAME="goreleaser-pro" +else + echo "Using the OSS distribution..." + RELEASES_URL="https://github.com/goreleaser/goreleaser/releases" + FILE_BASENAME="goreleaser" +fi + +test -z "$VERSION" && VERSION="$(curl -sfL -o /dev/null -w %{url_effective} "$RELEASES_URL/latest" | + rev | + cut -f1 -d'/'| + rev)" + +test -z "$VERSION" && { + echo "Unable to get goreleaser version." >&2 + exit 1 +} + +test -z "$TMPDIR" && TMPDIR="$(mktemp -d)" +export TAR_FILE="$TMPDIR/${FILE_BASENAME}_$(uname -s)_$(uname -m).tar.gz" + +( + cd "$TMPDIR" + echo "Downloading GoReleaser $VERSION..." + curl -sfLo "$TAR_FILE" \ + "$RELEASES_URL/download/$VERSION/${FILE_BASENAME}_$(uname -s)_$(uname -m).tar.gz" + curl -sfLo "checksums.txt" "$RELEASES_URL/download/$VERSION/checksums.txt" + curl -sfLo "checksums.txt.sig" "$RELEASES_URL/download/$VERSION/checksums.txt.sig" + echo "Verifying checksums..." + sha256sum --ignore-missing --quiet --check checksums.txt + if command -v cosign >/dev/null 2>&1; then + echo "Verifying signatures..." + COSIGN_EXPERIMENTAL=1 cosign verify-blob \ + --signature checksums.txt.sig \ + checksums.txt + else + echo "Could not verify signatures, cosign is not installed." + fi +) + +tar -xf "$TAR_FILE" -C "$TMPDIR" +"${TMPDIR}/goreleaser" "$@" + From a33571005e12e76c4f5bca3b21ef3913c8748fa7 Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Thu, 28 Apr 2022 22:48:53 -0300 Subject: [PATCH 2/2] fix: rename script Signed-off-by: Carlos A Becker --- www/docs/ci/circle.md | 2 +- www/docs/ci/drone.md | 2 +- www/docs/ci/jenkins.md | 2 +- www/docs/ci/semaphore.md | 2 +- www/docs/ci/travis.md | 4 ++-- www/docs/install.md | 11 +++++++++-- www/docs/static/{install => run} | 0 7 files changed, 15 insertions(+), 8 deletions(-) rename www/docs/static/{install => run} (100%) diff --git a/www/docs/ci/circle.md b/www/docs/ci/circle.md index bd79c4d5cf3..12d6306c0b8 100644 --- a/www/docs/ci/circle.md +++ b/www/docs/ci/circle.md @@ -21,5 +21,5 @@ jobs: - image: cimg/go:1.18 steps: - checkout - - run: curl -sL https://goreleaser.com/static/install | bash + - run: curl -sfL https://goreleaser.com/static/run | bash ``` diff --git a/www/docs/ci/drone.md b/www/docs/ci/drone.md index a3ee5cf0d69..988a798c85a 100644 --- a/www/docs/ci/drone.md +++ b/www/docs/ci/drone.md @@ -105,7 +105,7 @@ pipeline: image: golang:1.10 secrets: [github_token] commands: - curl -sfL https://goreleaser.com/static/install | bash + curl -sfL https://goreleaser.com/static/run | bash when: event: tag ``` diff --git a/www/docs/ci/jenkins.md b/www/docs/ci/jenkins.md index 4c6fa8b74c5..c4e419001b8 100644 --- a/www/docs/ci/jenkins.md +++ b/www/docs/ci/jenkins.md @@ -29,7 +29,7 @@ pipeline { } steps { - sh 'curl -sfL https://goreleaser.com/static/install | bash' + sh 'curl -sfL https://goreleaser.com/static/run | bash' } } } diff --git a/www/docs/ci/semaphore.md b/www/docs/ci/semaphore.md index 58115c489d6..dc02c16a775 100644 --- a/www/docs/ci/semaphore.md +++ b/www/docs/ci/semaphore.md @@ -63,7 +63,7 @@ blocks: jobs: - name: goreleaser commands: - - curl -sfL https://goreleaser.com/static/install | bash + - curl -sfL https://goreleaser.com/static/run | bash ``` The following YAML file, `createSecret.yml` creates a new secret item that is diff --git a/www/docs/ci/travis.md b/www/docs/ci/travis.md index e86d3085177..10bfb8f1549 100644 --- a/www/docs/ci/travis.md +++ b/www/docs/ci/travis.md @@ -19,7 +19,7 @@ services: script: - go test ./... # replace this with your test script - - curl -sfL https://goreleaser.com/static/install | sh -s -- check # check goreleaser config for deprecations + - curl -sfL https://goreleaser.com/static/run | bash -s -- check # check goreleaser config for deprecations after_success: # Docker login is required if you want to push Docker images. @@ -36,7 +36,7 @@ after_success: deploy: - provider: script skip_cleanup: true - script: curl -sfL https://goreleaser.com/static/install | bash + script: curl -sfL https://goreleaser.com/static/run | bash on: tags: true condition: $TRAVIS_OS_NAME = linux diff --git a/www/docs/install.md b/www/docs/install.md index 51ba53cdafa..e9b1c887c8d 100644 --- a/www/docs/install.md +++ b/www/docs/install.md @@ -126,17 +126,24 @@ checksums and signagures (if cosign is installed), and run it. === "OSS" ```sh - curl -sfL https://goreleaser.com/static/install | bash + curl -sfL https://goreleaser.com/static/run | bash ``` === "Pro" ```sh - curl -sfL https://goreleaser.com/static/install | DISTRIBUTION=pro bash + curl -sfL https://goreleaser.com/static/run | DISTRIBUTION=pro bash ``` You can also set a `VERSION` variable to specify a version instead of using latest. +You can also pass flags and args to GoReleaser: + +```bash +curl -sfL https://goreleaser.com/static/run | + VERSION=__VERSION__ DISTRIBUTION=oss bash -s -- check +``` + ### manually === "OSS" diff --git a/www/docs/static/install b/www/docs/static/run similarity index 100% rename from www/docs/static/install rename to www/docs/static/run