diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1361a1c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +dist/ +.idea +config.toml +spiegel \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..8fe4a07 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,68 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +gitea_urls: + api: https://git.gnous.eu/api/v1 + download: https://git.gnous.eu + skip_tls_verify: false + +before: + hooks: + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + +archives: + - format: tar.gz + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + +nfpms: + - + id: spiegel + package_name: spiegel + file_name_template: "{{ .ConventionalFileName }}" + vendor: Ada + homepage: https://git.gnous.eu/ada/spiegel + maintainer: Ada + description: A light paste server + license: MPL-2.0 + formats: + - deb + - rpm + - archlinux + umask: 002 + provides: + - spiegel + contents: + - src: config.example.toml + dst: /etc/spiegel/config.toml + - src: deployment/goreleaser/spiegel.service + dst: /usr/lib/systemd/system/spiegel.service + scripts: + preinstall: "deployment/goreleaser/preinstall.sh" + preremove: "deployment/goreleaser/preremove.sh" + postremove: "deployment/goreleaser/postremove.sh" + +checksum: + algorithm: sha256 + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/.woodpecker/release.yaml b/.woodpecker/release.yaml new file mode 100644 index 0000000..19c9196 --- /dev/null +++ b/.woodpecker/release.yaml @@ -0,0 +1,11 @@ +steps: + - name: Release + image: golang:1.22.3 + commands: + - go install github.com/goreleaser/goreleaser@latest + - goreleaser release + secrets: [ gitea_token ] + when: + event: tag + repo: gnouseu/spiegel + depends_on: [] diff --git a/config.example.toml b/config.example.toml index c69d798..5818c30 100644 --- a/config.example.toml +++ b/config.example.toml @@ -1,4 +1,4 @@ -clonedirectory = "archive/" +clonedirectory = "/var/lib/spiegel/" interval = 10 [log] diff --git a/deployment/goreleaser/postremove.sh b/deployment/goreleaser/postremove.sh new file mode 100644 index 0000000..b6a802e --- /dev/null +++ b/deployment/goreleaser/postremove.sh @@ -0,0 +1,7 @@ +if getent passwd spiegel > /dev/null; then + userdel -r spiegel +fi + +if getent group spiegel > /dev/null; then + groupdel spiegel +fi \ No newline at end of file diff --git a/deployment/goreleaser/preinstall.sh b/deployment/goreleaser/preinstall.sh new file mode 100644 index 0000000..c457350 --- /dev/null +++ b/deployment/goreleaser/preinstall.sh @@ -0,0 +1,12 @@ +if ! getent group spiegel > /dev/null; then + groupadd -r spiegel +fi + +if ! getent passwd spiegel > /dev/null; then + useradd -r -d /var/lib/spiegel -s /sbin/nologin -g spiegel -c "Spiegel server" spiegel +fi +if ! test -d /var/lib/spiegel; then + mkdir -p /var/lib/spiegel + chmod 0750 /var/lib/spiegel + chown -R spiegel:spiegel /var/lib/spiegel +fi diff --git a/deployment/goreleaser/preremove.sh b/deployment/goreleaser/preremove.sh new file mode 100644 index 0000000..176f5f0 --- /dev/null +++ b/deployment/goreleaser/preremove.sh @@ -0,0 +1 @@ +systemctl stop spiegel \ No newline at end of file diff --git a/deployment/goreleaser/spiegel.service b/deployment/goreleaser/spiegel.service new file mode 100644 index 0000000..ee7eb85 --- /dev/null +++ b/deployment/goreleaser/spiegel.service @@ -0,0 +1,12 @@ +[Unit] +Description=A light git repository mirror tools +After=network.target + +[Service] +Type=simple +User=spiegel + +ExecStart=/usr/bin/spiegel /etc/spiegel/config.toml + +[Install] +WantedBy=multi-user.target