diff --git a/Makefile b/Makefile index 96da814e..79fac90f 100755 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -TARGETS := $(shell ls scripts | grep -vE 'clean|run|help|release|build-moby|run-moby') +TARGETS := $(shell ls scripts | grep -vE 'clean|run|help|release*|build-moby|run-moby') .dapper: @echo Downloading dapper @@ -53,12 +53,12 @@ vmware: .dapper mkdir -p dist APPEND_SYSTEM_IMAGES="rancher/os-openvmtools:10.2.5-3" \ VMWARE_APPEND="console=tty1 console=ttyS0,115200n8 printk.devkmsg=on rancher.autologin=tty1 rancher.autologin=ttyS0 rancher.autologin=ttyS1 panic=10" \ - ./.dapper vmware-release 2>&1 | tee dist/release.log + ./.dapper release-vmware 2>&1 | tee dist/release.log hyperv: .dapper mkdir -p dist APPEND_SYSTEM_IMAGES="rancher/os-hypervvmtools:v4.14.85-rancher-1" \ - ./.dapper hyperv-release 2>&1 | tee dist/release.log + ./.dapper release-hyperv 2>&1 | tee dist/release.log help: @./scripts/help diff --git a/scripts/hyperv-release b/scripts/hyperv-release deleted file mode 100755 index f5245122..00000000 --- a/scripts/hyperv-release +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -ex - -cd $(dirname $0)/.. - - -source ./scripts/version -./scripts/release - -ISO_NAME="rancheros-autoformat.iso" - -mkdir -p /tmp/dist && mv ./dist/* /tmp/dist/ -mkdir -p ./dist/hyperv && mv /tmp/dist/* ./dist/hyperv/ -mkdir -p ./dist/artifacts && cp ./dist/hyperv/artifacts/rancheros.iso ./dist/artifacts/${ISO_NAME} -echo "gsutil cp dist/artifacts/${ISO_NAME} gs://releases.rancher.com/os/latest/hyperv/${ISO_NAME}" -echo "gsutil cp dist/artifacts/${ISO_NAME} gs://releases.rancher.com/os/${VERSION}/hyperv/${ISO_NAME}" diff --git a/scripts/package-iso b/scripts/package-iso index 5764f7cc..ecfc28ea 100755 --- a/scripts/package-iso +++ b/scripts/package-iso @@ -7,6 +7,7 @@ cd $(dirname $0)/.. ARTIFACTS=$(pwd)/dist/artifacts CD=${BUILD}/cd +rm -rf ${CD}/ ISO=${ARTIFACTS}/$(echo ${DISTRIB_ID} | tr '[:upper:]' '[:lower:]').iso CHECKSUM=iso-checksums.txt diff --git a/scripts/release b/scripts/release index 24b00c82..54ebaaa4 100755 --- a/scripts/release +++ b/scripts/release @@ -2,78 +2,8 @@ set -ex cd $(dirname $0)/.. + source ./scripts/version -export REPO_VERSION=$VERSION -if [[ -n "$DIRTY" || -z "$GIT_TAG" ]]; then - export REPO_VERSION=master -fi -export COMPRESS="gzip -9" +./scripts/release-build -./scripts/ci - -# from scripts/ci -echo PREPARE -./scripts/prepare -echo PACKAGE -./scripts/package - -#if [[ "$ARCH" == "" || "$ARCH" == "amd64" ]]; then -## make generated changelog -#lastrelease=$(hub release | grep -v rc | head -n1 | tr -d ' \r\n') -#git log --format="%s: %b" ${lastrelease}..${VERSION} | grep "Merge pull" | sed 's/.*\(#.*\) from .*:\(.*\)/* \1: \2/g' > dist/artifacts/changelog.txt -#fi - -CHECKSUM="dist/checksums.txt" -rm -f $CHECKSUM - -cat scripts/hosting/rancheros.ipxe | sed "s/latest/${VERSION}/g" > dist/artifacts/rancheros.ipxe - -echo "github-release release --user rancher --repo os --tag ${VERSION} --pre-release --draft" > dist/publish.sh -chmod 755 dist/publish.sh - -touch dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh -chmod 755 dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh - -for file in $(ls dist/artifacts/); do - case $file in - *"installer.tar" | "Dockerfile"*) - ;; - "initrd-"*) - echo "github-release upload --user rancher --repo os --tag ${VERSION} --file ./dist/artifacts/${file} --name initrd" >> dist/publish.sh - echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/initrd" >> ./dist/publish_gss_latest.sh - echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/initrd" >> ./dist/publish_gss_${VERSION}.sh - ;; - "vmlinuz-"*) - echo "github-release upload --user rancher --repo os --tag ${VERSION} --file ./dist/artifacts/${file} --name vmlinuz" >> dist/publish.sh - echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/vmlinuz" >> ./dist/publish_gss_latest.sh - echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/vmlinuz" >> ./dist/publish_gss_${VERSION}.sh - ;; - *) - echo "github-release upload --user rancher --repo os --tag ${VERSION} --file ./dist/artifacts/${file} --name ${file}" >> dist/publish.sh - echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/${file}" >> ./dist/publish_gss_latest.sh - echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/${file}" >> ./dist/publish_gss_${VERSION}.sh - ;; - esac - - #checksums - pushd . - cd dist/artifacts - for algo in sha256 md5; do - echo "$algo: $(${algo}sum $file)" >> ../../$CHECKSUM - done - popd -done -echo "github-release upload --user rancher --repo os --tag ${VERSION} --file dist/release.log --name release.log" >> dist/publish.sh - -echo "github-release upload --user rancher --repo os --tag ${VERSION} --file ${CHECKSUM} --name checksums.txt" >> dist/publish.sh - -echo >> dist/publish.sh - -cat dist/images | sed 's/^/docker push /' >> dist/publish.sh - -echo "--- Run dist/publish.sh" -cat dist/publish.sh - -echo "--- Run dist/publish_gss.sh" -cat dist/publish_gss_latest.sh -cat dist/publish_gss_${VERSION}.sh +./scripts/release-${ARCH} diff --git a/scripts/release-amd64 b/scripts/release-amd64 new file mode 100755 index 00000000..7622f3a4 --- /dev/null +++ b/scripts/release-amd64 @@ -0,0 +1,62 @@ +#!/bin/bash +set -ex + +cd $(dirname $0)/.. + +source ./scripts/version +./scripts/release-build + +CHECKSUM="dist/checksums.txt" +rm -f $CHECKSUM + +cat scripts/hosting/rancheros.ipxe | sed "s/latest/${VERSION}/g" > dist/artifacts/rancheros.ipxe + +echo "github-release release --user rancher --repo os --tag ${VERSION} --pre-release --draft" > dist/publish.sh +chmod 755 dist/publish.sh + +touch dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh +chmod 755 dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh + +for file in $(ls dist/artifacts/); do + case $file in + *"installer.tar" | "Dockerfile"*) + ;; + "initrd-"*) + echo "github-release upload --user rancher --repo os --tag ${VERSION} --file ./dist/artifacts/${file} --name initrd" >> dist/publish.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/initrd" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/initrd" >> ./dist/publish_gss_${VERSION}.sh + ;; + "vmlinuz-"*) + echo "github-release upload --user rancher --repo os --tag ${VERSION} --file ./dist/artifacts/${file} --name vmlinuz" >> dist/publish.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/vmlinuz" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/vmlinuz" >> ./dist/publish_gss_${VERSION}.sh + ;; + *) + echo "github-release upload --user rancher --repo os --tag ${VERSION} --file ./dist/artifacts/${file} --name ${file}" >> dist/publish.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/${file}" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/${file}" >> ./dist/publish_gss_${VERSION}.sh + ;; + esac + + #checksums + pushd . + cd dist/artifacts + for algo in sha256 md5; do + echo "$algo: $(${algo}sum $file)" >> ../../$CHECKSUM + done + popd +done +echo "github-release upload --user rancher --repo os --tag ${VERSION} --file dist/release.log --name release.log" >> dist/publish.sh + +echo "github-release upload --user rancher --repo os --tag ${VERSION} --file ${CHECKSUM} --name checksums.txt" >> dist/publish.sh + +echo >> dist/publish.sh + +cat dist/images | sed 's/^/docker push /' >> dist/publish.sh + +echo "--- Run dist/publish.sh" +cat dist/publish.sh + +echo "--- Run dist/publish_gss.sh" +cat dist/publish_gss_latest.sh +cat dist/publish_gss_${VERSION}.sh diff --git a/scripts/release-arm64 b/scripts/release-arm64 new file mode 100755 index 00000000..21b7d0a7 --- /dev/null +++ b/scripts/release-arm64 @@ -0,0 +1,29 @@ +#!/bin/bash +set -ex + +cd $(dirname $0)/.. + +source ./scripts/version +./scripts/release-build + +touch dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh +chmod 755 dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh + +for file in $(ls dist/artifacts/); do + case $file in + *"installer.tar" | "Dockerfile"*) + ;; + "initrd-"*) + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/arm64/initrd" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/arm64/initrd" >> ./dist/publish_gss_${VERSION}.sh + ;; + "vmlinuz-"*) + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/arm64/vmlinuz" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/arm64/vmlinuz" >> ./dist/publish_gss_${VERSION}.sh + ;; + *) + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/arm64/${file}" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/arm64/${file}" >> ./dist/publish_gss_${VERSION}.sh + ;; + esac +done diff --git a/scripts/release-build b/scripts/release-build new file mode 100755 index 00000000..9ca36708 --- /dev/null +++ b/scripts/release-build @@ -0,0 +1,18 @@ +#!/bin/bash +set -ex + +cd $(dirname $0)/.. +source ./scripts/version +export REPO_VERSION=$VERSION +if [[ -n "$DIRTY" || -z "$GIT_TAG" ]]; then + export REPO_VERSION=master +fi +export COMPRESS="gzip -9" + +./scripts/ci + +# from scripts/ci +echo PREPARE +./scripts/prepare +echo PACKAGE +./scripts/package diff --git a/scripts/release-hyperv b/scripts/release-hyperv new file mode 100755 index 00000000..f60488a7 --- /dev/null +++ b/scripts/release-hyperv @@ -0,0 +1,23 @@ +#!/bin/bash +set -ex + +cd $(dirname $0)/.. + +source ./scripts/version +./scripts/release-build + +touch dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh +chmod 755 dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh + +for file in $(ls dist/artifacts/); do + case $file in + "initrd-"*) + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/hyperv/initrd" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/hyperv/initrd" >> ./dist/publish_gss_${VERSION}.sh + ;; + "rancheros.iso" | "rootfs.tar.gz") + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/hyperv/${file}" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/hyperv/${file}" >> ./dist/publish_gss_${VERSION}.sh + ;; + esac +done diff --git a/scripts/release-vmware b/scripts/release-vmware new file mode 100755 index 00000000..b00b8bab --- /dev/null +++ b/scripts/release-vmware @@ -0,0 +1,76 @@ +#!/bin/bash +set -ex + +cd $(dirname $0)/.. + +touch .make-vmware + +source ./scripts/version +./scripts/release-build + +touch dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh +chmod 755 dist/publish_gss_${VERSION}.sh dist/publish_gss_latest.sh + +if [ "$VMWARE_AUTOFORMAT" = 1 ]; then + echo "gsutil cp dist/artifacts/rancheros.iso gs://releases.rancher.com/os/latest/vmware/rancheros-autoformat.iso" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/rancheros.iso gs://releases.rancher.com/os/${VERSION}/vmware/rancheros-autoformat.iso" >> ./dist/publish_gss_${VERSION}.sh + echo "gsutil cp dist/artifacts/rancheros.iso gs://releases.rancher.com/os/latest/rancheros-vmware.iso" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/rancheros.iso gs://releases.rancher.com/os/${VERISION}/rancheros-vmware.iso" >> ./dist/publish_gss_${VERSION}.sh + exit 0 +fi + +if [ "$VMWARE_APPEND" != "" ]; then + echo "--append ${VMWARE_APPEND}" + APPEND_PARAM="--append \"${VMWARE_APPEND}\"" +fi + +mkdir -p /tmp/dist/openstack/latest ./dist/vmware + +cat > /tmp/dist/openstack/latest/user_data << EOF +#!/bin/bash +set -e + +trap "poweroff" EXIT + +mount -t 9p -o trans=virtio,version=9p2000.L config-2 /mnt + +touch log +sleep 5 +openvt -s -- tail -f log & +ros install \ + -d /dev/vda \ + ${APPEND_PARAM} \ + -f \ + --no-reboot >log 2>&1 + +touch /mnt/success +EOF + +rm -f /tmp/dist/success + +qemu-img create -f qcow2 ./dist/vmware/vmdk.img 8G +kvm -curses \ + -drive if=virtio,file=./dist/vmware/vmdk.img \ + -cdrom ./dist/artifacts/rancheros.iso \ + -m 2048 \ + -fsdev local,id=conf,security_model=none,path=/tmp/dist \ + -device virtio-9p-pci,fsdev=conf,mount_tag=config-2 \ + -device virtio-rng-pci + +[ -f /tmp/dist/success ] + +echo "Converting ./dist/rancheros.vmdk" +qemu-img convert -f qcow2 -O vmdk ./dist/vmware/vmdk.img ./dist/artifacts/rancheros.vmdk + +for file in $(ls dist/artifacts/); do + case $file in + "initrd-"*) + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/vmware/initrd" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/vmware/initrd" >> ./dist/publish_gss_${VERSION}.sh + ;; + "rancheros.iso" | "rancheros.vmdk" | "rootfs.tar.gz") + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/latest/vmware/${file}" >> ./dist/publish_gss_latest.sh + echo "gsutil cp dist/artifacts/${file} gs://releases.rancher.com/os/${VERSION}/vmware/${file}" >> ./dist/publish_gss_${VERSION}.sh + ;; + esac +done diff --git a/scripts/vmware-release b/scripts/vmware-release deleted file mode 100755 index 6773b184..00000000 --- a/scripts/vmware-release +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -set -ex - -cd $(dirname $0)/.. - -touch .make-vmware - -source ./scripts/version -./scripts/release - -if [ "$VMWARE_AUTOFORMAT" = 1 ]; then - ISO_NAME="rancheros-autoformat.iso" - mkdir -p /tmp/dist && mv ./dist/* /tmp/dist/ - mkdir -p ./dist/vmware && mv /tmp/dist/* ./dist/vmware/ - mkdir -p ./dist/artifacts && cp ./dist/vmware/artifacts/rancheros.iso ./dist/artifacts/${ISO_NAME} - echo "gsutil cp dist/artifacts/${ISO_NAME} gs://releases.rancher.com/os/latest/vmware/${ISO_NAME}" - echo "gsutil cp dist/artifacts/${ISO_NAME} gs://releases.rancher.com/os/${VERSION}/vmware/${ISO_NAME}" - exit 0 -fi - -ROOT_FS_NAME="rootfs.tar.gz" -VMDK_NAME="rancheros.vmdk" -ISO_NAME="rancheros.iso" - -if [ "$VMWARE_APPEND" != "" ]; then - echo "--append ${VMWARE_APPEND}" - APPEND_PARAM="--append \"${VMWARE_APPEND}\"" -fi - -mkdir -p /tmp/dist/openstack/latest && mv ./dist/* /tmp/dist/ - -# create rancheros-vmware.vmdk -if [ -e /tmp/dist/vmdk.img ]; then - rm -rf /tmp/dist/vmdk.img -fi - -cat > /tmp/dist/openstack/latest/user_data << EOF -#!/bin/bash -set -e - -trap "poweroff" EXIT - -mount -t 9p -o trans=virtio,version=9p2000.L config-2 /mnt - -touch log -sleep 5 -openvt -s -- tail -f log & -ros install \ - -d /dev/vda \ - ${APPEND_PARAM} \ - -f \ - --no-reboot >log 2>&1 - -touch /mnt/success -EOF - -rm -f /tmp/dist/success - -mkdir -p ./dist/vmware && mv /tmp/dist/* ./dist/vmware/ -mkdir -p ./dist/artifacts - -qemu-img create -f qcow2 ./dist/vmware/vmdk.img 8G -kvm -curses \ - -drive if=virtio,file=./dist/vmware/vmdk.img \ - -cdrom ./dist/vmware/artifacts/rancheros.iso \ - -m 2048 \ - -fsdev local,id=conf,security_model=none,path=./dist/vmware \ - -device virtio-9p-pci,fsdev=conf,mount_tag=config-2 \ - -device virtio-rng-pci - -[ -f ./dist/vmware/success ] - -echo Converting ./dist/${VMDK_NAME} -qemu-img convert -f qcow2 -O vmdk ./dist/vmware/vmdk.img ./dist/artifacts/${VMDK_NAME} - -cp ./dist/vmware/artifacts/rancheros.iso ./dist/artifacts/${ISO_NAME} && \ - cp ./dist/vmware/artifacts/rootfs.tar.gz ./dist/artifacts/${ROOT_FS_NAME} && \ - cp ./dist/vmware/artifacts/${INITRD} ./dist/artifacts/${INITRD} - -for file in $(ls dist/artifacts/); do - case $file in - "initrd-"*) - echo "gsutil cp dist/artifacts/${INITRD} gs://releases.rancher.com/os/latest/vmware/${INITRD}" >> ./dist/publish_gss_latest.sh - echo "gsutil cp dist/artifacts/${INITRD} gs://releases.rancher.com/os/${VERSION}/vmware/${INITRD}" >> ./dist/publish_gss_${VERSION}.sh - ;; - "rancheros.iso") - echo "gsutil cp dist/artifacts/${ISO_NAME} gs://releases.rancher.com/os/latest/vmware/${ISO_NAME}" >> ./dist/publish_gss_latest.sh - echo "gsutil cp dist/artifacts/${ISO_NAME} gs://releases.rancher.com/os/${VERSION}/vmware/${ISO_NAME}" >> ./dist/publish_gss_${VERSION}.sh - ;; - "rancheros.vmdk") - echo "gsutil cp dist/artifacts/${VMDK_NAME} gs://releases.rancher.com/os/latest/vmware/${VMDK_NAME}" >> ./dist/publish_gss_latest.sh - echo "gsutil cp dist/artifacts/${VMDK_NAME} gs://releases.rancher.com/os/${VERSION}/vmware/${VMDK_NAME}" >> ./dist/publish_gss_${VERSION}.sh - ;; - "rootfs.tar.gz") - echo "gsutil cp dist/artifacts/${ROOT_FS_NAME} gs://releases.rancher.com/os/latest/vmware/${ROOT_FS_NAME}" >> ./dist/publish_gss_latest.sh - echo "gsutil cp dist/artifacts/${ROOT_FS_NAME} gs://releases.rancher.com/os/${VERSION}/vmware/${ROOT_FS_NAME}" >> ./dist/publish_gss_${VERSION}.sh - ;; - esac -done - -chmod 755 ./dist/*.sh