make update-ui-version (#578)
* make update-ui-version * make update-ui-version: default branch main * make update-ui-version: actually checkout commit
This commit is contained in:
1 parent
f24e478542
commit
560c727bcf
5 files changed
+94
-30
No files matched your search
@@ -35,13 +35,38 @@ bin: build-ui
|
|||||||
fmt:
|
fmt:
|
||||||
goimports -w $$(find . -name '*.go' | grep -v pb.go | grep -v pb.gw.go)
|
goimports -w $$(find . -name '*.go' | grep -v pb.go | grep -v pb.gw.go)
|
||||||
|
|
||||||
|
# Set env for all UI targets.
|
||||||
|
UI_TARGETS := update-ui-version build-ui build-ui-ifne
|
||||||
|
# Note the extra .tmp path segment in UI_CLONE_DIR is significant and required.
|
||||||
|
$(UI_TARGETS): export UI_CLONE_DIR := internal/ui/.tmp/boundary-ui
|
||||||
|
$(UI_TARGETS): export UI_VERSION_FILE := internal/ui/VERSION
|
||||||
|
$(UI_TARGETS): export UI_ASSETS_FILE := internal/ui/assets.go
|
||||||
|
$(UI_TARGETS): export UI_DEFAULT_BRANCH := main
|
||||||
|
$(UI_TARGETS): export UI_CURRENT_COMMIT := $(shell head -n1 < "$(UI_VERSION_FILE)" | cut -d' ' -f1)
|
||||||
|
$(UI_TARGETS): export UI_COMMITISH ?=
|
||||||
|
|
||||||
|
update-ui-version:
|
||||||
|
@if [ -z "$(UI_COMMITISH)" ]; then \
|
||||||
|
echo "==> Setting UI version to latest commit on branch '$(UI_DEFAULT_BRANCH)'"; \
|
||||||
|
export UI_COMMITISH="$(UI_DEFAULT_BRANCH)"; \
|
||||||
|
else \
|
||||||
|
echo "==> Setting to latest commit matching '$(UI_COMMITISH)'"; \
|
||||||
|
fi; \
|
||||||
|
./scripts/uiclone.sh && ./scripts/uiupdate.sh
|
||||||
|
|
||||||
build-ui:
|
build-ui:
|
||||||
@scripts/uigen.sh
|
@if [ -z "$(UI_COMMITISH)" ]; then \
|
||||||
|
echo "==> Building default UI version from $(UI_VERSION_FILE): $(UI_CURRENT_COMMIT)"; \
|
||||||
|
export UI_COMMITISH="$(UI_CURRENT_COMMIT)"; \
|
||||||
|
else \
|
||||||
|
echo "==> Building custom UI version $(UI_COMMITISH)"; \
|
||||||
|
fi; \
|
||||||
|
./scripts/uiclone.sh && ./scripts/uigen.sh
|
||||||
|
|
||||||
build-ui-ifne:
|
build-ui-ifne:
|
||||||
ifeq (,$(wildcard internal/ui/assets.go))
|
ifeq (,$(wildcard internal/ui/assets.go))
|
||||||
@echo "==> No UI assets found, building..."
|
@echo "==> No UI assets found, building..."
|
||||||
@scripts/uigen.sh
|
@$(MAKE) build-ui
|
||||||
else
|
else
|
||||||
@echo "==> UI assets found, use build-ui target to update"
|
@echo "==> UI assets found, use build-ui target to update"
|
||||||
endif
|
endif
|
||||||
@@ -119,7 +144,7 @@ test-ci: install-go
|
|||||||
install-go:
|
install-go:
|
||||||
./ci/goinstall.sh
|
./ci/goinstall.sh
|
||||||
|
|
||||||
.PHONY: api tools gen migrations proto website ci-config ci-verify
|
.PHONY: api tools gen migrations proto website ci-config ci-verify set-ui-version
|
||||||
|
|
||||||
.NOTPARALLEL:
|
.NOTPARALLEL:
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1,2 +1,4 @@
|
|||||||
31f7b575a981f92629dfe1ba8006054ae8b22eff Merge pull request #311 from hashicorp/release
|
31f7b575a981f92629dfe1ba8006054ae8b22eff Merge pull request #311 from hashicorp/release
|
||||||
# Above commit is used for production builds.
|
# This file determines the version of the UI to embed in the boundary binary.
|
||||||
|
# Update this file by running 'make update-ui-version' from the root of this repo.
|
||||||
|
# Set UI_COMMITISH when running the above target to update to a specific version.
|
||||||
Executable
+29
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$UI_COMMITISH" ]; then
|
||||||
|
echo "Must set UI_COMMITISH"; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$UI_CLONE_DIR" ]; then
|
||||||
|
echo "Must set UI_CLONE_DIR"; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$UI_VERSION_FILE" ]; then
|
||||||
|
echo "Must set UI_CLONE_DIR"; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
tempdir="$(dirname "${UI_CLONE_DIR}")"
|
||||||
|
|
||||||
|
mkdir -p "${tempdir}"
|
||||||
|
echo "*" > "${tempdir}/.gitignore"
|
||||||
|
|
||||||
|
if ! [ -d "${UI_CLONE_DIR}/.git" ]; then
|
||||||
|
git clone https://github.com/hashicorp/boundary-ui "${UI_CLONE_DIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "${UI_CLONE_DIR}"
|
||||||
|
git reset --hard
|
||||||
|
git fetch origin "${UI_COMMITISH}"
|
||||||
|
git checkout "${UI_COMMITISH}"
|
||||||
+11
-26
@@ -2,41 +2,26 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
ui_commitish="${UI_COMMITISH:-develop}"
|
if [ -z "$UI_CLONE_DIR" ]; then
|
||||||
|
echo "Must set UI_CLONE_DIR"; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
targetdir="internal/ui"
|
if [ -z "$UI_ASSETS_FILE" ]; then
|
||||||
shafile="${targetdir}/VERSION"
|
echo "Must set UI_ASSETS_FILE"; exit 1
|
||||||
shafileabs="$(pwd)/${shafile}"
|
|
||||||
tempdir="${targetdir}/source"
|
|
||||||
uirepodir="${tempdir}/boundary-ui"
|
|
||||||
mkdir -p "${tempdir}"
|
|
||||||
echo "*" > "${tempdir}/.gitignore"
|
|
||||||
|
|
||||||
if ! [ -d "${uirepodir}/.git" ]; then
|
|
||||||
git clone https://github.com/hashicorp/boundary-ui "${uirepodir}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
cd "${uirepodir}"
|
cd "$UI_CLONE_DIR"
|
||||||
git reset --hard
|
|
||||||
git fetch origin "${ui_commitish}"
|
|
||||||
git checkout "${ui_commitish}"
|
|
||||||
if ! docker-compose -f docker-compose-embedding.yml run build; then
|
if ! docker-compose -f docker-compose-embedding.yml run build; then
|
||||||
echo "==> UI build failed."
|
echo "==> UI build failed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
git log -n1 --pretty=oneline > "${shafileabs}"
|
|
||||||
echo "# Above commit is used for production builds." >> "${shafileabs}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
uidir="${uirepodir}/ui/core/dist"
|
uidir="${UI_CLONE_DIR}/ui/core/dist"
|
||||||
|
|
||||||
target="${targetdir}/assets.go"
|
go-bindata -fs -o "$UI_ASSETS_FILE.tmp" -pkg ui -prefix "${uidir}" "${uidir}" "${uidir}/assets"
|
||||||
|
|
||||||
go-bindata -fs -o "${target}.tmp" -pkg ui -prefix "${uidir}" "${uidir}" "${uidir}/assets"
|
printf "// +build ui\n" > "$UI_ASSETS_FILE"
|
||||||
|
cat "$UI_ASSETS_FILE.tmp" >> "$UI_ASSETS_FILE"
|
||||||
printf "// +build ui\n" > "${target}"
|
rm "$UI_ASSETS_FILE.tmp"
|
||||||
cat "${target}.tmp" >> "${target}"
|
|
||||||
rm "${target}.tmp"
|
|
||||||
|
|
||||||
rm -rf "$tempdir"
|
|
||||||
Executable
+23
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$UI_VERSION_FILE" ]; then
|
||||||
|
echo "Must set UI_VERSION_FILE"; exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$UI_CLONE_DIR" ]; then
|
||||||
|
echo "Must set UI_CLONE_DIR"; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shafileabs="$(pwd)/${UI_VERSION_FILE}"
|
||||||
|
cd "${UI_CLONE_DIR}"
|
||||||
|
V="$(git log -n1 --pretty=oneline)"
|
||||||
|
echo "==> Setting UI version to: $V"
|
||||||
|
|
||||||
|
# Write the version file.
|
||||||
|
{
|
||||||
|
echo "$V"
|
||||||
|
echo "# This file determines the version of the UI to embed in the boundary binary."
|
||||||
|
echo "# Update this file by running 'make update-ui-version' from the root of this repo."
|
||||||
|
echo "# Set UI_COMMITISH when running the above target to update to a specific version."
|
||||||
|
} > "${shafileabs}"
|
||||||
Reference in new issue
Block a user