Skip to content

Commit

Permalink
Merge pull request #18 from malaupa/use-goreleaser
Browse files Browse the repository at this point in the history
add: debian packaging using goreleaser
  • Loading branch information
malaupa committed May 12, 2023
2 parents f895774 + f086b1f commit fb59d10
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 109 deletions.
7 changes: 7 additions & 0 deletions .chglog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
conventional-commits: false
deb:
distribution: ["jammy"]
urgency: "medium"
debug: false
owner: "The MMS Linux Dev Team <mmslinux-dev@t-systems-mms.com>"
package-name: "oc-daemon"
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: stable

- name: Test and Build
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: build --snapshot --clean
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json
25 changes: 0 additions & 25 deletions .github/workflows/go.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
workflow_dispatch:
push:
tags:
- "*"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Fetch Tags
run: git fetch --force --tags

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: stable

- name: Release
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json
15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Binaries for programs and plugins
*.dll
*.dylib
*.exe
*.exe~
*.dll
*.out
*.so
*.dylib

# Output of the go coverage tool, specifically when used with LiteIDE
# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Ignore dist
dist/
# Ignore our executables
oc-client
oc-daemon
oc-daemon-vpncscript
oc-daemon-vpncscript
112 changes: 112 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
before:
hooks:
- go mod tidy
- go test ./...
builds:
- id: oc-client
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
main: ./cmd/oc-client/main.go
binary: oc-client
ldflags:
- -s -w -X github.com/T-Systems-MMS/oc-daemon/internal/daemon.Version={{.Version}}-{{.Commit}}
- id: oc-daemon
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
main: ./cmd/oc-daemon/main.go
binary: oc-daemon
ldflags:
- -s -w -X github.com/T-Systems-MMS/oc-daemon/internal/daemon.Version={{.Version}}-{{.Commit}}
- id: oc-daemon-vpncscript
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
main: ./cmd/oc-daemon-vpncscript/main.go
binary: oc-daemon-vpncscript
ldflags:
- -s -w -X github.com/T-Systems-MMS/oc-daemon/internal/daemon.Version={{.Version}}-{{.Commit}}
archives:
- format: tar.gz
rlcp: true
wrap_in_directory: true
files:
- src: init/oc-daemon.service
dst: oc-daemon.service
info:
mode: 0644
- src: configs/oc-client.json
dst: example_config.json
info:
mode: 0644
- README.md
- LICENSE
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
nfpms:
- package_name: oc-daemon
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Arch }}"
vendor: Deutsche Telekom MMS GmbH
maintainer: The MMS Linux Dev Team <mmslinux-dev@t-systems-mms.com>
description: |-
OpenConnect Daemon
Wraps OpenConnect to enhance functionality for corporate Linux clients.
license: MIT
formats:
- deb
dependencies:
- "nftables"
- "openconnect"
bindir: /usr/bin
section: net
# important: this makes the package non native
release: "1"
priority: important
# chglog init -> generates changelog.yml
# chglog add --version v#.#.# -> after every tag, call in hook above?
# activate if https://github.com/goreleaser/nfpm/pull/656 is merged and used in goreleaser
# -> remove overrides
# changelog: "changelog.yml"
scripts:
postinstall: build/package/postinstall.sh
preremove: build/package/preremove.sh
postremove: build/package/postremove.sh
deb:
lintian_overrides:
- "no-manual-page"
- "no-changelog"
- "statically-linked-binary"
contents:
- src: init/oc-daemon.service
dst: /lib/systemd/system/
file_info:
mode: 0644
- src: configs/oc-client.json
dst: /usr/share/doc/oc-daemon/examples/
file_info:
mode: 0644
- src: copyright
dst: /usr/share/doc/oc-daemon/
file_info:
mode: 0644
release:
prerelease: auto
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
29 changes: 18 additions & 11 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
Copyright 2022 T-Systems Multimedia Solutions GmbH
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Copyright (c) Deutsche Telekom MMS GmbH

The above copyright notice and this permission notice shall be included in all copies or substantial portions of
the Software.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions build/package/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh -e
# taken from https://github.com/Debian/debhelper/blob/master/dh

UNIT='oc-daemon.service'

case "$1" in
'configure' | 'abort-upgrade' | 'abort-deconfigure' | 'abort-remove')
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask $UNIT >/dev/null || true

# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled $UNIT; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable $UNIT >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state $UNIT >/dev/null || true
fi
;;
esac
22 changes: 22 additions & 0 deletions build/package/postremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh -e
# taken from https://github.com/Debian/debhelper/blob/master/dh

UNIT='oc-daemon.service'

case "$1" in
'remove')
if [ -d /run/systemd/system ] ; then
systemctl --system daemon-reload >/dev/null || true
fi
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask $UNIT >/dev/null || true
fi
;;

'purge')
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge $UNIT >/dev/null || true
deb-systemd-helper unmask $UNIT >/dev/null || true
fi
;;
esac
12 changes: 12 additions & 0 deletions build/package/preremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh -e
# taken from https://github.com/Debian/debhelper/blob/master/dh

UNIT='oc-daemon.service'

case "$1" in
'remove')
if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ] ; then
deb-systemd-invoke stop $UNIT >/dev/null || true
fi
;;
esac
5 changes: 5 additions & 0 deletions copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files:
*
Copyright: 2023 Deutsche Telekom MMS GmbH
License: MIT
Loading

0 comments on commit fb59d10

Please sign in to comment.