Skip to content

Commit 3240221

Browse files
authored
v0.6.1 (#171)
2 parents 2588e16 + c79ea92 commit 3240221

File tree

100 files changed

+1503
-557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1503
-557
lines changed

.github/workflows/go.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.idea/
2+
/.cache/
23
/mytoken
34
/mytoken-setup
45
/mytoken-server
@@ -15,3 +16,4 @@ dist/
1516
/docker/db.env
1617
/docker/haproxy/haproxy.cfg
1718
/docker/.env
19+
/results/

.gitlab-ci-scripts/goreleaser.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
mkdir ../shared
2+
first=$(grep '^## ' -nm1 CHANGELOG.md | cut -d':' -f1); \
3+
second=$(grep '^## ' -nm2 CHANGELOG.md | tail -n1 | cut -d':' -f1); \
4+
tail -n+$first CHANGELOG.md | head -n$(($second-$first)) > ../shared/release.md
5+
GORELEASER_CONFIG=".goreleaser.yml"
6+
if [ -n "$CI_COMMIT_TAG" ] && echo "$CI_COMMIT_TAG" | grep -qv '-'; then
7+
GORELEASER_CONFIG=".goreleaser-release.yml"
8+
fi
9+
BASEDIR=/go/src/github.com/oidc-mytoken/server
10+
docker run --rm --privileged \
11+
-v "$PWD":"$BASEDIR" \
12+
-w "$BASEDIR" \
13+
-v "${PWD}/../shared":/tmp/shared \
14+
-v /var/run/docker.sock:/var/run/docker.sock \
15+
-e DOCKER_USERNAME -e DOCKER_PASSWORD \
16+
-e GITHUB_TOKEN \
17+
-e GORELEASER_CONFIG \
18+
goreleaser/goreleaser release -f $GORELEASER_CONFIG --release-notes /tmp/shared/release.md
19+
ls -l results
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
MASTER_BRANCH=refs/remotes/origin/master
4+
VERSION_FILE=internal/model/version/VERSION
5+
6+
git config --global --add safe.directory "$PWD"
7+
git config user.email "[email protected]"
8+
git config user.name "cicd"
9+
10+
PREREL=$(git rev-list --count HEAD ^$MASTER_BRANCH)
11+
VERSION=$(cat $VERSION_FILE)
12+
FULL_VERSION="${VERSION}-pr${PREREL}"
13+
echo "$FULL_VERSION" > $VERSION_FILE
14+
git add $VERSION_FILE
15+
git commit -m "dummy prerel version"
16+
git tag "v${FULL_VERSION}"

.gitlab-ci-scripts/upload.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
REPO_TARGET="/prerel"
3+
if [ -n "$CI_COMMIT_TAG" ] && echo "$CI_COMMIT_TAG" | grep -qv '-'; then
4+
REPO_TARGET="/preprod"
5+
fi
6+
7+
# ssh-key-script
8+
[ -e /tmp/ssh-private-keys/${REPO_USER} ] && {
9+
eval $(ssh-agent -s)
10+
cat /tmp/ssh-private-keys/${REPO_USER} | tr -d '\r' | ssh-add -
11+
test -d ~/.ssh || mkdir -p ~/.ssh
12+
chmod 700 ~/.ssh
13+
}
14+
[ -e /tmp/ssh-private-keys/known_hosts ] && {
15+
test -d ~/.ssh || mkdir -p ~/.ssh
16+
cp /tmp/ssh-private-keys/known_hosts ~/.ssh/known_hosts
17+
chmod 644 ~/.ssh/known_hosts
18+
}
19+
ssh-add -l
20+
ssh -o StrictHostKeyChecking=no "${REPO_USER}@${REPO_HOST}" "hostname -f"
21+
22+
# sign-repo function
23+
sign_repos() {
24+
ssh "${REPO_USER}@${REPO_HOST}" "~/ci-voodoo/ci-tools/sign-all-repos.sh -t ${REPO_TARGET}"
25+
}
26+
27+
upload_files() {
28+
UPLOAD_DIR=/tmp/package-upload
29+
ssh "${REPO_USER}@${REPO_HOST}" "rm -rf $UPLOAD_DIR && mkdir -p $UPLOAD_DIR"
30+
scp results/* "${REPO_USER}@${REPO_HOST}:${UPLOAD_DIR}"
31+
}
32+
33+
distribute_files() {
34+
ssh "${REPO_USER}@${REPO_HOST}" "~/ci-voodoo/ci-tools/distribute-local-packages.sh -t ${REPO_TARGET} -w mytoken"
35+
}
36+
37+
38+
# upload and sign
39+
upload_files
40+
distribute_files
41+
sign_repos

.gitlab-ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
image: golang:1.19
2+
stages:
3+
- build
4+
- test
5+
- lint
6+
- release
7+
8+
default:
9+
tags:
10+
- linux
11+
cache:
12+
paths:
13+
- .cache
14+
15+
16+
before_script:
17+
- mkdir -p .cache
18+
- export GOPATH=${CI_PROJECT_DIR}/.cache
19+
20+
test:
21+
stage: test
22+
script:
23+
- go test -v ./...
24+
25+
test_race:
26+
stage: test
27+
script:
28+
- go test -race -v ./...
29+
30+
lint:
31+
stage: lint
32+
before_script:
33+
- go install golang.org/x/lint/golint@latest
34+
script:
35+
- golint -set_exit_status ./...
36+
37+
vet:
38+
stage: lint
39+
script:
40+
- go vet ./...
41+
42+
build_server:
43+
stage: build
44+
script:
45+
- go build github.com/oidc-mytoken/server/cmd/mytoken-server
46+
47+
build_setup:
48+
stage: build
49+
script:
50+
- go build github.com/oidc-mytoken/server/cmd/mytoken-server/mytoken-setup
51+
52+
build_migratedb:
53+
stage: build
54+
script:
55+
- go build github.com/oidc-mytoken/server/cmd/mytoken-server/mytoken-migratedb
56+
57+
prerelease:
58+
stage: release
59+
image:
60+
name: docker:stable
61+
services:
62+
- docker:dind
63+
only:
64+
refs:
65+
- tags
66+
- prerel
67+
tags:
68+
- linux
69+
variables:
70+
GIT_STRATEGY: clone
71+
GIT_DEPTH: 0
72+
REPO_HOST: repo.data.kit.edu
73+
REPO_USER: cicd
74+
script:
75+
- docker run --rm -v $PWD:/tmp/mytoken -w /tmp/mytoken bitnami/git .gitlab-ci-scripts/set-prerel-version
76+
- .gitlab-ci-scripts/goreleaser.sh
77+
- .gitlab-ci-scripts/upload.sh
78+
after_script:
79+
- docker run --rm curlimages/curl -d "repo=github.com/oidc-mytoken/server" https://goreportcard.com/checks

0 commit comments

Comments
 (0)