Skip to content

Commit

Permalink
Add initial gitlab config
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed Jun 13, 2022
1 parent 59a36da commit 8589c18
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
image: golang:latest

variables:
REPO_NAME: gitlab.com/***/***

before_script:
- go version
- echo $CI_BUILD_REF
- echo $CI_PROJECT_DIR

stages:
- test
- build

test-project:
stage: test
script:
- mkdir -p $GOPATH/src/$REPO_NAME
- mv $CI_PROJECT_DIR/* $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
- go test $(go list ./... | grep -v /vendor/)

build-project:
stage: build
script:
- OUTPUT="ouput"
- mkdir -p $GOPATH/src/$REPO_NAME
- mv $CI_PROJECT_DIR/* $GOPATH/src/$REPO_NAME/
- cd $GOPATH/src/$REPO_NAME
- bash .gitlab/build-all.sh $OUTPUT $CI_PROJECT_DIR

artifacts:
paths:
- artifacts/
18 changes: 18 additions & 0 deletions .gitlab/build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
BIN_FILE_NAME_PREFIX=$1
PROJECT_DIR=$2
PLATFORMS=$(go tool dist list)
for PLATFORM in $PLATFORMS; do
GOOS=${PLATFORM%/*}
GOARCH=${PLATFORM#*/}
FILEPATH="$PROJECT_DIR/artifacts/${GOOS}-${GOARCH}"
#echo $FILEPATH
mkdir -p $FILEPATH
BIN_FILE_NAME="$FILEPATH/${BIN_FILE_NAME_PREFIX}"
#echo $BIN_FILE_NAME
if [[ "${GOOS}" == "windows" ]]; then BIN_FILE_NAME="${BIN_FILE_NAME}.exe"; fi
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILE_NAME}"
#echo $CMD
echo "${CMD}"
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
done

0 comments on commit 8589c18

Please sign in to comment.