First version
This commit is contained in:
commit
a80cf70af7
8 files changed
+192
No files matched your search
@@ -0,0 +1,116 @@
|
|||||||
|
name: Build and publish notifier
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "App version, without the v (e.g. 1.0.0)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
revision:
|
||||||
|
description: "Packaging revision"
|
||||||
|
required: false
|
||||||
|
default: "1"
|
||||||
|
type: string
|
||||||
|
|
||||||
|
env:
|
||||||
|
DISTRIBUTION: any
|
||||||
|
COMPONENT: main
|
||||||
|
SOURCE_OWNER: notifier
|
||||||
|
SOURCE_REPO: frontend-app-linux
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
select-runner:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
runner: ${{ steps.pick.outputs.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Check if local runner is online
|
||||||
|
id: pick
|
||||||
|
env:
|
||||||
|
API_TOKEN: ${{ secrets.GET_AVAILABLE_RUNNERS_API_TOKEN }}
|
||||||
|
API_URL: ${{ github.server_url }}/api/v1/admin/actions/runners
|
||||||
|
run: |
|
||||||
|
RUNNER="ubuntu-latest"
|
||||||
|
|
||||||
|
RESPONSE=$(curl -fsS --max-time 15 \
|
||||||
|
-H "Authorization: token ${API_TOKEN}" \
|
||||||
|
"${API_URL}" || echo "")
|
||||||
|
|
||||||
|
if [ -n "$RESPONSE" ]; then
|
||||||
|
ONLINE=$(echo "$RESPONSE" | jq '[.runners[]?
|
||||||
|
| select(.status != "offline")
|
||||||
|
| select(any(.labels[]?; .name == "local"))] | length')
|
||||||
|
if [ "${ONLINE:-0}" -gt 0 ]; then
|
||||||
|
RUNNER="local"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Runner API not reachable, falling back to ubuntu-latest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Selected runner: $RUNNER"
|
||||||
|
echo "runner=$RUNNER" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
build-and-publish:
|
||||||
|
needs: select-runner
|
||||||
|
runs-on: ${{ needs.select-runner.outputs.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Validate inputs
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
run: |
|
||||||
|
echo "$VERSION" | grep -Eq '^[0-9]+(\.[0-9]+)*$' || { echo "Bad version"; exit 1; }
|
||||||
|
echo "$REVISION" | grep -Eq '^[0-9]+$' || { echo "Bad revision"; exit 1; }
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install build tools
|
||||||
|
run: |
|
||||||
|
if ! command -v make >/dev/null || ! command -v curl >/dev/null; then
|
||||||
|
apt-get update && apt-get install -y make curl
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Fetch application source at the tag
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
|
SERVER: ${{ gitea.server_url }}
|
||||||
|
run: |
|
||||||
|
curl -sSL --fail \
|
||||||
|
-o /tmp/source.tar.gz \
|
||||||
|
"${SERVER}/${SOURCE_OWNER}/${SOURCE_REPO}/archive/v${VERSION}.tar.gz"
|
||||||
|
mkdir -p /tmp/source
|
||||||
|
tar -xzf /tmp/source.tar.gz -C /tmp/source --strip-components=1
|
||||||
|
|
||||||
|
- name: Build package
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
run: make VERSION="$VERSION" REVISION="$REVISION" SRC_DIR=/tmp/source
|
||||||
|
|
||||||
|
- name: Publish to Gitea package registry
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
UPLOADER: ${{ secrets.PACKAGE_UPLOAD_USERNAME }}
|
||||||
|
TOKEN: ${{ secrets.PACKAGE_UPLOAD_TOKEN }}
|
||||||
|
OWNER: ${{ gitea.repository_owner }}
|
||||||
|
SERVER: ${{ gitea.server_url }}
|
||||||
|
run: |
|
||||||
|
DEB="build/notifier_${VERSION}-${REVISION}_all.deb"
|
||||||
|
CODE=$(curl -sS -o /tmp/resp -w '%{http_code}' \
|
||||||
|
--user "${UPLOADER}:${TOKEN}" \
|
||||||
|
--upload-file "$DEB" \
|
||||||
|
"${SERVER}/api/packages/${OWNER}/debian/pool/${DISTRIBUTION}/${COMPONENT}/upload")
|
||||||
|
cat /tmp/resp; echo
|
||||||
|
case "$CODE" in
|
||||||
|
201) echo "Published $DEB" ;;
|
||||||
|
409) echo "This version/revision already exists; bump REVISION"; exit 1 ;;
|
||||||
|
*) echo "Upload failed with HTTP $CODE"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Keep the .deb as a workflow artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: notifier-deb
|
||||||
|
path: build/*.deb
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
build/
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
PACKAGE := notifier
|
||||||
|
VERSION ?=
|
||||||
|
REVISION ?= 1
|
||||||
|
SRC_DIR ?= src
|
||||||
|
SRC_FILES ?= api_client.py config.py credentials.py main.py models.py notifier.py poller.py
|
||||||
|
|
||||||
|
BUILD_DIR := build
|
||||||
|
STAGE := $(BUILD_DIR)/stage
|
||||||
|
DEB := $(BUILD_DIR)/$(PACKAGE)_$(VERSION)-$(REVISION)_all.deb
|
||||||
|
|
||||||
|
.PHONY: all check clean
|
||||||
|
|
||||||
|
all: $(DEB)
|
||||||
|
|
||||||
|
check:
|
||||||
|
@test -n "$(VERSION)" || { echo "VERSION is required (make VERSION=1.0.0)"; exit 1; }
|
||||||
|
@test -d "$(SRC_DIR)" || { echo "SRC_DIR '$(SRC_DIR)' not found"; exit 1; }
|
||||||
|
@for f in $(SRC_FILES); do \
|
||||||
|
test -f "$(SRC_DIR)/$$f" || { echo "Missing source file: $(SRC_DIR)/$$f"; exit 1; }; \
|
||||||
|
done
|
||||||
|
|
||||||
|
$(DEB): check
|
||||||
|
rm -rf $(STAGE)
|
||||||
|
mkdir -p $(STAGE)
|
||||||
|
cp -a pkg/. $(STAGE)/
|
||||||
|
for f in $(SRC_FILES); do \
|
||||||
|
install -D -m 644 "$(SRC_DIR)/$$f" "$(STAGE)/usr/lib/notifier/$$f"; \
|
||||||
|
done
|
||||||
|
sed -i 's/@VERSION@/$(VERSION)-$(REVISION)/' $(STAGE)/DEBIAN/control
|
||||||
|
chmod 755 $(STAGE)/DEBIAN $(STAGE)/DEBIAN/postinst $(STAGE)/DEBIAN/prerm $(STAGE)/usr/bin/notifier
|
||||||
|
dpkg-deb --build --root-owner-group $(STAGE) $@
|
||||||
|
@echo "Built $@"
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
Package: notifier
|
||||||
|
Version: @VERSION@
|
||||||
|
Section: utils
|
||||||
|
Priority: optional
|
||||||
|
Architecture: all
|
||||||
|
Depends: python3 (>= 3.10), python3-gi, gir1.2-notify-0.7, python3-httpx, python3-keyring, python3-secretstorage
|
||||||
|
Maintainer: Florian dev@gansejunge.com
|
||||||
|
Description: Desktop notifier that pulls notifications from the gateway
|
||||||
|
Polls the notification backend and shows desktop notifications.
|
||||||
|
Run "notifier set-key" once to store your API key.
|
||||||
|
|
||||||
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
if [ "$1" = "configure" ]; then
|
||||||
|
python3 -m compileall -q /usr/lib/notifier || true
|
||||||
|
systemctl --global enable notifier.service || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
if [ "$1" = "remove" ]; then
|
||||||
|
systemctl --global disable notifier.service || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
Executable
+2
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
exec /usr/bin/python3 /usr/lib/notifier/main.py "$@"
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Desktop notifier
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/notifier
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
Reference in new issue
Block a user