-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
100 changed files
with
1,503 additions
and
557 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.