commit 5b28e83627a2fcbf008eeb11a131088bc9daae77 Author: Robert Kaussow Date: Sat Oct 9 13:51:41 2021 +0200 initial commit diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..0de1b6c --- /dev/null +++ b/.drone.yml @@ -0,0 +1,126 @@ +--- +kind: pipeline +name: test + +platform: + os: linux + arch: amd64 + +steps: + - name: markdownlint + image: thegeeklab/markdownlint-cli + commands: + - markdownlint 'README.md' + +trigger: + ref: + - refs/heads/main + - refs/pull/** + - refs/tags/** + +--- +kind: pipeline +name: build-container + +platform: + os: linux + arch: amd64 + +steps: + - name: package + image: thegeeklab/alpine-tools + commands: + - mkdir dist/ + - tar -C ./overlay -zcvf dist/container-library.tar.gz -X . + + - name: checksum + image: thegeeklab/alpine-tools + commands: + - cd dist/ && sha256sum * > ../sha256sum.txt + + - name: changelog-generate + image: thegeeklab/git-chglog + commands: + - git fetch -tq + - git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased} + depends_on: + - tags + + - name: changelog-format + image: thegeeklab/alpine-tools + commands: + - prettier CHANGELOG.md + - prettier -w CHANGELOG.md + depends_on: + - changelog-generate + + - name: publish-gitea + image: plugins/gitea-release + settings: + api_key: + from_secret: gitea_token + base_url: https://gitea.rknet.org + files: + - dist/* + - sha256sum.txt + note: CHANGELOG.md + overwrite: true + title: ${DRONE_TAG} + when: + ref: + - refs/tags/** + depends_on: + - publish-dockerhub + - publish-quay + +trigger: + ref: + - refs/heads/main + - refs/pull/** + - refs/tags/** + +depends_on: + - test + +--- +kind: pipeline +name: notifications + +platform: + os: linux + arch: amd64 + +steps: + - name: matrix + image: thegeeklab/drone-matrix + settings: + homeserver: + from_secret: matrix_homeserver + password: + from_secret: matrix_password + roomid: + from_secret: matrix_roomid + template: "Status: **{{ build.Status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}
Message: {{ commit.Message.Title }}" + username: + from_secret: matrix_username + when: + status: + - success + - failure + +trigger: + ref: + - refs/heads/main + - refs/tags/** + status: + - success + - failure + +depends_on: + - build-container + +--- +kind: signature +hmac: 3d3a49cd900fe822c6568d4f2f2e6e9d628ddf2aca147079658b117c8de92c45 + +... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f44447b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +CHANGELOG.md +dist/ diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..b59a114 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,6 @@ +--- +default: True +MD013: False +MD041: False +MD004: + style: dash diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..97e0b3e --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +.drone.yml +*.tpl.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8e54586 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Robert Kaussow + +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 above copyright notice and this permission notice (including the next +paragraph) 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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc228f8 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# container-library + +[![Build Status](https://img.shields.io/drone/build/docker/container-library?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/docker/container-library) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/docker/container-library/src/branch/main/LICENSE) + +Basic utilities script library to use in container images. + +## License + +This project is licensed under the MIT License - see the [LICENSE](https://gitea.rknet.org/docker/container-library/src/branch/main/LICENSE) file for details. diff --git a/overlay/usr/local/lib/log.sh b/overlay/usr/local/lib/log.sh new file mode 100644 index 0000000..399634e --- /dev/null +++ b/overlay/usr/local/lib/log.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +# Library for logging functions + +# Log the given message at the given level. All logs are written to stderr with a timestamp. +log() { + level="$1" + message="$2" + timestamp=$(date +"%Y-%m-%d %H:%M:%S") + script_name="$(basename "$0")" + printf >&2 "%s [%s] [%s] %s" "${timestamp}" "${level}" "$script_name" "${message}" +} + +# Log the given message at INFO level. All logs are written to stderr with a timestamp. +log_info() { + message="$1" + log "INFO" "$message" +} + +# Log the given message at WARN level. All logs are written to stderr with a timestamp. +log_warn() { + message="$1" + log "WARN" "$message" +} + +# Log the given message at ERROR level. All logs are written to stderr with a timestamp. +log_error() { + message="$1" + log "ERROR" "$message" +}