commit 29272e175d9aa1b84c5127a93ef34b5fd43b530d Author: Tommie Gannert Date: Sat Sep 11 11:37:29 2021 +0200 Initial commit of addlatest, workflow and configuration. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b5702c6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +# This is a basic workflow to help you get started with Actions + +name: Update Repository + +# Controls when the workflow will run +on: + #push: + # # If the configuration has changed, this ensures we apply updates. + # branches: [ main ] + + #schedule: + # # Upstream releases around once per month, so twice a week should be fine. + # - cron: '23 14 * * mon,thu' + + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + runs-on: ubuntu-latest + + steps: + - name: Install dependencies + run: DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends --yes gpg jq reprepro + + - name: Checkout + uses: actions/checkout@v2 + with: + # See https://github.com/marketplace/actions/github-push + persist-credentials: false + fetch-depth: 0 + + - name: Download and include package files + run: ./addlatest + + - name: Push changes + uses: ad-m/github-push-action@v0.6.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..336d32b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/tmp.addlatest.* diff --git a/addlatest b/addlatest new file mode 100755 index 0000000..98bcd2f --- /dev/null +++ b/addlatest @@ -0,0 +1,45 @@ +#!/bin/bash +# +# Downloads upstream releases and uses reprepro to update the +# repository in debian/. This is idempotent and doesn't clobber files +# if the latest releases is already included. +# + +set -e + +release_repo=tonarino/innernet + +has_changes() { + git status --porcelain --untracked-files=no | grep -q . +} + +main() { + local tmpd + tmpd="$(mktemp -d tmp.addlatest.XXXXXXXXXX)" + + ( + cd "$tmpd" + + wget -Olatest.json \ + -H'Accept: application/json' \ + "https://api.github.com/repos/$release_repo/releases/latest" + + cat latest.json \ + | jq -r '.assets[] | select(.name | endswith(".deb")) | (.name + " " + .url)' \ + | while read name url; do + wget --header='Accept: application/octet-stream' -O"$name" "$url" + reprepro -b ../debian includedeb unstable "$name" + done + + if has_changes; then + git \ + -c 'user.email=41898282+github-actions[bot]@users.noreply.github.com' \ + -c 'user.name=github-actions[bot]' \ + commit -m "Included release $release_repo@$(cat latest.json | jq -r '.name | ltrimstr("v")')." debian/{db,dists,pool} + else + echo 'No updates to commit.' + fi + ) +} + +main diff --git a/debian/conf/deboverride b/debian/conf/deboverride new file mode 100644 index 0000000..d6a7c2a --- /dev/null +++ b/debian/conf/deboverride @@ -0,0 +1,2 @@ +innernet-server Source innernet +innernet* $Component contrib diff --git a/debian/conf/distributions b/debian/conf/distributions new file mode 100644 index 0000000..77d28d8 --- /dev/null +++ b/debian/conf/distributions @@ -0,0 +1,8 @@ +Origin: Unofficial Innernet Debian repository +Label: innernet-debian +Description: APT repository for https://github.com/tonarino/innernet/. +Codename: bullseye +Suite: unstable +Architectures: amd64 +Components: contrib +DebOverride: deboverride diff --git a/debian/conf/options b/debian/conf/options new file mode 100644 index 0000000..10c27c2 --- /dev/null +++ b/debian/conf/options @@ -0,0 +1,2 @@ +verbose +ask-passphrase