1
0
mirror of https://github.com/rancher/cli.git synced 2026-02-05 18:48:50 +01:00
Files
cli/scripts/package
Enrico Candino 192a95e4ed [v2.9] Migrate from Drone to Github Actions, remove Dapper and add Darwin/arm64 support (#362)
* enabled gofmt linter, added lint scripts, removed dapper from Makefile

* added build (with arm64 support), package steps, and fossa job

* github tag, and envs

* upload assets

* removed dapper and google cloud storage

* moved checkout steps

* removed drone.yml

* requested changes

- removed extra Test step
- added check for run on PRs
- added FOSSA check on release

* moved fossa in its own workflow

* remove manual trigger and tag check on release
2024-05-06 12:31:58 +02:00

83 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
set -e
source $(dirname $0)/version
cd $(dirname $0)/..
DIST=$(pwd)/dist/artifacts
mkdir -p $DIST/${VERSION} $DIST/latest
for i in build/bin/*; do
if [ ! -e $i ]; then
continue
fi
BASE=build/archive
DIR=${BASE}/rancher-${VERSION}
rm -rf $BASE
mkdir -p $BASE $DIR
EXT=
if [[ $i =~ .*windows.* ]]; then
EXT=.exe
fi
cp $i ${DIR}/rancher${EXT}
arch=$(echo $i | cut -f2 -d_)
mkdir -p $DIST/${VERSION}/binaries/$arch
mkdir -p $DIST/latest/binaries/$arch
cp $i $DIST/${VERSION}/binaries/$arch/rancher${EXT}
if [ -z "${EXT}" ]; then
gzip -c $i > $DIST/${VERSION}/binaries/$arch/rancher.gz
xz -c $i > $DIST/${VERSION}/binaries/$arch/rancher.xz
fi
rm -rf $DIST/latest/binaries/$arch
mkdir -p $DIST/latest/binaries
cp -rf $DIST/${VERSION}/binaries/$arch $DIST/latest/binaries
(
cd $BASE
NAME=$(basename $i | sed 's/_/-/g')
if [ -z "$EXT" ]; then
tar cvzf $DIST/${VERSION}/${NAME}-${VERSION}.tar.gz .
cp $DIST/${VERSION}/${NAME}-${VERSION}.tar.gz $DIST/latest/${NAME}.tar.gz
tar cvJf $DIST/${VERSION}/${NAME}-${VERSION}.tar.xz .
cp $DIST/${VERSION}/${NAME}-${VERSION}.tar.xz $DIST/latest/${NAME}.tar.xz
else
NAME=$(echo $NAME | sed 's/'${EXT}'//g')
zip -r $DIST/${VERSION}/${NAME}-${VERSION}.zip *
cp $DIST/${VERSION}/${NAME}-${VERSION}.zip $DIST/latest/${NAME}.zip
fi
)
done
ARCH=${ARCH:-"amd64"}
SUFFIX=""
[ "${ARCH}" != "amd64" ] && SUFFIX="_${ARCH}"
cd package
TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-rancher}
if echo $TAG | grep -q dirty; then
TAG=dev
fi
if [ -n "$GITHUB_TAG" ]; then
TAG=$GITHUB_TAG
fi
cp ../bin/rancher .
docker build -t ${REPO}/cli:${TAG} .
echo ${REPO}/cli:${TAG} > ../dist/images
echo Built ${REPO}/cli:${TAG}