Skip to content

Commit

Permalink
build: Unify release code in one place (#2679)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolajb authored Oct 3, 2024
1 parent 4980877 commit 15677be
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 51 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ jobs:
shell: bash
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: make release
- name: Release
env:
DOCKER_USERNAME: ${{ secrets.NEXUS_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
GIT_TAG: ${{ env.GIT_TAG }}
run: devbox run -- make release
run: devbox run -- just release

- name: Release OCI artifact
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: devbox run -- just release-oci ${{ env.GIT_TAG }}
GIT_TAG: ${{ env.GIT_TAG }}
run: devbox run -- just release-oci
16 changes: 0 additions & 16 deletions hack/build-archive.sh

This file was deleted.

30 changes: 26 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
set dotenv-load

registry := "registry-1.docker.io"
git_tag := env_var_or_default("GIT_TAG", "v0.0.0")

registry := "docker.io"
org_name := "mesosphere"
repository := org_name / "kommander-applications"
include_file := justfile_directory() / ".include-airgapped"
exclude_file := justfile_directory() / ".exclude-airgapped"
git_operator_version := env("GIT_OPERATOR_VERSION", "latest")

release-oci tag tmp_dir=`mktemp --directory`:
rsync --info=name --archive --recursive --files-from={{ include_file }} --exclude-from={{ exclude_file }} {{ justfile_directory() }} {{ tmp_dir }}
cd {{ tmp_dir }} && echo "${DOCKER_PASSWORD}" | oras push --password-stdin --username "${DOCKER_USERNAME}" --verbose {{ registry }}/{{ repository }}:{{ tag }} .
s3_path := "dkp" / git_tag
s3_bucket := "downloads.mesosphere.io"
s3_uri := "s3://" / s3_bucket / s3_path
s3_acl := "bucket-owner-full-control"
archive_name := "kommander-applications-" + git_tag+ ".tar.gz"
published_url := "https://downloads.d2iq.com" / s3_path / archive_name

release tmp_dir=`mktemp --directory`: (_prepare-archive tmp_dir)
aws s3 cp --acl {{ s3_acl }} {{ archive_name }} {{ s3_uri }}
@echo "Published to {{ published_url }}"

release-oci tmp_dir=`mktemp --directory`: (_prepare-files-for-a-bundle tmp_dir)
cd {{ tmp_dir }} && echo "${DOCKER_PASSWORD}" | oras push --password-stdin --username "${DOCKER_USERNAME}" --verbose {{ registry }}/{{ repository }}:{{ git_tag }} .

service_version:=`ls services/git-operator/ | grep -E "v?[[:digit:]]\.[[:digit:]]\.[[:digit:]]"`
service_dir:=justfile_directory() / "services/git-operator" / service_version
Expand All @@ -19,3 +31,13 @@ git-operator-fetch-manifests tmp_dir=`mktemp --directory`:
# HACK: strip SHA off git-operator image
kustomize build {{ tmp_dir }}/default | sed -r 's/(image\: docker\.io\/mesosphere\/git-operator\:v[0-9]+\.[0-9]+.[0-9]+)\@sha256\:.*?$/\1/g' >{{ service_dir }}/git-operator-manifests/all.yaml
[ -z "$(git diff --name-only services/git-operator)" ] || echo -e '\n\n\nWARNING: Git Operator manifests have changed!\nEdit {{ service_dir }}/additional-images.txt to ensure additional images are up to date.\n\n'

_prepare-archive dir: (_prepare-files-for-a-bundle dir)
tar -cvzf {{ justfile_directory() }}/{{ archive_name }} -C {{ dir }} .

_cleanup:
rm {{ archive_name }}

_prepare-files-for-a-bundle output_dir:
rsync --archive --recursive --files-from={{ include_file }} --exclude-from={{ exclude_file }} {{ justfile_directory() }} {{ output_dir }}
yq 'del(.resources[] | select(. == "ai-navigator-repos.yaml"))' --inplace {{ output_dir }}/common/helm-repositories/kustomization.yaml
1 change: 0 additions & 1 deletion make/all.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ include $(INCLUDE_DIR)repo.mk
include $(INCLUDE_DIR)docker.mk
include $(INCLUDE_DIR)flux.mk
include $(INCLUDE_DIR)tools.mk
include $(INCLUDE_DIR)release.mk
include $(INCLUDE_DIR)pre-commit.mk
include $(INCLUDE_DIR)validate.mk
include $(INCLUDE_DIR)go.mk
Expand Down
27 changes: 0 additions & 27 deletions make/release.mk

This file was deleted.

0 comments on commit 15677be

Please sign in to comment.