Skip to content

Commit

Permalink
v0.6.1 (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmann authored Nov 11, 2022
2 parents 2588e16 + c79ea92 commit 3240221
Show file tree
Hide file tree
Showing 100 changed files with 1,503 additions and 557 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/go.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/release.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.idea/
/.cache/
/mytoken
/mytoken-setup
/mytoken-server
Expand All @@ -15,3 +16,4 @@ dist/
/docker/db.env
/docker/haproxy/haproxy.cfg
/docker/.env
/results/
19 changes: 19 additions & 0 deletions .gitlab-ci-scripts/goreleaser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
mkdir ../shared
first=$(grep '^## ' -nm1 CHANGELOG.md | cut -d':' -f1); \
second=$(grep '^## ' -nm2 CHANGELOG.md | tail -n1 | cut -d':' -f1); \
tail -n+$first CHANGELOG.md | head -n$(($second-$first)) > ../shared/release.md
GORELEASER_CONFIG=".goreleaser.yml"
if [ -n "$CI_COMMIT_TAG" ] && echo "$CI_COMMIT_TAG" | grep -qv '-'; then
GORELEASER_CONFIG=".goreleaser-release.yml"
fi
BASEDIR=/go/src/github.com/oidc-mytoken/server
docker run --rm --privileged \
-v "$PWD":"$BASEDIR" \
-w "$BASEDIR" \
-v "${PWD}/../shared":/tmp/shared \
-v /var/run/docker.sock:/var/run/docker.sock \
-e DOCKER_USERNAME -e DOCKER_PASSWORD \
-e GITHUB_TOKEN \
-e GORELEASER_CONFIG \
goreleaser/goreleaser release -f $GORELEASER_CONFIG --release-notes /tmp/shared/release.md
ls -l results
16 changes: 16 additions & 0 deletions .gitlab-ci-scripts/set-prerel-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

MASTER_BRANCH=refs/remotes/origin/master
VERSION_FILE=internal/model/version/VERSION

git config --global --add safe.directory "$PWD"
git config user.email "[email protected]"
git config user.name "cicd"

PREREL=$(git rev-list --count HEAD ^$MASTER_BRANCH)
VERSION=$(cat $VERSION_FILE)
FULL_VERSION="${VERSION}-pr${PREREL}"
echo "$FULL_VERSION" > $VERSION_FILE
git add $VERSION_FILE
git commit -m "dummy prerel version"
git tag "v${FULL_VERSION}"
41 changes: 41 additions & 0 deletions .gitlab-ci-scripts/upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

REPO_TARGET="/prerel"
if [ -n "$CI_COMMIT_TAG" ] && echo "$CI_COMMIT_TAG" | grep -qv '-'; then
REPO_TARGET="/preprod"
fi

# ssh-key-script
[ -e /tmp/ssh-private-keys/${REPO_USER} ] && {
eval $(ssh-agent -s)
cat /tmp/ssh-private-keys/${REPO_USER} | tr -d '\r' | ssh-add -
test -d ~/.ssh || mkdir -p ~/.ssh
chmod 700 ~/.ssh
}
[ -e /tmp/ssh-private-keys/known_hosts ] && {
test -d ~/.ssh || mkdir -p ~/.ssh
cp /tmp/ssh-private-keys/known_hosts ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
}
ssh-add -l
ssh -o StrictHostKeyChecking=no "${REPO_USER}@${REPO_HOST}" "hostname -f"

# sign-repo function
sign_repos() {
ssh "${REPO_USER}@${REPO_HOST}" "~/ci-voodoo/ci-tools/sign-all-repos.sh -t ${REPO_TARGET}"
}

upload_files() {
UPLOAD_DIR=/tmp/package-upload
ssh "${REPO_USER}@${REPO_HOST}" "rm -rf $UPLOAD_DIR && mkdir -p $UPLOAD_DIR"
scp results/* "${REPO_USER}@${REPO_HOST}:${UPLOAD_DIR}"
}

distribute_files() {
ssh "${REPO_USER}@${REPO_HOST}" "~/ci-voodoo/ci-tools/distribute-local-packages.sh -t ${REPO_TARGET} -w mytoken"
}


# upload and sign
upload_files
distribute_files
sign_repos
79 changes: 79 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
image: golang:1.19
stages:
- build
- test
- lint
- release

default:
tags:
- linux
cache:
paths:
- .cache


before_script:
- mkdir -p .cache
- export GOPATH=${CI_PROJECT_DIR}/.cache

test:
stage: test
script:
- go test -v ./...

test_race:
stage: test
script:
- go test -race -v ./...

lint:
stage: lint
before_script:
- go install golang.org/x/lint/golint@latest
script:
- golint -set_exit_status ./...

vet:
stage: lint
script:
- go vet ./...

build_server:
stage: build
script:
- go build github.com/oidc-mytoken/server/cmd/mytoken-server

build_setup:
stage: build
script:
- go build github.com/oidc-mytoken/server/cmd/mytoken-server/mytoken-setup

build_migratedb:
stage: build
script:
- go build github.com/oidc-mytoken/server/cmd/mytoken-server/mytoken-migratedb

prerelease:
stage: release
image:
name: docker:stable
services:
- docker:dind
only:
refs:
- tags
- prerel
tags:
- linux
variables:
GIT_STRATEGY: clone
GIT_DEPTH: 0
REPO_HOST: repo.data.kit.edu
REPO_USER: cicd
script:
- docker run --rm -v $PWD:/tmp/mytoken -w /tmp/mytoken bitnami/git .gitlab-ci-scripts/set-prerel-version
- .gitlab-ci-scripts/goreleaser.sh
- .gitlab-ci-scripts/upload.sh
after_script:
- docker run --rm curlimages/curl -d "repo=github.com/oidc-mytoken/server" https://goreportcard.com/checks
Loading

0 comments on commit 3240221

Please sign in to comment.