-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from oidc-mytoken/prerel
0.6
- Loading branch information
Showing
54 changed files
with
520 additions
and
2,292 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ config/config.yaml | |
config/config-dev.yaml | ||
/cmd/test | ||
dist/ | ||
.cache/ |
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 -p ../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/client | ||
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,54 @@ | ||
#!/bin/sh | ||
|
||
DEVSTRING="pr" | ||
VERSION_FILE=internal/model/version/VERSION | ||
|
||
while [ $# -gt 0 ]; do | ||
case $1 in | ||
--devstring) | ||
DEVSTRING="$2" | ||
shift # past argument | ||
shift # past value | ||
;; | ||
--version_file) | ||
VERSION_FILE="$2" | ||
shift # past argument | ||
shift # past value | ||
;; | ||
--*|-*) | ||
echo "Unknown option $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
git config user.email || { | ||
echo "Setting up git in CI" | ||
git config --global --add safe.directory "$PWD" | ||
git config user.email "[email protected]" | ||
git config user.name "cicd" | ||
} | ||
|
||
# Get master branch name: | ||
# use origin if exists | ||
# else use last found remote | ||
REMOTES=$(git remote show) | ||
for R in $REMOTES; do | ||
MASTER=master | ||
MASTER_BRANCH="refs/remotes/${R}/${MASTER}" | ||
#echo "Master-branch: ${MASTER_BRANCH}" | ||
[ "x${R}" = "xorigin" ] && break | ||
done | ||
|
||
PREREL=$(git rev-list --count HEAD ^"$MASTER_BRANCH") | ||
|
||
# use version file: | ||
VERSION=$(cat "$VERSION_FILE") | ||
PR_VERSION="${VERSION}-${DEVSTRING}${PREREL}" | ||
echo "$PR_VERSION" > "$VERSION_FILE" | ||
echo "$PR_VERSION" | ||
|
||
echo "$PR_VERSION" > "$VERSION_FILE" | ||
git add "$VERSION_FILE" | ||
git commit -m "dummy prerel version" | ||
git tag "v${PR_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,70 @@ | ||
image: golang:1.16 | ||
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 ./... | ||
|
||
staticcheck: | ||
image: golang:1.19 | ||
stage: lint | ||
before_script: | ||
- go install honnef.co/go/tools/cmd/staticcheck@latest | ||
script: | ||
- staticcheck ./... | ||
|
||
vet: | ||
stage: lint | ||
script: | ||
- go vet ./... | ||
|
||
build: | ||
stage: build | ||
script: | ||
- go build github.com/oidc-mytoken/client/cmd/mytoken | ||
|
||
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: | ||
- if [ -z "$CI_COMMIT_TAG" ]; then docker run --rm -v $PWD:/tmp/mytoken -w /tmp/mytoken bitnami/git .gitlab-ci-scripts/set-prerel-version.sh; fi; | ||
- .gitlab-ci-scripts/goreleaser.sh | ||
- .gitlab-ci-scripts/upload.sh | ||
after_script: | ||
- docker run --rm curlimages/curl -d "repo=github.com/oidc-mytoken/client" https://goreportcard.com/checks |
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,92 @@ | ||
project_name: mytoken | ||
before: | ||
hooks: | ||
- go mod tidy | ||
dist: results | ||
builds: | ||
- id: client | ||
main: ./cmd/mytoken/main.go | ||
binary: mytoken | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
ignore: | ||
- goos: windows | ||
goarch: arm64 | ||
flags: | ||
- -trimpath | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
archives: | ||
- replacements: | ||
darwin: macOS | ||
386: 32-bit | ||
amd64: 64-bit | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
nfpms: | ||
- id: client-pkg | ||
package_name: mytoken | ||
replacements: | ||
386: i386 | ||
file_name_template: "{{ .PackageName }}_{{ .Version }}_{{ .Arch }}" | ||
builds: | ||
- client | ||
homepage: https://mytoken-docs.data.kit.edu/ | ||
maintainer: Gabriel Zachmann <[email protected]> | ||
description: Mytoken is a command line client for the central web service mytoken. It can be used to easily obtain OpenID Connect access tokens across devices. | ||
license: MIT | ||
formats: | ||
- deb | ||
- rpm | ||
release: 1 | ||
section: misc | ||
bindir: /usr/bin | ||
contents: | ||
- src: config/example-config.yaml | ||
dst: /etc/mytoken/example-config.yaml | ||
type: config | ||
overrides: | ||
rpm: | ||
replacements: | ||
amd64: x86_64 | ||
file_name_template: "{{ .PackageName }}-{{ .Version }}.{{ .Arch }}" | ||
dockers: | ||
- goos: linux | ||
goarch: amd64 | ||
ids: | ||
- client | ||
image_templates: | ||
- "oidcmytoken/mytoken:latest" | ||
- "oidcmytoken/mytoken:{{ .Tag }}" | ||
- "oidcmytoken/mytoken:{{ .Major }}" | ||
- "oidcmytoken/mytoken:{{ .Major }}.{{ .Minor }}" | ||
dockerfile: cmd/mytoken/Dockerfile | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.title=mytoken" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
release: | ||
disable: true | ||
prerelease: auto | ||
draft: true | ||
github: | ||
owner: oidc-mytoken | ||
name: client | ||
name_template: "{{.ProjectName}} {{.Version}}" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' |
Oops, something went wrong.