Skip to content

Commit

Permalink
Release version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fluepke committed Jul 13, 2020
1 parent a5a469b commit 6340275
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
56 changes: 56 additions & 0 deletions .ci/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -e

echo "Publishing artifacts"

if [ -z $DEPLOY_TOKEN ]; then
echo "DEPLOY_TOKEN not set!"
exit 42
fi

token="$DEPLOY_TOKEN"
gitlab="https://gitlab.com"
api="$gitlab/api/v4"


echo "Uploading the binary to $gitlab"
out=$(curl -f \
--request POST \
--header "PRIVATE-TOKEN: $token" \
--form "file=@$CI_PROJECT_DIR/transceiver-exporter" \
"$api/projects/$CI_PROJECT_ID/uploads")


echo "Response from gitlab is:"
echo "$out"
url=$(echo "$out" | jq -r '.full_path')

body=$(cat <<JSON
{
"tag_name": "$CI_COMMIT_TAG",
"name": "$ref",
"assets": {
"links": [
{ "name": "transceiver-exporter",
"url": "$gitlab$url",
"filepath": "/binaries/transceiver-exporter"
}
]
}
}
JSON
)

echo "Using the following body..."
echo "$body"

echo "... creating a release"
curl -f \
-o - \
--header 'Content-Type: application/json' \
--header "PRIVATE-TOKEN: $token" \
--data "$body" \
--request POST \
"$api/projects/$CI_PROJECT_ID/releases"

24 changes: 23 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ image: golang:1.14

stages:
- verify
- build
- publish

default:
before_script:
- mkdir -p /go/src/gitlab.com/wobcom /go/src/_/builds
- cp -r $CI_PROJECT_DIR /go/src/gitlab.com/wobcom/transceiver-exporter
- ln -s /go/src/gitlab.com/wobcom/transceiver-exporter /go/src/_/builds/transceiver-exporter
- go get -v -d ./...
- go build -i -v gitlab.com/wobcom/transceiver-exporter
- go build -o $CI_PROJECT_DIR/transceiver-exporter -i -v gitlab.com/wobcom/transceiver-exporter

fmt:
stage: verify
Expand Down Expand Up @@ -39,3 +41,23 @@ test:
- docker
script:
- go test ./...

build:
stage: build
artifacts:
paths:
- $CI_PROJECT_DIR/transceiver-exporter*
tags:
- docker
script:
- GOOS=linux GOARCH=amd64 go build -o $CI_PROJECT_DIR/transceiver-exporter -i -v gitlab.com/wobcom/transceiver-exporter

publish:
stage: publish
tags:
- docker
only:
- tags
script:
- apt-get update && apt-get install -y jq
- ./.ci/publish.sh $CI_COMMIT_REF_NAME
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
)

const version string = "0.1"
const version string = "1.0"

var (
showVersion = flag.Bool("version", false, "Print version and exit")
Expand Down

0 comments on commit 6340275

Please sign in to comment.