Building OSS

This commit is contained in:
Laszlo Fogas 2019-04-04 21:18:28 +02:00
parent ca5817ffc2
commit 897c9352a3
3 changed files with 36 additions and 25 deletions

View file

@ -1,2 +1,4 @@
* *
!release/* !release/*
.env

View file

@ -1,28 +1,28 @@
#!/bin/sh #!/bin/sh
# only execute this script as part of the pipeline. # only execute this script as part of the pipeline.
[ -z "$CI" ] && echo "missing ci environment variable" && exit 2 # [ -z "$CI" ] && echo "missing ci environment variable" && exit 2
# only execute the script when github token exists. # only execute the script when github token exists.
[ -z "$SSH_KEY" ] && echo "missing ssh key" && exit 3 # [ -z "$SSH_KEY" ] && echo "missing ssh key" && exit 3
# write the ssh key. # write the ssh key.
mkdir /root/.ssh # mkdir /root/.ssh
echo -n "$SSH_KEY" > /root/.ssh/id_rsa # echo -n "$SSH_KEY" > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa # chmod 600 /root/.ssh/id_rsa
# add github.com to our known hosts. # add github.com to our known hosts.
touch /root/.ssh/known_hosts # touch /root/.ssh/known_hosts
chmod 600 /root/.ssh/known_hosts # chmod 600 /root/.ssh/known_hosts
ssh-keyscan -H github.com > /etc/ssh/ssh_known_hosts 2> /dev/null # ssh-keyscan -H github.com > /etc/ssh/ssh_known_hosts 2> /dev/null
# clone the extras project. # clone the extras project.
set -e set -e
set -x set -x
git clone git@github.com:drone/drone-enterprise.git extras # git clone git@github.com:drone/drone-enterprise.git extras
# build a static binary with the build number and extra features. # build a static binary with the build number and extra features.
go build -ldflags '-extldflags "-static" -X github.com/laszlocph/drone-oss-08/version.VersionDev=build.'${DRONE_BUILD_NUMBER} -o release/drone-server github.com/laszlocph/drone-oss-08/extras/cmd/drone-server go build -ldflags '-extldflags "-static" -X github.com/laszlocph/drone-oss-08/version.VersionDev=build.'${DRONE_BUILD_NUMBER} -o release/drone-server github.com/laszlocph/drone-oss-08/cmd/drone-server
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-X github.com/laszlocph/drone-oss-08/version.VersionDev=build.'${DRONE_BUILD_NUMBER} -o release/drone-agent github.com/laszlocph/drone-oss-08/cmd/drone-agent GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-X github.com/laszlocph/drone-oss-08/version.VersionDev=build.'${DRONE_BUILD_NUMBER} -o release/drone-agent github.com/laszlocph/drone-oss-08/cmd/drone-agent
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags '-X github.com/laszlocph/drone-oss-08/version.VersionDev=build.'${DRONE_BUILD_NUMBER} -o release/linux/arm64/drone-agent github.com/laszlocph/drone-oss-08/cmd/drone-agent GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags '-X github.com/laszlocph/drone-oss-08/version.VersionDev=build.'${DRONE_BUILD_NUMBER} -o release/linux/arm64/drone-agent github.com/laszlocph/drone-oss-08/cmd/drone-agent
GOOS=linux GOARCH=arm CGO_ENABLED=0 GOARM=7 go build -ldflags '-X github.com/laszlocph/drone-oss-08/version.VersionDev=build.'${DRONE_BUILD_NUMBER} -o release/linux/arm/drone-agent github.com/laszlocph/drone-oss-08/cmd/drone-agent GOOS=linux GOARCH=arm CGO_ENABLED=0 GOARM=7 go build -ldflags '-X github.com/laszlocph/drone-oss-08/version.VersionDev=build.'${DRONE_BUILD_NUMBER} -o release/linux/arm/drone-agent github.com/laszlocph/drone-oss-08/cmd/drone-agent

View file

@ -33,13 +33,12 @@ pipeline:
build: build:
image: golang:1.8 image: golang:1.8
commands: sh .drone.sh commands: sh .drone.sh
secrets: [ ssh_key ]
when: when:
event: [ push, tag ] event: [ push, tag ]
publish_server_alpine: publish_server_alpine:
image: plugins/docker image: plugins/docker
repo: drone/drone repo: laszlocloud/drone-oss-08-server
dockerfile: Dockerfile.alpine dockerfile: Dockerfile.alpine
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ alpine ] tag: [ alpine ]
@ -49,7 +48,17 @@ pipeline:
publish_server: publish_server:
image: plugins/docker image: plugins/docker
repo: drone/drone repo: laszlocloud/drone-oss-08-server
secrets: [ docker_username, docker_password ]
tag: [ latest ]
when:
branch: master
event: push
publish_agent:
image: plugins/docker
repo: laszlocloud/drone-oss-08-agent
dockerfile: Dockerfile.agent
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ latest ] tag: [ latest ]
when: when:
@ -58,7 +67,7 @@ pipeline:
publish_agent_alpine: publish_agent_alpine:
image: plugins/docker image: plugins/docker
repo: drone/agent repo: laszlocloud/drone-oss-08-agent
dockerfile: Dockerfile.agent.alpine dockerfile: Dockerfile.agent.alpine
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ alpine ] tag: [ alpine ]
@ -68,7 +77,7 @@ pipeline:
publish_agent_arm: publish_agent_arm:
image: plugins/docker image: plugins/docker
repo: drone/agent repo: laszlocloud/drone-oss-08-agent
dockerfile: Dockerfile.agent.linux.arm dockerfile: Dockerfile.agent.linux.arm
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ linux-arm ] tag: [ linux-arm ]
@ -78,7 +87,7 @@ pipeline:
publish_agent_arm64: publish_agent_arm64:
image: plugins/docker image: plugins/docker
repo: drone/agent repo: laszlocloud/drone-oss-08-agent
dockerfile: Dockerfile.agent.linux.arm64 dockerfile: Dockerfile.agent.linux.arm64
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ linux-arm64 ] tag: [ linux-arm64 ]
@ -88,7 +97,7 @@ pipeline:
publish_agent_amd64: publish_agent_amd64:
image: plugins/docker image: plugins/docker
repo: drone/agent repo: laszlocloud/drone-oss-08-agent
dockerfile: Dockerfile.agent dockerfile: Dockerfile.agent
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ latest ] tag: [ latest ]
@ -98,36 +107,36 @@ pipeline:
release_server_alpine: release_server_alpine:
image: plugins/docker image: plugins/docker
repo: drone/drone repo: laszlocloud/drone-oss-08-server
dockerfile: Dockerfile.alpine dockerfile: Dockerfile.alpine
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ 0.8-alpine ] tag: [ 0.8.91-alpine ]
when: when:
event: tag event: tag
release_agent_alpine: release_agent_alpine:
image: plugins/docker image: plugins/docker
repo: drone/agent repo: laszlocloud/drone-oss-08-agent
dockerfile: Dockerfile.agent.alpine dockerfile: Dockerfile.agent.alpine
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ 0.8-alpine ] tag: [ 0.8.91-alpine ]
when: when:
event: tag event: tag
release_server: release_server:
image: plugins/docker image: plugins/docker
repo: drone/drone repo: laszlocloud/drone-oss-08-server
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ 0.8, 0.8.9 ] tag: [ 0.8.91 ]
when: when:
event: tag event: tag
release_agent: release_agent:
image: plugins/docker image: plugins/docker
repo: drone/agent repo: laszlocloud/drone-oss-08-agent
dockerfile: Dockerfile.agent dockerfile: Dockerfile.agent
secrets: [ docker_username, docker_password ] secrets: [ docker_username, docker_password ]
tag: [ 0.8, 0.8.9 ] tag: [ 0.8.91 ]
when: when:
event: tag event: tag