Commit eca510b0 authored by Jonas Jasas's avatar Jonas Jasas

Docker

parent 6781f9e4
Pipeline #156015702 passed with stages
in 4 minutes and 39 seconds
......@@ -15,80 +15,80 @@ stages:
# TEST ######################################################################################
#test:unit:
# stage: test
# extends: .go
# script: go test ./test/unittest/... -cover
#
#test:race:
# stage: test
# extends: .go
# script: go build --race ./cmd/...
#
#test:integration:
# stage: test
# extends: .go
# script: go test ./test/integration/...
test:unit:
stage: test
extends: .go
script: go test ./test/unittest/... -cover
test:race:
stage: test
extends: .go
script: go build --race ./cmd/...
test:integration:
stage: test
extends: .go
script: go test ./test/integration/...
# DOWNLOADS ################################################################################
#.download:
# artifacts:
# paths:
# - download/
#
#download:build:
# stage: build
# extends:
# - .go
# - .download
#
# variables:
# GZIP: '-9'
#
# script:
# - mkdir download
#
# - GOOS=linux GOARCH=386 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
# - tar -czf download/httprelay_linux_386_$CI_COMMIT_TAG.tar.gz -C bin .
# - rm -r bin
#
# - GOOS=linux GOARCH=amd64 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
# - tar -czf download/httprelay_linux_amd64_$CI_COMMIT_TAG.tar.gz -C bin .
# - rm -r bin
#
# - GOOS=linux GOARCH=arm go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
# - tar -czf download/httprelay_linux_arm_$CI_COMMIT_TAG.tar.gz -C bin .
# - rm -r bin
#
# - GOOS=linux GOARCH=arm64 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
# - tar -czf download/httprelay_linux_arm64_$CI_COMMIT_TAG.tar.gz -C bin .
# - rm -r bin
#
# - GOOS=windows GOARCH=amd64 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME}.exe ./cmd/...
# - tar -czf download/httprelay_windows_amd64_$CI_COMMIT_TAG.tar.gz -C bin .
# - rm -r bin
#
# - GOOS=darwin GOARCH=amd64 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
# - tar -czf download/httprelay_macosx_arm64_$CI_COMMIT_TAG.tar.gz -C bin .
# - rm -r bin
#
#download:release:
# extends: .download
# stage: release
# only:
# - tags
# - /v\d*/
#
# script:
# - >
# curl --request DELETE --header "PRIVATE-TOKEN: $API_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/releases/v2"
#
# - export DESCRIPTION=`echo $CI_COMMIT_MESSAGE | tr '\n' ' '`
# - >
# curl -v --header "Content-Type: application/json" --header "PRIVATE-TOKEN: $API_TOKEN"
# --data '{ "name": "'"$CI_COMMIT_TAG"'", "tag_name": "'"$CI_COMMIT_TAG"'", "description": "'"$DESCRIPTION"'", "assets": { "links": [{ "name": "Download standalone binaries (Linux, Mac, Windows)", "url": "https://gitlab.com/jonas.jasas/httprelay/-/jobs/'"$CI_JOB_ID"'/artifacts/browse/download" }] } }'
# https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/releases
.download:
artifacts:
paths:
- download/
download:build:
stage: build
extends:
- .go
- .download
variables:
GZIP: '-9'
script:
- mkdir download
- GOOS=linux GOARCH=386 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
- tar -czf download/httprelay_linux_386_$CI_COMMIT_TAG.tar.gz -C bin .
- rm -r bin
- GOOS=linux GOARCH=amd64 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
- tar -czf download/httprelay_linux_amd64_$CI_COMMIT_TAG.tar.gz -C bin .
- rm -r bin
- GOOS=linux GOARCH=arm go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
- tar -czf download/httprelay_linux_arm_$CI_COMMIT_TAG.tar.gz -C bin .
- rm -r bin
- GOOS=linux GOARCH=arm64 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
- tar -czf download/httprelay_linux_arm64_$CI_COMMIT_TAG.tar.gz -C bin .
- rm -r bin
- GOOS=windows GOARCH=amd64 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME}.exe ./cmd/...
- tar -czf download/httprelay_windows_amd64_$CI_COMMIT_TAG.tar.gz -C bin .
- rm -r bin
- GOOS=darwin GOARCH=amd64 go build -ldflags "-X gitlab.com/jonas.jasas/httprelay/pkg/server.Version=$CI_COMMIT_TAG" -o bin/${CI_PROJECT_NAME} ./cmd/...
- tar -czf download/httprelay_macosx_arm64_$CI_COMMIT_TAG.tar.gz -C bin .
- rm -r bin
download:release:
extends: .download
stage: release
only:
- tags
- /v\d*/
script:
- >
curl --request DELETE --header "PRIVATE-TOKEN: $API_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/releases/v2"
- export DESCRIPTION=`echo $CI_COMMIT_MESSAGE | tr '\n' ' '`
- >
curl -v --header "Content-Type: application/json" --header "PRIVATE-TOKEN: $API_TOKEN"
--data '{ "name": "'"$CI_COMMIT_TAG"'", "tag_name": "'"$CI_COMMIT_TAG"'", "description": "'"$DESCRIPTION"'", "assets": { "links": [{ "name": "Download standalone binaries (Linux, Mac, Windows)", "url": "https://gitlab.com/jonas.jasas/httprelay/-/jobs/'"$CI_JOB_ID"'/artifacts/browse/download" }] } }'
https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/releases
# DOCKER ###################################################################################
......@@ -98,6 +98,7 @@ stages:
DOCKER_HOST: tcp://docker:2375
GITLAB_REG_IMG: registry.gitlab.com/$CI_PROJECT_PATH
GITLAB_REG_BUILD_TAG: registry.gitlab.com/$CI_PROJECT_PATH:build-$CI_PIPELINE_IID
GITLAB_REG_RELEASE_TAG: registry.gitlab.com/$CI_PROJECT_PATH:${CI_COMMIT_TAG}
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
......@@ -105,10 +106,6 @@ stages:
docker:build:
stage: build
extends: .docker
only:
- tags
- /v\d*/
services:
- docker:dind
......@@ -128,7 +125,6 @@ docker:release:
variables:
GITHUB_REG_IMG: $DOCKERHUB_USER/$CI_PROJECT_NAME
GITLAB_REG_RELEASE_TAG: registry.gitlab.com/$CI_PROJECT_PATH:${CI_COMMIT_TAG}
script:
- docker pull $GITLAB_REG_BUILD_TAG
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment