diff options
-rw-r--r-- | .gitlab-ci.yml | 30 | ||||
-rwxr-xr-x | build-release.sh | 26 |
2 files changed, 56 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..236b28c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,30 @@ +# source repo .gitlab-ci.yml +# requires a project access token (Project > Settings > Access tokens): +# - TOKEN with read_repository, write_repository; Role: Maintainer +# +# disable protected branch for Maintainer (Project > Settings > Repository): +# - main branch allowed to merge, allowed to push and merge maintainer; allowed to force push on +# +# requires the following gitlab variables (Project > Settings > CI/CD > Variables): +# - REPO_NAME: gitlab.com/<user>/<repo_name> (Protected, Masked, Expanded) +# - SOURCE_REPO: https://cgit.example.com/<repo_name> (Protected, Masked, Expanded) +# - TOKEN: <project access token> (Protected, Masked, Expanded) +# +stages: + - mirror + +mirror-from-cgit: + stage: mirror + image: ubuntu:20.04 + before_script: + - apt-get update -y && apt-get install -y git + - git config --global user.name "CI" + - git config --global user.email "ci@gitlab.com" + script: + - git clone --mirror "$SOURCE_REPO" temp_repo + - cd temp_repo + - TARGET_REPO="https://oauth2:$TOKEN@$REPO_NAME" + - git remote set-url origin "$TARGET_REPO" + - git push --prune --mirror + only: + - schedules diff --git a/build-release.sh b/build-release.sh new file mode 100755 index 0000000..7eaa8ad --- /dev/null +++ b/build-release.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +if ! command -v docker &>/dev/null; then + printf "%s\n" "[err] docker not found" + exit 1 +fi + +docker run --rm -it -v $(pwd):/mnt golang:latest /bin/bash -c ' +git config --global --add safe.directory /mnt +DEBIAN_FRONTEND=noninteractive apt-get update +DEBIAN_FRONTEND=noninteractive apt-get install -y make zip git + +( + cd /mnt + REPO_NAME=$(basename $(git remote get-url origin)) + REPO_NAME="${REPO_NAME%.git}" + + cd src/ + make all + mv build .. + cd .. + + zip -r "${REPO_NAME}-release.zip" LICENSE README.md build/ + rm -rf build +) +' |