Skip to content
Snippets Groups Projects
Commit f374865a authored by Maximilian Reinheimer's avatar Maximilian Reinheimer
Browse files

Update CI to build binary packages and create releases on tag pipelines

parent b934c564
Branches
No related tags found
2 merge requests!3Update CI to build binary packages and create releases on tag pipelines,!2First working version that retrieves the real state from the device
stages:
- build
- release
- deploy
.default_rules_dev: .default_rules_dev:
rules: rules:
- if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "schedule"
when: never when: never
- if: $CI_COMMIT_BRANCH == "develop" - if: $CI_COMMIT_BRANCH == "develop"
variables:
SERVER_IP: "syslab-cube13-1.fbi.h-da.de"
.default_rules_prod: .default_rules_prod:
rules: rules:
- if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "schedule"
when: never when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
SERVER_IP: "syslab-cube13-1.fbi.h-da.de"
variables: variables:
GOPATH: "${CI_PROJECT_DIR}/.cache" GOPATH: "${CI_PROJECT_DIR}/.cache"
...@@ -22,7 +23,7 @@ variables: ...@@ -22,7 +23,7 @@ variables:
# build and test stages, unrelated to this article # build and test stages, unrelated to this article
build: build:
image: golang:1.17 image: golang:1.16-buster
stage: build stage: build
script: script:
- | - |
...@@ -31,8 +32,6 @@ build: ...@@ -31,8 +32,6 @@ build:
GOOS=$os GOARCH=$arch make cross GOOS=$os GOARCH=$arch make cross
done done
done done
- apt-get -qq -y install curl
- /bin/sh mkrel.sh gnmitarget
artifacts: artifacts:
paths: paths:
- gnmitarget_* - gnmitarget_*
...@@ -40,10 +39,11 @@ build: ...@@ -40,10 +39,11 @@ build:
- !reference [.default_rules_dev, rules] - !reference [.default_rules_dev, rules]
- !reference [.default_rules_prod, rules] - !reference [.default_rules_prod, rules]
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == "test"
release: release:
image: golang:1.17 image: ubuntu:21.04
stage: release stage: release
before_script: before_script:
- apt-get update -qq && apt-get -y -qq install jq xxd curl - apt-get update -qq && apt-get -y -qq install jq xxd curl
......
PROGNAME=gnmitarget
OUTPUT=${PROGNAME}_${CI_COMMIT_TAG}_${GOOS}_${GOARCH}
# other targets
cross:
go build -o ${OUTPUT}
sha256sum ${OUTPUT} > ${OUTPUT}.sha256
mkrel.sh 0 → 100755
#!/bin/bash
set -x
progname=$1
baseurl="https://gitlab.fbi.h-da.de/api/v4/projects/${CI_PROJECT_ID}"
for os in ${OSS}; do
for arch in ${GOARCH}; do
fullname="${progname}_${CI_COMMIT_TAG}_${os}_${arch}"
linkurl="${baseurl}/jobs/${CI_JOB_ID}/artifacts/${fullname}"
linklist="${linklist}{\"name\": \"${fullname}\", \"url\": \"${linkurl}\"}"
linklist="${linklist}{\"name\": \"${fullname}.sha256\", \"url\": \"${linkurl}.sha256\"}"
done
done
links="[$(echo ${linklist}|sed 's/}{/}, {/g')]"
descr="$(curl -H \"JOB-TOKEN:\ ${CI_JOB_TOKEN}\" ${baseurl}/repository/tags/${CI_COMMIT_TAG}|jq -r '.message')"
DATA="
{
\"name\": \"${progname} version ${CI_COMMIT_TAG}\",
\"description\": \"${descr}\",
\"tag_name\": \"${CI_COMMIT_TAG}\",
\"assets\": {
\"links\": "${links}"
}
}
"
curl -v -H 'Content-Type: application/json' -X POST -H "JOB-TOKEN: ${CI_JOB_TOKEN}" "${baseurl}/releases" -d "${DATA}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment