Skip to content

Commit

Permalink
all: improve scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Dec 24, 2020
1 parent 2d38b81 commit 3f32e3f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down Expand Up @@ -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'
Expand All @@ -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':
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -27,6 +28,7 @@ ENV = env\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$$PWD/bin:$$PATH"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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,\
Expand Down
32 changes: 21 additions & 11 deletions scripts/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
Expand Down
File renamed without changes.

0 comments on commit 3f32e3f

Please sign in to comment.