Skip to content

Commit

Permalink
Improve packaging and distribution (see #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
vhotspur authored Mar 20, 2024
2 parents 28152cb + e1df184 commit f6af3b9
Show file tree
Hide file tree
Showing 17 changed files with 201 additions and 50 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
- name: Install
run: pip install .

- name: Show all plugins
run: |
nagios_d3s_check_health || true
echo
nagios_d3s_check_memory || true
echo
nagios_d3s_check_os_updates || true
echo
nagios_d3s_check_systemd_service --service sshd || true
39 changes: 39 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Linux packages

on: [push, pull_request]

env:
PACKAGE_NAME: d3s-nagios-plugins-git
PACKAGE_MAINTAINER: vhotspur
PACKAGE_SUMMARY: "Collection of various Nagios plugins"
PACKAGE_VERSION: 1.0.0

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
- name: Prepare install for Debian
run: |
pip install --root ${{github.workspace}}/pkg-deb --prefix /usr .
find ${{github.workspace}}/pkg-deb
- uses: jiro4989/build-deb-action@v3
with:
package_root: ${{github.workspace}}/pkg-deb
package: ${{ env.PACKAGE_NAME }}
maintainer: ${{ env.PACKAGE_MAINTAINER }}
desc: '${{ env.PACKAGE_SUMMARY }}'
version: '${{ env.PACKAGE_VERSION }}'
arch: 'amd64'

- uses: actions/upload-artifact@v4
with:
name: deb-package
path: |
./d3s*.deb
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
push:
tags:
- "v*.*.*"

env:
PACKAGE_NAME: d3s-nagios-plugins
PACKAGE_MAINTAINER: vhotspur
PACKAGE_SUMMARY: "Collection of various Nagios plugins"
PACKAGE_VERSION: 1.0.0

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
- name: Prepare install for Debian
run: |
pip install --root ${{github.workspace}}/pkg-deb --prefix /usr .
find ${{github.workspace}}/pkg-deb
- uses: jiro4989/build-deb-action@v3
with:
package_root: ${{github.workspace}}/pkg-deb
package: ${{ env.PACKAGE_NAME }}
maintainer: ${{ env.PACKAGE_MAINTAINER }}
desc: '${{ env.PACKAGE_SUMMARY }}'
version: '${{ env.PACKAGE_VERSION }}'
arch: 'amd64'

- name: Setup release notes
run: ./contrib/get-release-notes.sh ${{ env.PACKAGE_VERSION }} >gh-release-body.txt

- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: gh-release-body.txt
files: |
msim*.deb
msim*.rpm
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# D3S Nagios Plugins change log

All notable changes to D3S Nagios Plugins will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

### Added

### Changed

### Deprecated

### Removed


## v1.0.0 - 2024-03-20

### Changed

* Packaging setup (@vhotspur)
* Move changelog to a more structured format (@vhotspur)

### Added

* Automated releases (@vhotspur)
17 changes: 17 additions & 0 deletions contrib/get-release-notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Get release notes from change log file.

set -ueo pipefail

get_changelog_for() {
# Find text between header lines and remove those header lines
sed -n -e "/^## v${1} - 20[0-9][0-9]-[01][0-9]-[0123][0-9]$/,/^## v/{/^## v/d;p}"
}

strip_empty_lines() {
# https://unix.stackexchange.com/a/552195
sed -e '/./,$!d' -e :a -e '/^\n*$/{$d;N;ba' -e '}'
}

get_changelog_for "$1" < "CHANGELOG.md" | strip_empty_lines
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"

29 changes: 29 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[metadata]
name = d3s-nagios-plugins
version = 1.0
author = Vojtech Horky
author_email = horky@d3s.mff.cuni.cz
description = Collection of various Nagios plugins
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/d-iii-s/d3s-nagios-plugins
keywords = Nagios monitoring
classifiers =
License :: OSI Approved :: Apache 2 License

[options]
package_dir =
= src
packages = find:
python_requires = >=3.8
zip_safe = False

[options.packages.find]
where = src

[options.entry_points]
console_scripts =
nagios_d3s_check_health = d3s.nagios_plugins.check_health:main
nagios_d3s_check_memory = d3s.nagios_plugins.check_memory:main
nagios_d3s_check_os_updates = d3s.nagios_plugins.check_os_updates:main
nagios_d3s_check_systemd_service = d3s.nagios_plugins.check_systemd_service:main
50 changes: 0 additions & 50 deletions setup.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f6af3b9

Please sign in to comment.