Empaquetage via NFPM #1
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/dist
|
49
Jenkinsfile
vendored
Normal file
49
Jenkinsfile
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
@Library('cadoles') _
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
dockerfile {
|
||||
label 'docker'
|
||||
filename 'Dockerfile'
|
||||
dir 'misc/ci'
|
||||
}
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build and publish packages') {
|
||||
when {
|
||||
anyOf {
|
||||
branch 'master'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
List<String> packagers = ['deb', 'rpm']
|
||||
packagers.each { pkgr ->
|
||||
sh "make NFPM_PACKAGER='${pkgr}' package"
|
||||
}
|
||||
|
||||
List<String> attachments = sh(returnStdout: true, script: "find dist -type f -name '*.deb' -or -name '*.rpm' -or -name '*.ipk'").split(' ')
|
||||
String releaseVersion = sh(returnStdout: true, script: "git describe --always | rev | cut -d '/' -f 1 | rev").trim()
|
||||
|
||||
String releaseBody = """
|
||||
_Publication automatisée réalisée par Jenkins._ [Voir le job](${env.RUN_DISPLAY_URL})
|
||||
"""
|
||||
|
||||
gitea.release('forge-jenkins', 'Cadoles', 'postgres-backup', [
|
||||
'attachments': attachments,
|
||||
'body': releaseBody,
|
||||
'releaseName': "${releaseVersion}",
|
||||
'releaseVersion': "${releaseVersion}"
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
12
Makefile
Normal file
12
Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
PACKAGE_VERSION ?= $(shell git describe --always | rev | cut -d '/' -f 1 | rev)
|
||||
NFPM_PACKAGER ?= deb
|
||||
|
||||
package: dist
|
||||
PACKAGE_VERSION=$(PACKAGE_VERSION) \
|
||||
nfpm package \
|
||||
--config nfpm.yml \
|
||||
--target ./dist \
|
||||
--packager $(NFPM_PACKAGER)
|
||||
|
||||
dist:
|
||||
mkdir -p dist
|
9
misc/ci/Dockerfile
Normal file
9
misc/ci/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM alpine:3.15
|
||||
|
||||
RUN apk add --no-cache make git curl jq bash openssl
|
||||
|
||||
RUN curl -k https://forge.cadoles.com/Cadoles/Jenkins/raw/branch/master/resources/com/cadoles/common/add-letsencrypt-ca.sh | bash
|
||||
|
||||
RUN wget https://github.com/goreleaser/nfpm/releases/download/v2.20.0/nfpm_2.20.0_Linux_x86_64.tar.gz \
|
||||
&& tar -xzf nfpm_2.20.0_Linux_x86_64.tar.gz -C /usr/local/bin \
|
||||
&& chmod +x /usr/local/bin/nfpm
|
10
misc/packaging/postgres-backup.service
Normal file
10
misc/packaging/postgres-backup.service
Normal file
@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Run PostgreSQL backup
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/pg_backup_rotated.sh -c /etc/postgres-backup/pg_backup.conf
|
||||
User=postgres
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
9
misc/packaging/postgres-backup.timer
Normal file
9
misc/packaging/postgres-backup.timer
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Timer for periodic execution of postgres-backup service.
|
||||
|
||||
[Timer]
|
||||
OnCalendar=daily
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
39
nfpm.yml
Normal file
39
nfpm.yml
Normal file
@ -0,0 +1,39 @@
|
||||
name: "postgres-backup"
|
||||
arch: "amd64"
|
||||
platform: "linux"
|
||||
version: "${PACKAGE_VERSION}"
|
||||
section: "default"
|
||||
priority: "extra"
|
||||
maintainer: "Cadoles <contact@cadoles.com>"
|
||||
description: |
|
||||
PostgreSQL automated backup scripts
|
||||
vendor: "Cadoles"
|
||||
homepage: "https://forge.cadoles.com/Cadoles/postgres-backup"
|
||||
license: "AGPL-3.0"
|
||||
contents:
|
||||
- src: script/pg_backup.sh
|
||||
dst: /usr/share/postgres-backup/pg_backup.sh
|
||||
file_info:
|
||||
mode: 0755
|
||||
- src: script/pg_backup_rotated.sh
|
||||
dst: /usr/share/postgres-backup/pg_backup_rotated.sh
|
||||
file_info:
|
||||
mode: 0755
|
||||
- src: /usr/share/postgres-backup/pg_backup.sh
|
||||
dst: /usr/bin/pg_backup.sh
|
||||
type: symlink
|
||||
- src: /usr/share/postgres-backup/pg_backup_rotated.sh
|
||||
dst: /usr/bin/pg_backup_rotated.sh
|
||||
type: symlink
|
||||
- src: conf/pg_backup.conf
|
||||
dst: /etc/postgres-backup/pg_backup.conf
|
||||
type: config|noreplace
|
||||
- src: misc/packaging/postgres-backup.timer
|
||||
dst: /usr/lib/systemd/system/postgres-backup.timer
|
||||
- src: misc/packaging/postgres-backup.service
|
||||
dst: /usr/lib/systemd/system/postgres-backup.service
|
||||
- dst: /var/backups/database/postgresql
|
||||
type: dir
|
||||
file_info:
|
||||
owner: postgres
|
||||
group: postgres
|
Loading…
Reference in New Issue
Block a user