Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Drone CI to sign gpg #28

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 70 additions & 53 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,112 @@
---
kind: pipeline
name: amd64
name: default

platform:
os: linux
arch: amd64

steps:
- name: build
- name: build-release-binary
image: rancher/dapper:v0.5.8
environment:
CROSS: 1
commands:
- dapper precheck
- dapper ci
volumes:
- name: docker
path: /var/run/docker.sock
when:
event:
- tag

- name: stage-binaries
- name: gpg-sign-release
image: plugins/gpgsign
settings:
key:
from_secret: gpg_private_key
passphrase:
from_secret: gpg_passphrase
files:
- dist/artifacts/terraform-provider-harvester_*_SHA256SUMS
detach_sign: true
armor: false
when:
event:
- tag

- name: github-binary-prerelease
image: plugins/github-release
settings:
prerelease: true
files:
- dist/artifacts/terraform-provider-harvester_*
api_key:
from_secret: github_token
when:
ref:
include:
- "refs/tags/*rc*"
event:
- tag

- name: github-binary-release
image: plugins/github-release
settings:
files:
- dist/artifacts/terraform-provider-harvester_*
api_key:
from_secret: github_token
when:
ref:
exclude:
- "refs/tags/*rc*"
event:
- tag

- name: build
image: rancher/dapper:v0.5.8
commands:
- "cp -r ./bin/* ./package/"
- dapper ci
volumes:
- name: docker
path: /var/run/docker.sock
when:
event:
- push
- tag
- pull_request

- name: docker-publish-master
image: plugins/docker
settings:
build_args:
- ARCH=amd64
context: package/
custom_dns: 1.1.1.1
dockerfile: package/Dockerfile
password:
from_secret: docker_password
repo: "rancher/terraform-provider-harvester"
tag: ${DRONE_BRANCH}-head-amd64
username:
from_secret: docker_username
- name: stage-binaries
image: rancher/dapper:v0.5.8
commands:
- "cp -r ./bin/terraform-provider-harvester ./package/"
when:
ref:
include:
- "refs/heads/master"
- "refs/heads/v*"
event:
- push

- name: docker-publish
- name: docker-publish-master
image: plugins/docker
settings:
build_args:
- ARCH=amd64
- "VERSION=${DRONE_TAG}"
context: package/
custom_dns: 1.1.1.1
dockerfile: package/Dockerfile
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: "rancher/terraform-provider-harvester"
tag: "${DRONE_TAG}-amd64"
username:
from_secret: docker_username
tag: ${DRONE_BRANCH}-head-amd64
when:
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
include:
- "refs/heads/master"
event:
- tag
- push

volumes:
- name: docker
Expand Down Expand Up @@ -99,29 +137,8 @@ steps:
ref:
include:
- "refs/heads/master"
- "refs/heads/v*"
event:
- push

- name: manifest
image: plugins/manifest
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
platforms:
- linux/amd64
target: "rancher/terraform-provider-harvester:${DRONE_TAG}"
template: "rancher/terraform-provider-harvester:${DRONE_TAG}-ARCH"
when:
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
event:
- tag

depends_on:
- amd64
- default
49 changes: 0 additions & 49 deletions .github/workflows/release.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .goreleaser.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN if [ "${ARCH}" = "amd64" ]; then \

ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS
ENV DAPPER_SOURCE /go/src/github.com/harvester/terraform-provider-harvester
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_OUTPUT ./bin ./dist ./build
ENV DAPPER_DOCKER_SOCKET true
ENV HOME ${DAPPER_SOURCE}

Expand Down
52 changes: 52 additions & 0 deletions scripts/archive
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
set -e

source $(dirname $0)/version

cd $(dirname $0)/..

BIN_NAME_PREFIX="terraform-provider-harvester"
BUILD_DIR="./build"
BUILD_BIN_DIR="${BUILD_DIR}/bin"
if [ -z "$(ls -A ${BUILD_BIN_DIR})" ]; then
exit 0
fi

VERSION_NO_V=${VERSION/[v|V]/}
echo "==> Packaging binaries version ${VERSION_NO_V} ..."

DIST=$(pwd)/dist/artifacts

mkdir -p "${DIST}"

for i in "${BUILD_BIN_DIR}"/*; do
if [ ! -e "${i}" ]; then
continue
fi

ARCHIVE_DIR=${BUILD_DIR}/archive

rm -rf "${ARCHIVE_DIR}"
mkdir -p "${ARCHIVE_DIR}"

EXT=
if [[ $i =~ .*windows.* ]]; then
EXT=.exe
fi

cp "${i}" "${ARCHIVE_DIR}/${BIN_NAME_PREFIX}_${VERSION}${EXT}"

(
cd "${ARCHIVE_DIR}"
NAME=$(basename "${i}" | cut -f1 -d_)
ARCH=$(basename "${i}" | cut -f2,3 -d_ | cut -f1 -d.)
ARCHIVE_FILE="${NAME}_${VERSION_NO_V}_${ARCH}.zip"
echo "Packaging $DIST/${ARCHIVE_FILE} ..."
zip -q "${DIST}/${ARCHIVE_FILE}" ./*
)
done

(
cd "${DIST}"
shasum -a 256 ./* > "${BIN_NAME_PREFIX}_${VERSION_NO_V}_SHA256SUMS"
)
29 changes: 28 additions & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@ source $(dirname $0)/version

cd $(dirname $0)/..

declare -A OS_ARCH_ARG

OS_PLATFORM_ARG=(linux darwin)
OS_ARCH_ARG[linux]="amd64 arm64"
OS_ARCH_ARG[darwin]="amd64 arm64"

BIN_NAME="terraform-provider-harvester"
BUILD_DIR="./build"
BUILD_BIN_DIR="${BUILD_DIR}/bin"

mkdir -p bin
[ "$(uname)" != "Darwin" ] && LINKFLAGS="-extldflags -static -s"
CGO_ENABLED=0 go build -ldflags "-X main.VERSION=$VERSION $LINKFLAGS" -o bin/terraform-provider-harvester
CGO_ENABLED=0 go build -ldflags "-X main.VERSION=${VERSION} ${LINKFLAGS}" -o bin/${BIN_NAME}

if [ -n "${CROSS}" ]; then
rm -rf "${BUILD_BIN_DIR}"
mkdir -p "${BUILD_BIN_DIR}"
for OS in "${OS_PLATFORM_ARG[@]}"; do
for ARCH in ${OS_ARCH_ARG[${OS}]}; do
OUTPUT_BIN="${BUILD_BIN_DIR}/${BIN_NAME}_${OS}_${ARCH}"
if test "${OS}" = "windows"; then
OUTPUT_BIN="${OUTPUT_BIN}.exe"
fi
echo "Building binary for ${OS}/${ARCH}..."
GOARCH=${ARCH} GOOS=${OS} CGO_ENABLED=0 go build \
-ldflags="-w -X main.VERSION=$VERSION" \
-o "${OUTPUT_BIN}" ./
done
done
fi
1 change: 1 addition & 0 deletions scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ cd $(dirname $0)
./build
./test
./validate
./archive
./package
1 change: 1 addition & 0 deletions scripts/default
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ cd $(dirname $0)
./build
./test
./validate
./archive
./package
Loading