diff --git a/Makefile b/Makefile index 7c8f205f..b4823bb7 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ V1API = 0 # into BUILD_RELEASE_DEPS_0, and so both frontend and backend # dependencies are fetched and the frontend is built. Otherwise, if # FRONTEND_PREBUILT is 1, only backend dependencies are fetched and the -# frontend isn't reuilt. +# frontend isn't rebuilt. # # TODO(a.garipov): We could probably do that from .../build-release.sh, # but that would mean either calling make from inside make or diff --git a/bamboo-specs/release.yaml b/bamboo-specs/release.yaml index 7dd9a859..e3451bdc 100644 --- a/bamboo-specs/release.yaml +++ b/bamboo-specs/release.yaml @@ -10,6 +10,12 @@ 'dockerGo': 'adguard/golang-ubuntu:5.0' 'stages': +- 'Build frontend': + 'manual': false + 'final': false + 'jobs': + - 'Build frontend' + - 'Make release': 'manual': false 'final': false @@ -40,11 +46,41 @@ 'jobs': - 'Publish to GitHub Releases' -'Make release': +'Build frontend': 'docker': 'image': '${bamboo.dockerGo}' 'volumes': '${system.YARN_DIR}': '${bamboo.cacheYarn}' + 'key': 'BF' + 'other': + 'clean-working-dir': true + 'tasks': + - 'checkout': + 'force-clean-build': true + - 'script': + 'interpreter': 'SHELL' + 'scripts': + - | + #!/bin/sh + + set -e -f -u -x + + # Explicitly checkout the revision that we need. + git checkout "${bamboo.repository.revision.number}" + + make js-build + 'artifacts': + - 'name': 'AdGuardHome frontend' + 'pattern': 'build*/**' + 'shared': true + 'required': true + 'requirements': + - 'adg-docker': 'true' + +'Make release': + 'docker': + 'image': '${bamboo.dockerGo}' + 'volumes': '${system.GO_CACHE_DIR}': '${bamboo.cacheGo}' '${system.GO_PKG_CACHE_DIR}': '${bamboo.cacheGoPkg}' 'key': 'MR' @@ -72,6 +108,7 @@ make\ CHANNEL=${bamboo.channel}\ GPG_KEY_PASSPHRASE=${bamboo.gpgPassword}\ + FRONTEND_PREBUILT=1\ VERBOSE=1\ build-release # TODO(a.garipov): Use more fine-grained artifact rules. diff --git a/scripts/make/build-release.sh b/scripts/make/build-release.sh index 072dfe7a..1c8cb9c0 100644 --- a/scripts/make/build-release.sh +++ b/scripts/make/build-release.sh @@ -109,17 +109,17 @@ log "checking tools" # Make sure we fail gracefully if one of the tools we need is missing. Use # alternatives when available. -sha256sum_cmd='sha256sum' -for tool in gpg gzip sed "$sha256sum_cmd" snapcraft tar zip +use_shasum='0' +for tool in gpg gzip sed sha256sum snapcraft tar zip do if ! command -v "$tool" > /dev/null then - if [ "$tool" = "$sha256sum_cmd" ] && command -v 'shasum' > /dev/null + if [ "$tool" = 'sha256sum' ] && command -v 'shasum' > /dev/null then - # macOS doesn't have sha256sum installed by default, but - # it does have shasum. + # macOS doesn't have sha256sum installed by default, but it does + # have shasum. log 'replacing sha256sum with shasum -a 256' - sha256sum_cmd='shasum -a 256' + use_shasum='1' else log "pieces don't fit, '$tool' not found" @@ -127,7 +127,7 @@ do fi fi done -readonly sha256sum_cmd +readonly use_shasum # Data section. Arrange data into space-separated tables for read -r to read. # Use a hyphen for missing values. @@ -332,15 +332,40 @@ log "$build_archive" log "calculating checksums" +# calculate_checksums uses the previously detected SHA-256 tool to calculate +# checksums. Do not use find with -exec, since shasum requires arguments. +calculate_checksums() { + if [ "$use_shasum" -eq '0' ] + then + sha256sum "$@" + else + shasum -a 256 "$@" + fi +} + # Calculate the checksums of the files in a subshell with a different working # directory. Don't use ls, because files matching one of the patterns may be # absent, which will make ls return with a non-zero status code. +# +# TODO(a.garipov): Consider calculating these as the build goes. ( + set +f + cd "./${dist}" - find . ! -name . -prune \( -name '*.tar.gz' -o -name '*.zip' \)\ - -exec "$sha256sum_cmd" {} +\ - > ./checksums.txt + : > ./checksums.txt + + for archive in ./*.zip ./*.tar.gz + do + # Make sure that we don't try to calculate a checksum for a glob pattern + # that matched no files. + if [ ! -f "$archive" ] + then + continue + fi + + calculate_checksums "$archive" >> ./checksums.txt + done ) log "writing versions"