Repository navigation
Automate maintenance: package-update releases and Dependabot #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: github-actions | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| - package-ecosystem: docker | ||
| directory: /unbound | ||
| schedule: | ||
| interval: weekly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #!/usr/bin/env bash | ||
| # Compares the Alpine packages of a freshly built image with unbound/apk-packages.txt. | ||
| # On a difference it updates the list, bumps the patch version and adds a changelog entry. | ||
| # Usage (from the repository root): .github/scripts/package-update.sh IMAGE | ||
| # Writes changed=true|false and version=X.Y.Z to $GITHUB_OUTPUT when that variable is set. | ||
| set -euo pipefail | ||
|
|
||
| image=${1:?usage: .github/scripts/package-update.sh IMAGE} | ||
| lock=unbound/apk-packages.txt | ||
| config=unbound/config.yaml | ||
| changelog=unbound/CHANGELOG.md | ||
|
|
||
| output() { | ||
| if [ -n "${GITHUB_OUTPUT:-}" ]; then | ||
| echo "$1" >>"$GITHUB_OUTPUT" | ||
| fi | ||
| } | ||
|
|
||
| current=$(docker run --rm --entrypoint sh "$image" -c 'apk info -v 2>/dev/null | sort') | ||
| [ -n "$current" ] || { echo "error: no packages reported by $image" >&2; exit 1; } | ||
| previous=$(cat "$lock") | ||
|
|
||
| if [ "$current" = "$previous" ]; then | ||
| echo "No package changes." | ||
| output changed=false | ||
| exit 0 | ||
| fi | ||
|
|
||
| version=$(sed -nE 's/^version: "([0-9]+\.[0-9]+\.[0-9]+)"$/\1/p' "$config") | ||
| [ -n "$version" ] || { echo "error: cannot read version from $config" >&2; exit 1; } | ||
| IFS=. read -r major minor patch <<<"$version" | ||
| next="$major.$minor.$((patch + 1))" | ||
|
|
||
| [ "$(head -n 1 "$changelog")" = "# Changelog" ] || { echo "error: unexpected header in $changelog" >&2; exit 1; } | ||
|
|
||
| changes=$(awk ' | ||
| function pkg_name(s, n) { n = s; sub(/-[^-]+-r[0-9]+$/, "", n); return n } | ||
| NR == FNR { n = pkg_name($0); old[n] = substr($0, length(n) + 2); next } | ||
| { n = pkg_name($0); new[n] = substr($0, length(n) + 2) } | ||
| END { | ||
| for (n in new) { | ||
| if (!(n in old)) printf " - `%s` %s (added)\n", n, new[n] | ||
| else if (old[n] != new[n]) printf " - `%s` %s → %s\n", n, old[n], new[n] | ||
| } | ||
| for (n in old) if (!(n in new)) printf " - `%s` %s (removed)\n", n, old[n] | ||
| }' <(printf '%s\n' "$previous") <(printf '%s\n' "$current") | sort) | ||
|
|
||
| printf '%s\n' "$current" >"$lock" | ||
| sed -i -E "s/^version: \"$version\"$/version: \"$next\"/" "$config" | ||
| { | ||
| printf '# Changelog\n\n## %s\n\n- Rebuilt with updated Alpine packages:\n%s\n\n' "$next" "$changes" | ||
| tail -n +3 "$changelog" | ||
| } >"$changelog.tmp" | ||
| mv "$changelog.tmp" "$changelog" | ||
|
|
||
| echo "Package changes detected, prepared $next:" | ||
| printf '%s\n' "$changes" | ||
| output changed=true | ||
| output "version=$next" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: Package updates | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "17 4 * * 1" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| concurrency: | ||
| group: package-updates | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| update: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7.0.1 | ||
|
|
||
| - name: Build image with current Alpine packages | ||
| run: docker build --pull --no-cache -t unbound-pkg:ci unbound | ||
|
|
||
| - name: Compare package set | ||
| id: pkg | ||
| run: .github/scripts/package-update.sh unbound-pkg:ci | ||
|
|
||
| # Pushes made with GITHUB_TOKEN do not trigger the CI workflow, so the release is verified here. | ||
| - name: Smoke test | ||
| if: steps.pkg.outputs.changed == 'true' | ||
| run: | | ||
| command -v dig >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq dnsutils; } | ||
| tests/smoke.sh unbound-pkg:ci --hardened | ||
|
|
||
| - name: Home Assistant app linter | ||
| if: steps.pkg.outputs.changed == 'true' | ||
| uses: frenck/action-addon-linter@v2.21.1 | ||
| with: | ||
| path: "./unbound" | ||
|
|
||
| - name: Commit release | ||
| if: steps.pkg.outputs.changed == 'true' | ||
| env: | ||
| VERSION: ${{ steps.pkg.outputs.version }} | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git add unbound/apk-packages.txt unbound/config.yaml unbound/CHANGELOG.md | ||
| git commit -m "Release ${VERSION} with updated Alpine packages" | ||
| git push origin "HEAD:${GITHUB_REF_NAME}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| alpine-baselayout-3.7.2-r1 | ||
| alpine-baselayout-data-3.7.2-r1 | ||
| alpine-keys-2.6-r0 | ||
| alpine-release-3.24.1-r0 | ||
| apk-tools-3.0.6-r0 | ||
| busybox-1.37.0-r31 | ||
| busybox-binsh-1.37.0-r31 | ||
| ca-certificates-bundle-20260611-r0 | ||
| dnssec-root-20250524-r0 | ||
| hiredis-1.3.0-r0 | ||
| libapk-3.0.6-r0 | ||
| libcrypto3-3.5.7-r0 | ||
| libevent-2.1.13-r0 | ||
| libexpat-2.8.4-r0 | ||
| libssl3-3.5.7-r0 | ||
| musl-1.2.6-r2 | ||
| musl-utils-1.2.6-r2 | ||
| nghttp2-libs-1.69.0-r0 | ||
| protobuf-c-1.5.2-r2 | ||
| scanelf-1.3.9-r1 | ||
| ssl_client-1.37.0-r31 | ||
| unbound-1.25.2-r1 | ||
| unbound-libs-1.25.2-r1 | ||
| zlib-1.3.2-r0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the
ubuntu-latestrunner, this plaindocker buildonly builds the native amd64 image. Unlike.github/workflows/ci.yml, which explicitly builds bothlinux/amd64andlinux/arm64, this workflow then commits the release withGITHUB_TOKEN, and its own comment notes that this push will not trigger CI. Consequently, an Alpine package update that fails to build or run on aarch64 can be published automatically to supported aarch64 users without that architecture ever being checked; build the arm64 target before the commit as well.Useful? React with 👍 / 👎.