goshorly/.drone.yml

166 lines
3.4 KiB
YAML
Raw Normal View History

2022-12-23 22:20:22 +00:00
---
2022-12-23 22:02:20 +00:00
kind: pipeline
2022-12-23 22:20:22 +00:00
name: check
2022-12-23 22:02:20 +00:00
2022-12-23 22:18:11 +00:00
workspace:
base: /go
2023-09-04 18:59:51 +00:00
path: src/git.hackmi.ch/Phil/goshorly
2022-12-23 22:18:11 +00:00
steps:
- name: check-format
image: golang
commands:
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
- go test -race $(go list ./... | grep -v /vendor/)
- name: check-sec
image: golang
commands:
- go install github.com/securego/gosec/v2/cmd/gosec@latest
- go get -v -d .
- gosec ./...
2022-12-23 22:20:22 +00:00
---
2022-12-23 22:18:11 +00:00
kind: pipeline
2022-12-24 21:03:46 +00:00
name: Build-untagged
2022-12-23 22:18:11 +00:00
2022-12-23 22:02:20 +00:00
steps:
2022-12-23 23:39:23 +00:00
- name: Build Binary for Testing (linux/amd64)
image: golang
commands:
- go get -v -d ./...
2022-12-24 21:03:46 +00:00
- go build -a -installsuffix cgo
2022-12-23 23:39:23 +00:00
-o linux-amd64
.
- name: Build-latest-tag-docker
2022-12-23 23:02:06 +00:00
image: docker:dind
volumes:
- name: dockersock
path: /var/run
environment:
DOCKER_PASSWORD:
from_secret: DOCKER_PASSWORD
commands:
- docker ps -a
2022-12-23 22:49:03 +00:00
- docker context create build
- docker buildx create build --use
2023-09-04 18:59:51 +00:00
- echo $DOCKER_PASSWORD | docker login --username Phil --password-stdin git.hackmi.ch
2022-12-23 23:15:17 +00:00
- docker buildx build
2022-12-23 23:23:09 +00:00
--platform linux/amd64
2022-12-23 23:15:17 +00:00
--no-cache
--build-arg CI_COMMIT_BRANCH=$DRONE_COMMIT_BRANCH
--build-arg CI_COMMIT_SHORT_SHA=$DRONE_COMMIT_SHA
--push
2023-09-04 18:59:51 +00:00
--tag git.hackmi.ch/phil/goshorly:latest
2022-12-23 22:50:04 +00:00
.
2022-12-23 22:49:03 +00:00
services:
2022-12-23 23:02:06 +00:00
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
2022-12-23 22:49:03 +00:00
volumes:
2022-12-23 23:02:06 +00:00
- name: dockersock
temp: {}
2022-12-23 23:39:23 +00:00
depends_on:
2022-12-24 21:03:46 +00:00
- check
when:
branch:
2022-12-24 21:24:16 +00:00
- main
---
kind: pipeline
name: Build-tagged-release
steps:
- name: Build linux/amd64 (prod)
image: golang
environment:
GOOS: "linux"
GOARCH: "amd64"
CGO_ENABLED: 0
commands:
- go get -v -d ./...
- go build -a -installsuffix cgo
-ldflags="-X $I_PACKAGE.CI_COMMIT_SHORT_SHA=$DRONE_COMMIT_SHA
-X $I_PACKAGE.CI_COMMIT_BRANCH=$DRONE_COMMIT_BRANCH
-X $I_PACKAGE.CI_COMMIT_TAG=$DRONE_TAG"
-o linux-amd64
.
- name: Build windows/amd64 (prod)
image: golang
environment:
GOOS: "windows"
GOARCH: "amd64"
CGO_ENABLED: 0
commands:
- go get -v -d ./...
- go build -a -installsuffix cgo
-ldflags="-X $I_PACKAGE.CI_COMMIT_SHORT_SHA=$DRONE_COMMIT_SHA
-X $I_PACKAGE.CI_COMMIT_BRANCH=$DRONE_COMMIT_BRANCH
-X $I_PACKAGE.CI_COMMIT_TAG=$DRONE_TAG"
-o windows-amd64.exe
.
- name: Build-latest-tag-docker
image: docker:dind
volumes:
- name: dockersock
path: /var/run
environment:
DOCKER_PASSWORD:
from_secret: DOCKER_PASSWORD
commands:
2023-04-05 20:35:04 +00:00
- sleep 30
2022-12-24 21:24:16 +00:00
- docker ps -a
- docker context create build
- docker buildx create build --use
2023-09-04 18:59:51 +00:00
- echo $DOCKER_PASSWORD | docker login --username Phil --password-stdin git.hackmi.ch
2022-12-24 21:24:16 +00:00
- docker buildx build
--platform linux/amd64
--no-cache
--build-arg CI_COMMIT_BRANCH=$DRONE_COMMIT_BRANCH
--build-arg CI_COMMIT_SHORT_SHA=$DRONE_COMMIT_SHA
--build-arg CI_COMMIT_TAG=$DRONE_TAG
--push
2023-09-04 18:59:51 +00:00
--tag git.hackmi.ch/phil/goshorly:$DRONE_TAG
2022-12-24 21:24:16 +00:00
.
- name: Release Binary (Git)
image: plugins/gitea-release
settings:
api_key:
from_secret: DOCKER_PASSWORD
2023-09-04 18:59:51 +00:00
base_url: https://git.hackmi.ch
2022-12-24 21:24:16 +00:00
files:
- linux-amd64
- windows-amd64.exe
checksum: md5
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
depends_on:
- check
2022-12-24 21:26:42 +00:00
trigger:
2022-12-24 21:24:16 +00:00
event:
2022-12-24 21:26:42 +00:00
- tag