Add Drone and Dapper

This commit is contained in:
galal-hussein
2023-01-20 00:27:46 +02:00
parent 6256eb8170
commit 4dab6b8a9d
16 changed files with 421 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
/*
Copyright YEAR Rancher Labs, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Executable
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
set -e
source $(dirname $0)/version
cd $(dirname $0)/..
mkdir -p bin
if [ "$(uname)" = "Linux" ]; then
OTHER_LINKFLAGS="-extldflags -static -s"
fi
LINKFLAGS="-X github.com/rancher/k3k.Version=$VERSION"
LINKFLAGS="-X github.com/rancher/k3k.GitCommit=$COMMIT $LINKFLAGS"
CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/k3k
if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/k3k-darwin
GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/k3k-windows
fi
Executable
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
set -e
cd $(dirname $0)
./build
./test
./validate
./validate-ci
./package
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
set -e
cd $(dirname $0)
./build
./test
./package
Executable
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
set -e
mkdir -p bin dist
if [ -e ./scripts/$1 ]; then
./scripts/"$@"
else
exec "$@"
fi
chown -R $DAPPER_UID:$DAPPER_GID .
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
set -e
source $(dirname $0)/version
cd $(dirname $0)/..
mkdir -p dist/artifacts
cp bin/k3k dist/artifacts/k3k${SUFFIX}
IMAGE=${REPO}/k3k:${TAG}
DOCKERFILE=package/Dockerfile
if [ -e ${DOCKERFILE}.${ARCH} ]; then
DOCKERFILE=${DOCKERFILE}.${ARCH}
fi
docker build -f ${DOCKERFILE} -t ${IMAGE} .
echo Built ${IMAGE}
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
exec $(dirname $0)/ci
Executable
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
echo Running tests
go test -cover -tags=test ./...
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
echo Running validation
PACKAGES="$(go list ./...)"
if ! command -v golangci-lint; then
echo Skipping validation: no golangci-lint available
exit
fi
echo Running validation
echo Running: golangci-lint
golangci-lint run
echo Running: go fmt
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
go generate
source ./scripts/version
if [ -n "$DIRTY" ]; then
echo Git is dirty
git status
git diff
exit 1
fi
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
DIRTY="-dirty"
fi
COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
else
VERSION="${COMMIT}${DIRTY}"
fi
if [ -z "$ARCH" ]; then
ARCH=$(go env GOHOSTARCH)
fi
SUFFIX="-${ARCH}"
TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-galal-hussein}
if echo $TAG | grep -q dirty; then
TAG=dev
fi