From 3f32e3fd5e658d058d5c5172519384efc6cfef83 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Thu, 24 Dec 2020 18:50:01 +0300 Subject: [PATCH] all: improve scripts --- .github/workflows/build.yml | 6 ++--- Makefile | 6 +++-- scripts/build-docker.sh | 2 +- scripts/build-release.sh | 32 ++++++++++++++++--------- {.githooks => scripts/hooks}/pre-commit | 0 5 files changed, 29 insertions(+), 17 deletions(-) rename {.githooks => scripts/hooks}/pre-commit (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d7586f54232..4a24de1a971 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,7 +55,7 @@ 'restore-keys': '${{ runner.os }}-node-' - 'name': 'Run make ci' 'shell': 'bash' - 'run': 'make ci' + 'run': 'make VERBOSE=1 ci' - 'name': 'Upload coverage' 'uses': 'codecov/codecov-action@v1' 'if': "success() && matrix.os == 'ubuntu-latest'" @@ -96,7 +96,7 @@ - 'name': 'Set up Snapcraft' 'run': 'sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft' - 'name': 'Run snapshot build' - 'run': 'make build-release' + 'run': 'make SIGN=0 VERBOSE=1 js-deps js-build build-release' 'docker': 'runs-on': 'ubuntu-latest' @@ -111,7 +111,7 @@ - 'name': 'Set up Docker Buildx' 'uses': 'docker/setup-buildx-action@v1' - 'name': 'Docker Buildx (build)' - 'run': 'make build-docker' + 'run': 'make VERBOSE=1 build-docker' 'notify': 'needs': diff --git a/Makefile b/Makefile index 5b9619b17f5..523968f45f3 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ GOPROXY = https://goproxy.cn,https://goproxy.io,direct GPG_KEY_PASSPHRASE = not-a-real-password NPM = npm NPM_FLAGS = --prefix $(CLIENT_DIR) +SIGN = 1 VERBOSE = 0 VERSION = v0.0.0 @@ -27,6 +28,7 @@ ENV = env\ GO='$(GO)'\ GOPROXY='$(GOPROXY)'\ PATH="$$PWD/bin:$$PATH"\ + SIGN='$(SIGN)'\ VERBOSE='$(VERBOSE)'\ VERSION='$(VERSION)'\ @@ -45,11 +47,11 @@ test: js-test go-test # expand to something like "C:/Program Files/Git/usr/bin/sh.exe". build-docker: ; $(ENV) "$(SHELL)" ./scripts/build-docker.sh -build-release: deps go-gen +build-release: deps js-build go-gen $(ENV) "$(SHELL)" ./scripts/build-release.sh clean: ; $(ENV) "$(SHELL)" ./scripts/clean.sh -init: ; git config core.hooksPath ./.githooks +init: ; git config core.hooksPath ./scripts/hooks js-build: ; $(NPM) $(NPM_FLAGS) run build-prod js-deps: ; $(NPM) $(NPM_FLAGS) ci diff --git a/scripts/build-docker.sh b/scripts/build-docker.sh index 7153a97c8fe..f3d0b524ab4 100644 --- a/scripts/build-docker.sh +++ b/scripts/build-docker.sh @@ -20,7 +20,7 @@ readonly version="$VERSION" export DOCKER_CLI_EXPERIMENTAL='enabled' readonly docker_platforms="\ -linux/386, +linux/386,\ linux/amd64,\ linux/arm/v6,\ linux/arm/v7,\ diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 12fac868be3..0f1508383a9 100644 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -15,6 +15,9 @@ then set -x fi +# By default, sign the packages, but allow users to skip that step. +readonly sign="${SIGN:-1}" + # Exit the script if a pipeline fails (-e), prevent accidental filename # expansion (-f), and consider undefined variables as errors (-u). set -e -f -u @@ -47,9 +50,13 @@ fi log "channel '$channel'" log "version '$version'" -# Require the gpg key and passphrase to be set. -readonly gpg_key_passphrase="$GPG_KEY_PASSPHRASE" -readonly gpg_key="$GPG_KEY" +# Require the gpg key and passphrase to be set if the signing is +# required. +if [ "$sign" = '1' ] +then + readonly gpg_key_passphrase="$GPG_KEY_PASSPHRASE" + readonly gpg_key="$GPG_KEY" +fi # The default distribution files directory is dist. readonly dist="${DIST:-dist}" @@ -143,14 +150,17 @@ build() { log "$build_output" - gpg\ - --default-key "$gpg_key"\ - --detach-sig\ - --passphrase "$gpg_key_passphrase"\ - --pinentry-mode loopback\ - -q\ - "$build_output"\ - ; + if [ "$sign" = '1' ] + then + gpg\ + --default-key "$gpg_key"\ + --detach-sig\ + --passphrase "$gpg_key_passphrase"\ + --pinentry-mode loopback\ + -q\ + "$build_output"\ + ; + fi # Prepare the build directory for archiving. cp ./CHANGELOG.md ./LICENSE.txt ./README.md "$build_dir" diff --git a/.githooks/pre-commit b/scripts/hooks/pre-commit similarity index 100% rename from .githooks/pre-commit rename to scripts/hooks/pre-commit