From 0d5d3679b5dccc7ff59c233b0447163f4ad798c2 Mon Sep 17 00:00:00 2001 From: morph027 Date: Sun, 12 Apr 2020 13:43:49 +0200 Subject: [PATCH] initial commit --- .gitlab-ci.yml | 88 +++++++++++++++++++ .../usr/lib/systemd/system/gitea.service | 16 ++++ package_scripts/after-install.sh | 10 +++ repo/conf/distributions | 4 + 4 files changed, 118 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 package_root/usr/lib/systemd/system/gitea.service create mode 100644 package_scripts/after-install.sh create mode 100644 repo/conf/distributions diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..242be2e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,88 @@ +stages: + - package + - repo + - pages + +package: + stage: package + image: golang:latest + variables: + NAME: drone-server + URL: "https://gitea.io" + DESCRIPTION: "A painless self-hosted Git service." + ARTIFACTS: "usr" + script: + - export VERSION=$(echo ${CI_COMMIT_TAG} | cut -d'-' -f1) + - export PATCHLEVEL=$(echo ${CI_COMMIT_TAG} | cut -d'-' -f2) + - apt-get -qq update + - apt-get -qqy install ruby-dev ruby-ffi curl + - gem install specific_install + - gem specific_install https://github.com/root360/fpm.git all_fixes + - mkdir -p "${CI_PROJECT_DIR}/package_root/usr/bin" + - curl -sL -o "${CI_PROJECT_DIR}/package_root/usr/bin/gitea" "https://dl.gitea.io/gitea/${VERSION}/gitea-${VERSION}-linux-amd64" + - chmod +x "${CI_PROJECT_DIR}/package_root/usr/bin/gitea" + - fpm + --input-type dir + --output-type deb + --package "${CI_PROJECT_DIR}/gitea_${VERSION}-p${PATCHLEVEL}_amd64.deb" + --name "${NAME}" + --version "${VERSION}-p${PATCHLEVEL}" + --description "${DESCRIPTION}" + --maintainer "Stefan Heitmüller " + --url "${URL}" + --depends git + --deb-systemd "${CI_PROJECT_DIR}/package_root/usr/lib/systemd/system/${NAME}.service" + --deb-systemd-enable + --deb-systemd-auto-start + --deb-activate-noawait /etc/init.d + --prefix=/ + --after-install "${CI_PROJECT_DIR}/package_scripts/after-install.sh" + --chdir "${CI_PROJECT_DIR}/package_root" + $ARTIFACTS + artifacts: + paths: + - $CI_PROJECT_DIR/*.deb + only: + - tags + +reprepro: + cache: + untracked: true + paths: + - $CI_PROJECT_DIR/repo + key: reprepro + stage: repo + image: registry.gitlab.com/packaging/reprepro-multiple-versions:latest + script: + - echo "$SIGNING_KEY" > /tmp/key + - gpg --import /tmp/key + - rm -f /tmp/key + - test -f $CI_PROJECT_DIR/repo/gpg.key || gpg --export --armor "$SIGNING_KEY_ID" > $CI_PROJECT_DIR/repo/gpg.key + - sed -i 's,##SIGNING_KEY_ID##,'$SIGNING_KEY_ID',' repo/conf/distributions + - find $CI_PROJECT_DIR -type f -name "*.deb" -exec + reprepro + -b $CI_PROJECT_DIR/repo + includedeb + gitea + {} \+; + only: + - tags + +pages: + cache: + untracked: true + paths: + - $CI_PROJECT_DIR/repo + key: reprepro + policy: pull + stage: pages + image: ubuntu:focal + script: + - mkdir $CI_PROJECT_DIR/public + - cp -r $CI_PROJECT_DIR/repo/gpg.key $CI_PROJECT_DIR/repo/dists $CI_PROJECT_DIR/repo/pool $CI_PROJECT_DIR/public/ + artifacts: + paths: + - $CI_PROJECT_DIR/public + expire_in: 1 day + only: + - tags diff --git a/package_root/usr/lib/systemd/system/gitea.service b/package_root/usr/lib/systemd/system/gitea.service new file mode 100644 index 0000000..9115533 --- /dev/null +++ b/package_root/usr/lib/systemd/system/gitea.service @@ -0,0 +1,16 @@ +[Unit] +Description=Gitea (Git with a cup of tea) +After=network.target + +[Service] +RestartSec=2s +Type=simple +User=gitea +Group=gitea +WorkingDirectory=/var/lib/gitea/ +ExecStart=/usr/bin/gitea web -c /etc/gitea/app.ini +Restart=always +EnvironmentFile=/etc/default/gitea + +[Install] +WantedBy=multi-user.targe diff --git a/package_scripts/after-install.sh b/package_scripts/after-install.sh new file mode 100644 index 0000000..1b3daf0 --- /dev/null +++ b/package_scripts/after-install.sh @@ -0,0 +1,10 @@ +# https://docs.gitea.io/en-us/install-from-binary/ + +getent passwd gitea >/dev/null 2>&1 || adduser \ + --system \ + --shell /bin/bash \ + --gecos 'Gitea' \ + --group \ + --disabled-password \ + --home /home/gitea \ + gitea diff --git a/repo/conf/distributions b/repo/conf/distributions new file mode 100644 index 0000000..c58335f --- /dev/null +++ b/repo/conf/distributions @@ -0,0 +1,4 @@ +Codename: gitea +Components: main +Architectures: amd64 +SignWith: ##SIGNING_KEY_ID##