From aea5c7619f004e598156381573e56a77da928a95 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 17 Dec 2022 17:59:09 +0100 Subject: [PATCH] updated ci --- .drone.yml | 159 ++++++++++++++++------------------------------------ Makefile | 18 ------ ci-build.sh | 62 -------------------- 3 files changed, 48 insertions(+), 191 deletions(-) delete mode 100644 Makefile delete mode 100755 ci-build.sh diff --git a/.drone.yml b/.drone.yml index 72d3b03..8fb385b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,89 +1,70 @@ --- kind: pipeline type: docker -name: cleanup-before +name: build-linux + +environment: + GOOS: linux + GOOPTIONS: -mod=vendor + SRCFILES: cmd/pki/*.go + PROJECTNAME: pki steps: - - name: clean - image: alpine - commands: - - rm -rf /build/* - volumes: - - name: build - path: /build - when: - event: tag - -volumes: - - name: build - host: - path: /tmp/pki/build - ---- -kind: pipeline -type: docker -name: default-linux-amd64 - -steps: - - name: build + - name: build-linux-amd64 image: golang commands: - - ./ci-build.sh build + - go build -o $PROJECTNAME $GOOPTIONS $SRCFILES environment: - GOOS: linux GOARCH: amd64 - volumes: - - name: build - path: /build - -volumes: - - name: build - host: - path: /tmp/pki/build - -depends_on: - - cleanup-before - ---- -kind: pipeline -type: docker -name: default-linux-arm64 - -steps: - - name: build + when: + event: + exclude: + - tag + - name: build-linux-arm64 image: golang commands: - - ./ci-build.sh build + - go build -o $PROJECTNAME $GOOPTIONS $SRCFILES environment: - GOOS: linux GOARCH: arm64 - volumes: - - name: build - path: /build - -volumes: - - name: build - host: - path: /tmp/pki/build - -depends_on: - - cleanup-before + when: + event: + exclude: + - tag --- kind: pipeline type: docker -name: gitea-release +name: gitea-release-linux + +environment: + GOOS: linux + GOOPTIONS: -mod=vendor + SRCFILES: cmd/pki/*.go + PROJECTNAME: pki steps: - - name: move - image: alpine + - name: build-linux-amd64 + image: golang commands: - - mv build/* ./ - volumes: - - name: build - path: /drone/src/build + - go build -o $PROJECTNAME $GOOPTIONS $SRCFILES + - tar -czvf $PROJECTNAME-$DRONE_TAG-$GOOS-$GOARCH.tar.gz $PROJECTNAME + - echo $PROJECTNAME $DRONE_TAG > VERSION + environment: + GOARCH: amd64 when: - event: tag + event: + - tag + - name: build-linux-arm64 + image: golang + commands: + - go build -o $PROJECTNAME $GOOPTIONS $SRCFILES + - tar -czvf $PROJECTNAME-$DRONE_TAG-$GOOS-$GOARCH.tar.gz $PROJECTNAME + - echo $PROJECTNAME $DRONE_TAG > VERSION + environment: + GOARCH: arm64 + when: + event: + - tag - name: release image: plugins/gitea-release settings: @@ -95,50 +76,6 @@ steps: - sha256 - sha512 title: VERSION - volumes: - - name: build - path: /drone/src/build when: - event: tag - - name: ls - image: alpine - commands: - - find . - volumes: - - name: build - path: /drone/src/build - when: - event: tag - -volumes: - - name: build - host: - path: /tmp/pki/build - -depends_on: - - default-linux-amd64 - - default-linux-arm64 - ---- -kind: pipeline -type: docker -name: cleanup-after - -steps: - - name: clean - image: alpine - commands: - - rm -rf /build/* - volumes: - - name: build - path: /build - when: - event: tag - -volumes: - - name: build - host: - path: /tmp/pki/build - -depends_on: - - gitea-release + event: + - tag diff --git a/Makefile b/Makefile deleted file mode 100644 index a544f18..0000000 --- a/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# pki Makefile - -GOCMD=go -GOBUILDCMD=${GOCMD} build -GOOPTIONS=-mod=vendor -ldflags="-s -w" - -RMCMD=rm -BINNAME=pki - -SRCFILES=cmd/pki/*.go - -all: build - -build: - ${GOBUILDCMD} ${GOOPTIONS} ${SRCFILES} - -clean: - ${RMCMD} -f ${BINNAME} \ No newline at end of file diff --git a/ci-build.sh b/ci-build.sh deleted file mode 100755 index 85f340d..0000000 --- a/ci-build.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -set -e - -PROJECTNAME=pki -RELEASENAME=${PROJECTNAME} -VERSION="0" - -GOOPTIONS="-mod=vendor" -SRCFILES=cmd/${PROJECTNAME}/*.go - -build() { - echo "Begin of build" - if [[ ! -z $DRONE_TAG ]] - then - echo "Drone tag set, let's do a release" - VERSION=$DRONE_TAG - echo "${PROJECTNAME} ${VERSION}" > /build/VERSION - elif [[ ! -z $DRONE_TAG ]] - then - echo "Drone not set, let's only do a build" - VERSION=$DRONE_COMMIT - fi - - if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]] - then - echo "Let's set a release name" - RELEASENAME=${PROJECTNAME}-${VERSION}-${GOOS}-${GOARCH} - fi - - echo "Building project" - go build -o ${PROJECTNAME} ${GOOPTIONS} ${SRCFILES} - - if [[ ! -z $DRONE_TAG ]] - then - echo "Let's make archives" - mkdir -p /build - tar -czvf /build/${RELEASENAME}.tar.gz ${PROJECTNAME} - fi - - echo "Removing binary file" - rm ${PROJECTNAME} - - echo "End of build" -} - -clean() { - rm -rf $RELEASEDIR -} - -case $1 in - "build") - build - ;; - "clean") - clean - ;; - *) - echo "No options choosen" - exit 1 - ;; -esac