ci: goreleaser
This commit is contained in:
parent
1a2a37825c
commit
ad19c98615
7 changed files with 211 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,4 +1,4 @@
|
|||
.crush
|
||||
CRUSH.md
|
||||
config.yml
|
||||
|
||||
dist/
|
||||
|
|
|
|||
145
.goreleaser.yml
Normal file
145
.goreleaser.yml
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
version: 2
|
||||
|
||||
project_name: scron
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
- go generate ./...
|
||||
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- "386"
|
||||
- amd64
|
||||
- arm
|
||||
- arm64
|
||||
goarm:
|
||||
- "6"
|
||||
- "7"
|
||||
main: ./
|
||||
binary: scron
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
|
||||
|
||||
|
||||
nfpms:
|
||||
- id: scron
|
||||
package_name: scron
|
||||
vendor: SCRON Project
|
||||
homepage: https://git.keks.cloud/kekskurse/scron
|
||||
maintainer: SCRON Maintainers <maintainer@example.com>
|
||||
description: |-
|
||||
A lightweight, efficient cron-like scheduler written in Go.
|
||||
SCRON executes shell commands at specified intervals with precise timing
|
||||
and comprehensive logging support.
|
||||
license: MIT
|
||||
formats:
|
||||
- deb
|
||||
- rpm
|
||||
- apk
|
||||
bindir: /usr/bin
|
||||
section: utils
|
||||
priority: optional
|
||||
file_name_template: "{{ .ConventionalFileName }}"
|
||||
contents:
|
||||
- src: config.yml
|
||||
dst: /etc/scron/config.yml
|
||||
type: config|noreplace
|
||||
file_info:
|
||||
mode: 0644
|
||||
- src: scripts/scron.service
|
||||
dst: /etc/systemd/system/scron.service
|
||||
file_info:
|
||||
mode: 0644
|
||||
- dst: /etc/scron
|
||||
type: dir
|
||||
file_info:
|
||||
mode: 0755
|
||||
scripts:
|
||||
postinstall: scripts/postinstall.sh
|
||||
preremove: scripts/preremove.sh
|
||||
postremove: scripts/postremove.sh
|
||||
dependencies:
|
||||
- bash
|
||||
- systemd
|
||||
recommends:
|
||||
- logrotate
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
||||
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
use: github
|
||||
filters:
|
||||
exclude:
|
||||
- "^docs:"
|
||||
- "^test:"
|
||||
- "^ci:"
|
||||
- "^chore:"
|
||||
- "^style:"
|
||||
groups:
|
||||
- title: Features
|
||||
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
|
||||
order: 0
|
||||
- title: 'Bug fixes'
|
||||
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
|
||||
order: 1
|
||||
- title: 'Performance improvements'
|
||||
regexp: '^.*?perf(\([[:word:]]+\))??!?:.+$'
|
||||
order: 2
|
||||
- title: Others
|
||||
order: 999
|
||||
|
||||
gitea_urls:
|
||||
api: https://git.keks.cloud/api/v1/
|
||||
download: https://git.keks.cloud
|
||||
skip_tls_verify: false
|
||||
|
||||
release:
|
||||
gitea:
|
||||
owner: kekskurse
|
||||
name: scron
|
||||
draft: false
|
||||
prerelease: auto
|
||||
mode: replace
|
||||
header: |
|
||||
## SCRON {{ .Tag }}
|
||||
|
||||
A lightweight, efficient cron-like scheduler written in Go.
|
||||
footer: |
|
||||
## Installation
|
||||
|
||||
### Binary Installation
|
||||
Download the appropriate binary for your system from the assets above.
|
||||
|
||||
### Debian/Ubuntu (.deb package)
|
||||
```bash
|
||||
wget https://git.keks.cloud/kekskurse/scron/releases/download/{{ .Tag }}/scron_{{ .Version }}_linux_amd64.deb
|
||||
sudo dpkg -i scron_{{ .Version }}_linux_amd64.deb
|
||||
```
|
||||
|
||||
### RPM-based systems (.rpm package)
|
||||
```bash
|
||||
wget https://git.keks.cloud/kekskurse/scron/releases/download/{{ .Tag }}/scron_{{ .Version }}_linux_amd64.rpm
|
||||
sudo rpm -i scron_{{ .Version }}_linux_amd64.rpm
|
||||
```
|
||||
|
||||
### Alpine Linux (.apk package)
|
||||
```bash
|
||||
wget https://git.keks.cloud/kekskurse/scron/releases/download/{{ .Tag }}/scron_{{ .Version }}_linux_amd64.apk
|
||||
sudo apk add --allow-untrusted scron_{{ .Version }}_linux_amd64.apk
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Edit configuration: `/etc/scron/config.yml` (for package installs) or `config.yml` (for binary)
|
||||
2. Start the service: `sudo systemctl start scron` (package) or `./scron` (binary)
|
||||
3. View logs: `sudo journalctl -u scron -f` (package) or check stdout (binary)
|
||||
name_template: "{{.ProjectName}}-v{{.Version}}"
|
||||
|
|
@ -1,10 +1,22 @@
|
|||
when:
|
||||
- event: push
|
||||
- event: pull_request
|
||||
- event: tag
|
||||
|
||||
steps:
|
||||
test:
|
||||
image: golang:1.24-alpine
|
||||
commands:
|
||||
- go mod download
|
||||
- go test ./...
|
||||
when:
|
||||
- event: [push, pull_request]
|
||||
|
||||
release:
|
||||
image: goreleaser/goreleaser:latest
|
||||
commands:
|
||||
- goreleaser release --clean
|
||||
secrets: [gitea_token]
|
||||
when:
|
||||
- event: tag
|
||||
|
||||
|
|
|
|||
12
scripts/postinstall.sh
Executable file
12
scripts/postinstall.sh
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Reload systemd and enable service
|
||||
systemctl daemon-reload
|
||||
systemctl enable scron
|
||||
|
||||
echo "SCRON installed successfully!"
|
||||
echo "Configuration file: /etc/scron/config.yml"
|
||||
echo "Start service: systemctl start scron"
|
||||
echo "View logs: journalctl -u scron -f"
|
||||
|
||||
13
scripts/postremove.sh
Executable file
13
scripts/postremove.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Remove systemd service file
|
||||
if systemctl is-enabled --quiet scron; then
|
||||
systemctl disable scron
|
||||
fi
|
||||
rm -f /etc/systemd/system/scron.service
|
||||
systemctl daemon-reload
|
||||
|
||||
# Optionally remove user (commented out to preserve logs/data)
|
||||
# userdel scron 2>/dev/null || true
|
||||
|
||||
10
scripts/preremove.sh
Executable file
10
scripts/preremove.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Stop and disable service before removal
|
||||
if systemctl is-active --quiet scron; then
|
||||
systemctl stop scron
|
||||
fi
|
||||
if systemctl is-enabled --quiet scron; then
|
||||
systemctl disable scron
|
||||
fi
|
||||
18
scripts/scron.service
Normal file
18
scripts/scron.service
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=SCRON - Lightweight Cron Scheduler
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/etc/scron
|
||||
ExecStart=/usr/bin/scron
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=scron
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Loading…
Add table
Reference in a new issue