From 23387e4364e5a8c374d72f9ef27c931c01c2fc4c Mon Sep 17 00:00:00 2001 From: John Stairs Date: Fri, 6 Oct 2023 17:59:10 +0000 Subject: [PATCH] Update official publishing --- .devcontainer/devcontainer-on-create.sh | 2 ++ .github/workflows/pr-ci.yml | 13 +++++++++++++ Makefile | 3 ++- cli/.goreleaser.yaml | 3 ++- cli/Dockerfile | 4 ++-- cli/internal/install/helm.go | 4 +++- scripts/build-images.sh | 2 +- 7 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.devcontainer/devcontainer-on-create.sh b/.devcontainer/devcontainer-on-create.sh index cfd73af7..789baf4b 100755 --- a/.devcontainer/devcontainer-on-create.sh +++ b/.devcontainer/devcontainer-on-create.sh @@ -21,3 +21,5 @@ if [ -d "/home/.host/.azure/" ]; then # logged in on the host. cp -r /home/.host/.azure/ ~/.azure/ fi + +make install-cli || true diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index b4294ccc..5e94112d 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -99,6 +99,19 @@ jobs: set -euo pipefail make -s -j 8 + - name: Publish official images + if: startsWith(github.ref, 'refs/tags/') + env: + TYGER_ENVIRONMENT_NAME: ${{ steps.set-variables.outputs.TYGER_ENVIRONMENT_NAME }} + run: | + source /opt/conda/etc/profile.d/conda.sh + conda activate /opt/conda/envs/tyger + + set -euo pipefail + cd /workspaces/tyger + + make publish-official-images + - name: Build Windows Binaries run: | set -euo pipefail diff --git a/Makefile b/Makefile index bb56ff62..8c5e9032 100644 --- a/Makefile +++ b/Makefile @@ -247,7 +247,8 @@ install-cli: tag=$$(git describe --tags 2> /dev/null || echo "0.0.0") CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install -ldflags="-s -w \ -X main.version=$${tag} \ - -X github.com/microsoft/tyger/cli/internal/install.containerRegistry=$${official_container_registry}" \ + -X github.com/microsoft/tyger/cli/internal/install.containerRegistry=$${official_container_registry} \ + -X github.com/microsoft/tyger/cli/internal/install.containerImageTag=$${tag}" \ ./cmd/tyger ./cmd/buffer-sidecar ./cmd/tyger-proxy cli-ready: install-cli diff --git a/cli/.goreleaser.yaml b/cli/.goreleaser.yaml index 4c6521ed..133047d9 100644 --- a/cli/.goreleaser.yaml +++ b/cli/.goreleaser.yaml @@ -10,8 +10,9 @@ builds: - CGO_ENABLED=0 ldflags: - -s -w - - -X main.version={{.Tag}} + - -X main.version={{ .Tag }} - -X github.com/microsoft/tyger/cli/internal/install.containerRegistry={{ .Env.OFFICIAL_CONTAINER_REGISTRY }} + - -X github.com/microsoft/tyger/cli/internal/install.containerImageTag={{ .Tag }} goos: - linux - windows diff --git a/cli/Dockerfile b/cli/Dockerfile index 45789837..96052f84 100644 --- a/cli/Dockerfile +++ b/cli/Dockerfile @@ -6,11 +6,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /go/src/app COPY ./go.mod . -ARG COMMIT_HASH="a" +ARG TYGER_VERSION="a" RUN --mount=type=cache,target=/go/pkg/mod/cache go mod download COPY . . RUN --mount=type=cache,target=/root/.cache/go-build \ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.commit=${COMMIT_HASH}" -v -o /go/bin/dist/linux/amd64/buffer-sidecar ./cmd/buffer-sidecar \ + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version=${TYGER_VERSION}" -v -o /go/bin/dist/linux/amd64/buffer-sidecar ./cmd/buffer-sidecar \ && upx /go/bin/dist/linux/amd64/buffer-sidecar FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 as runtime-builder diff --git a/cli/internal/install/helm.go b/cli/internal/install/helm.go index c4417002..b576bc4f 100644 --- a/cli/internal/install/helm.go +++ b/cli/internal/install/helm.go @@ -25,7 +25,9 @@ import ( ) var ( - // set during build but we provide defaults so that there is some value when debugging + // Set during build but we provide defaults so that there is some value when debugging. + // We will need to update these from time to time. Alternatively, you can set the registry + // values using the --set command-line arugment. containerRegistry string = "tyger.azurecr.io" containerImageTag string = "v0.1.0-49-g5526c35" ) diff --git a/scripts/build-images.sh b/scripts/build-images.sh index 2f85e2d7..5dc5055d 100755 --- a/scripts/build-images.sh +++ b/scripts/build-images.sh @@ -79,7 +79,7 @@ repo_root_dir="$(dirname "$0")/.." function build_and_push() { echo "Building image ${local_tag}..." - docker build -f "${dockerfile_path}" -t "${local_tag}" --target "${target}" $quiet "${build_context}" >/dev/null + docker build -f "${dockerfile_path}" -t "${local_tag}" --target "${target}" --build-arg TYGER_VERSION="${image_tag}" $quiet "${build_context}" >/dev/null if [[ -z "${push:-}" ]]; then return 0