Added Tagged Build

This commit is contained in:
Phil 2022-12-24 22:24:16 +01:00
parent 17536c2312
commit 8ba101c6a1

View file

@ -43,7 +43,6 @@ steps:
DOCKER_PASSWORD: DOCKER_PASSWORD:
from_secret: DOCKER_PASSWORD from_secret: DOCKER_PASSWORD
commands: commands:
- sleep 30
- docker ps -a - docker ps -a
- docker context create build - docker context create build
- docker buildx create build --use - docker buildx create build --use
@ -74,4 +73,141 @@ depends_on:
when: when:
branch: branch:
- main - 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 linux/arm64 (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-arm64
.
- 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 darwin/amd64 (prod)
image: golang
environment:
GOOS: "darwin"
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 darwin-amd64
.
- name: Build darwin/arm64 (prod)
image: golang
environment:
GOOS: "darwin"
GOARCH: "arm64"
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 darwin-arm64
.
- name: Build-latest-tag-docker
image: docker:dind
volumes:
- name: dockersock
path: /var/run
environment:
DOCKER_PASSWORD:
from_secret: DOCKER_PASSWORD
commands:
- docker ps -a
- docker context create build
- docker buildx create build --use
- echo $DOCKER_PASSWORD | docker login --username Phil --password-stdin gitea.hackmi.ch
- 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
--tag gitea.hackmi.ch/phil/goshorly:$DRONE_TAG
.
- name: Release Binary (Git)
image: plugins/gitea-release
settings:
api_key:
from_secret: DOCKER_PASSWORD
base_url: https://gitea.hackmi.ch
files:
- linux-amd64
- linux-arm64
- windows-amd64.exe
- darwin-amd64
- darwin-arm64
checksum: md5
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
depends_on:
- check
when:
event:
- tag