Skip to content

Commit

Permalink
feat(packages): add meta data into the OCI artifacts (#186)
Browse files Browse the repository at this point in the history
The delivery jobs can utilize the meta data to publish TiUP packages,
etc...

Signed-off-by: wuhuizuo <wuhuizuo@126.com>

Signed-off-by: wuhuizuo <wuhuizuo@126.com>
  • Loading branch information
wuhuizuo authored Dec 25, 2023
1 parent 9bdebe2 commit 039eaa2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/packages.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ components:
src:
path: bin/tidb-server
tiup:
description: >
description: >-
TiDB is an open source distributed HTAP database compatible with the MySQL protocol.
entrypoint: tidb-server
- name: "br-{{ .Release.version }}-{{ .Release.os }}-{{ .Release.arch }}.tar.gz"
Expand All @@ -448,7 +448,7 @@ components:
path: bin/dumpling
tiup:
entrypoint: dumpling
description: >
description: >-
Dumpling is a CLI tool that helps you dump MySQL/TiDB data.
- name: "tidb-lightning-ctl-{{ .Release.version }}-{{ .Release.os }}-{{ .Release.arch }}.tar.gz"
files:
Expand Down
26 changes: 23 additions & 3 deletions packages/scripts/build-package-artifacts.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function parse_arguments() {
;;
o)
result_path=${OPTARG}
;;
;;
a)
need_package=true
;;
Expand Down Expand Up @@ -155,19 +155,39 @@ function archive() {
}

{{ if has .artifactory "package_repo" -}}
function prepare_artifact_config() {
local save_file="$1"

:> "$save_file"
yq -p json -o json -i '.os = "{{ .os }}"' "$save_file"
yq -p json -o json -i '.architecture = "{{ .arch }}"' "$save_file"
yq -p json -o json -i '.profile = "{{ .profile }}"' "$save_file"
yq -p json -o json -i '.version = "{{ .version }}"' "$save_file"
yq -p json -o json -i '.tiup = []' "$save_file"

{{- range (.artifacts | jq `map(select((.type == "file" or .type == null) and .tiup != null))`) }}
{{- with .tiup }}
yq -p json -o json -i '.tiup += {{ . | toJSON }}' "$save_file"
{{- end }}
yq -p json -o json -i '.tiup[-1].file = "{{ .name }}"' "$save_file"
{{- end }}
}
function push_files() {
local release_ws="$1"
local tag="{{ index .artifactory.tags 0 }}-{{ .profile }}_{{ .os }}_{{ .arch }}"
local destination="{{ .artifactory.package_repo }}:$tag"
prepare_artifact_config "$release_ws/artifact-config.json"
# You should login before call this script, default it use credential with docker `config`` file: ~/.docker/config.json
# Login steps:
# local registry=$(echo "${destination}" | cut -d/ -f)
# oras login -u ${ORAS_USER} -p ${ORAS_PASSWD} ${registry}
pushd "$release_ws"
oras push --artifact-type application/gzip ${destination}
oras push --artifact-type application/gzip --config artifact-config.json ${destination}
{{- range (.artifacts | jq `map(select(.type == "file" or .type == null))`) }}{{ printf " %s" .name }}{{- end }}
{{- range (.artifacts | jq `map(select(.type == "file" or .type == null))`) }}{{ printf " %s.sha256" .name }}{{- end }}
popd
Expand All @@ -190,7 +210,7 @@ function write_push_results() {
# local registry=$(echo "${destination}" | cut -d/ -f)
# oras login -u ${ORAS_USER} -p ${ORAS_PASSWD} ${registry}
digest="$(oras discover "${destination}" --distribution-spec v1.1-referrers-tag -o tree | cut -d@ -f2)"
cat <<EOF > "$result_file"
oci:
repo: {{ .artifactory.package_repo }}
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/gen-package-artifacts-with-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function main() {
yq -i ".os = \"$os\"" release-router.yaml
yq -i ".arch = \"$arch\"" release-router.yaml
yq -i ".profile = \"$profile\"" release-router.yaml
yq -i ".version = \"$version\"" release-router.yaml
yq -i ".steps = .steps[.profile]" release-router.yaml
yq -i ".steps = (.steps | map(select(.os == null or .os == \"$os\")))" release-router.yaml
yq -i ".steps = (.steps | map(select(.arch == null or .arch == \"$arch\")))" release-router.yaml
Expand Down

0 comments on commit 039eaa2

Please sign in to comment.