Skip to content

Commit 8b7d10a

Browse files
feat: rename workflow files and add alpine package management (#179)
Co-authored-by: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com>
1 parent 236a49e commit 8b7d10a

File tree

10 files changed

+162
-74
lines changed

10 files changed

+162
-74
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
*
33

44
# Include
5+
!alpine-packages.txt
56
!Dockerfile
67
!LICENSE
78
!README.md
8-
!show-versions.sh
9+
!entrypoint.sh
910
!pip

.github/workflows/auto-create-pull-request.yml renamed to .github/workflows/auto-pull-request-create.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: (Auto) Create Pull Request
1+
name: (Auto) Pull Request Create
22

33
on:
44
push:
@@ -14,7 +14,7 @@ permissions:
1414

1515
jobs:
1616
call:
17-
uses: devops-infra/.github/.github/workflows/reusable-auto-create-pull-request.yml@v1
17+
uses: devops-infra/.github/.github/workflows/reusable-auto-pull-request-create.yml@v1
1818
with:
1919
profile: dockerized
2020
secrets: inherit

.github/workflows/cron-check-dependencies.yml renamed to .github/workflows/cron-dependency-update.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: (Cron) Check dependencies
1+
name: (Cron) Dependency Update
22

33
on:
44
schedule:
@@ -13,7 +13,7 @@ permissions:
1313

1414
jobs:
1515
call:
16-
uses: devops-infra/.github/.github/workflows/reusable-cron-check-dependencies.yml@v1
16+
uses: devops-infra/.github/.github/workflows/reusable-cron-dependency-update.yml@v1
1717
with:
1818
profile: dockerized
1919
secrets: inherit

.github/workflows/manual-update-version.yml renamed to .github/workflows/manual-release-create.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: (Manual) Update Version
1+
name: (Manual) Release Create
22

33
on:
44
workflow_dispatch:
@@ -30,7 +30,7 @@ permissions:
3030

3131
jobs:
3232
call:
33-
uses: devops-infra/.github/.github/workflows/reusable-manual-update-version.yml@v1
33+
uses: devops-infra/.github/.github/workflows/reusable-manual-release-create.yml@v1
3434
with:
3535
bump-type: ${{ inputs.type }}
3636
explicit-version: ${{ inputs.version }}

Dockerfile

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
FROM alpine:3.23.3
22

3+
# Copy all needed files
4+
COPY pip/requirements.txt /tmp/requirements.txt
5+
COPY alpine-packages.txt /tmp/alpine-packages.txt
6+
COPY entrypoint.sh /usr/bin/
7+
38
# Install prerequisits
49
SHELL ["/bin/sh", "-euxo", "pipefail", "-c"]
510
RUN apk update --no-cache ;\
6-
apk add --no-cache \
7-
bash~=5.3 \
8-
docker=~=29.1 \
9-
make~=4.4 \
10-
ncurses~=6.5 \
11-
python3~=3.12 \
12-
py3-pip~=25.1
13-
14-
# List of Python packages
15-
COPY pip/requirements.txt /tmp/requirements.txt
16-
17-
# Python packages
18-
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
19-
RUN pip3 install --break-system-packages --no-cache-dir -r /tmp/requirements.txt
20-
21-
COPY show-versions.sh /usr/bin/
22-
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
23-
RUN chmod +x \
24-
/usr/bin/show-versions.sh ;\
25-
# Cleanup \
11+
xargs -r apk add --no-cache < /tmp/alpine-packages.txt ;\
12+
pip3 install --break-system-packages --no-cache-dir -r /tmp/requirements.txt ;\
13+
chmod +x /usr/bin/entrypoint.sh ;\
2614
rm -rf /var/cache/* ;\
2715
rm -rf /root/.cache/* ;\
2816
rm -rf /tmp/*
@@ -64,4 +52,4 @@ LABEL \
6452
repository="${REPO_URL}"
6553

6654
WORKDIR /data
67-
CMD ["show-versions.sh"]
55+
CMD ["entrypoint.sh"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ Recommended setup:
8686
- GitHub Actions: set repo variables for the four values above, and secrets for `DOCKER_TOKEN` and `GITHUB_TOKEN`.
8787

8888
Publish images without a release:
89-
- Run the `(Manual) Update Version` workflow with `build_only: true` to build and push images without tagging a release.
89+
- Run the `(Manual) Release Create` workflow with `build_only: true` to build and push images without tagging a release.

Taskfile.cicd.yml

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ tasks:
7979
exit $rc
8080
fi
8181
82-
version:get:
83-
desc: Get current version
82+
dependency:update:
83+
desc: Update repository dependencies not covered by dependabot
8484
cmds:
85-
- echo "{{.VERSION}}"
85+
- task: scripts:packages:update
8686

8787
version:set:
8888
desc: Validate version
@@ -242,45 +242,7 @@ tasks:
242242
- git config user.name "github-actions[bot]"
243243
- git config user.email "github-actions[bot]@users.noreply.github.com"
244244

245-
sync:all:
246-
desc: Sync all common files
247-
cmds:
248-
- task sync:configs
249-
- task sync:ignores
250-
- task sync:taskfiles
251-
252-
sync:configs:
253-
desc: Sync configuration files with devops-infra/.github
254-
cmds:
255-
- |
256-
echo "▶️ Syncing configuration files from devops-infra/.github..."
257-
curl -fsSL {{.CONFIGS_BASE_URL}}/.editorconfig -o ./.editorconfig
258-
curl -fsSL {{.CONFIGS_BASE_URL}}/.hadolint.yaml -o ./.hadolint.yaml
259-
curl -fsSL {{.CONFIGS_BASE_URL}}/.pre-commit-config.yaml -o ./.pre-commit-config.yaml
260-
curl -fsSL {{.CONFIGS_BASE_URL}}/.shellcheckrc -o ./.shellcheckrc
261-
curl -fsSL {{.CONFIGS_BASE_URL}}/.yamllint.yml -o ./.yamllint.yml
262-
git add .editorconfig .hadolint.yaml .pre-commit-config.yaml .shellcheckrc .yamllint.yml
263-
echo "✅ Synced configuration files"
264-
265-
sync:ignores:
266-
desc: Sync ignore files with devops-infra/.github
267-
cmds:
268-
- |
269-
echo "▶️ Syncing ignore files from devops-infra/.github..."
270-
curl -fsSL {{.CONFIGS_BASE_URL}}/.gitignore -o ./.gitignore
271-
curl -fsSL {{.CONFIGS_BASE_URL}}/.dockerignore -o ./.dockerignore
272-
git add .gitignore .dockerignore
273-
echo "✅ Synced ignore files"
274-
275-
sync:taskfiles:
276-
desc: Sync Taskfiles with devops-infra/.github
245+
version:get:
246+
desc: Get current version
277247
cmds:
278-
- |
279-
echo "▶️ Syncing Taskfiles from devops-infra/.github..."
280-
curl -fsSL {{.TASKFILES_BASE_URL}}/Taskfile.yml -o ./Taskfile.yml
281-
curl -fsSL {{.TASKFILES_BASE_URL}}/Taskfile.cicd.yml -o ./Taskfile.cicd.yml
282-
curl -fsSL {{.TASKFILES_BASE_URL}}/Taskfile.scripts.yml -o ./Taskfile.scripts.yml
283-
curl -fsSL {{.TASKFILES_BASE_URL}}/Taskfile.docker.yml -o ./Taskfile.docker.yml
284-
curl -fsSL {{.TASKFILES_BASE_URL}}/Taskfile.variables.yml -o ./Taskfile.variables.yml
285-
git add Taskfile*.yml
286-
echo "✅ Synced Taskfiles"
248+
- echo "{{.VERSION}}"

Taskfile.scripts.yml

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ tasks:
4949
- |
5050
echo "▶️ Running shellcheck..."
5151
set +e
52-
docker run --rm -i -v "$PWD:/work" -w /work koalaman/shellcheck:stable -x -S style show-versions.sh
52+
docker run --rm -i -v "$PWD:/work" -w /work koalaman/shellcheck:stable -x -S style entrypoint.sh
5353
rc=$?
5454
set -e
5555
if [ "$rc" -eq 0 ]; then
@@ -87,6 +87,137 @@ tasks:
8787
- git config user.name "github-actions[bot]"
8888
- git config user.email "github-actions[bot]@users.noreply.github.com"
8989

90+
packages:update:
91+
desc: Update Alpine package pins in alpine-packages.txt
92+
cmds:
93+
- |
94+
set -eu
95+
if [ ! -f Dockerfile ]; then
96+
echo "INFO: Dockerfile not found; nothing to update"
97+
exit 0
98+
fi
99+
if [ ! -f alpine-packages.txt ]; then
100+
echo "INFO: alpine-packages.txt not found; nothing to update"
101+
exit 0
102+
fi
103+
104+
base_image="$(sed -nE 's/^FROM[[:space:]]+([^[:space:]]+).*/\1/p' Dockerfile | head -1)"
105+
if [ -z "$base_image" ]; then
106+
echo "INFO: Could not resolve base image; nothing to update"
107+
exit 0
108+
fi
109+
110+
case "$base_image" in
111+
alpine:*|alpine)
112+
:
113+
;;
114+
*)
115+
echo "INFO: Base image is '$base_image', not Alpine; nothing to update"
116+
exit 0
117+
;;
118+
esac
119+
120+
alpine_line="${base_image#alpine:}"
121+
if [ "$alpine_line" = "$base_image" ] || [ -z "$alpine_line" ]; then
122+
echo "INFO: Could not parse Alpine version from '$base_image'; nothing to update"
123+
exit 0
124+
fi
125+
alpine_minor="$(printf '%s' "$alpine_line" | awk -F. '{print $1 "." $2}')"
126+
if ! printf '%s' "$alpine_minor" | grep -Eq '^[0-9]+\.[0-9]+$'; then
127+
echo "INFO: Unsupported Alpine version '$alpine_line'; nothing to update"
128+
exit 0
129+
fi
130+
alpine_repo="v${alpine_minor}"
131+
arch="x86_64"
132+
133+
normalize_minor() {
134+
version="$1"
135+
printf '%s' "$version" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/'
136+
}
137+
138+
fetch_index() {
139+
repo="$1"
140+
out="$2"
141+
url="https://dl-cdn.alpinelinux.org/alpine/${alpine_repo}/${repo}/${arch}/APKINDEX.tar.gz"
142+
curl --fail --silent --show-error "$url" | tar -O -zx APKINDEX > "$out"
143+
}
144+
145+
lookup_latest() {
146+
pkg="$1"
147+
for index in "$index_main" "$index_community"; do
148+
found="$(awk -v pkg="$pkg" '
149+
BEGIN { RS=""; FS="\n" }
150+
{
151+
p=""; v=""
152+
for (i=1; i<=NF; i++) {
153+
if ($i ~ /^P:/) p=substr($i,3)
154+
if ($i ~ /^V:/) v=substr($i,3)
155+
}
156+
if (p==pkg) { print v; exit }
157+
}
158+
' "$index")"
159+
if [ -n "$found" ]; then
160+
printf '%s' "$found"
161+
return 0
162+
fi
163+
done
164+
return 1
165+
}
166+
167+
mkdir -p .tmp
168+
index_main=".tmp/apkindex-main-${alpine_repo}-${arch}.txt"
169+
index_community=".tmp/apkindex-community-${alpine_repo}-${arch}.txt"
170+
fetch_index main "$index_main"
171+
fetch_index community "$index_community"
172+
173+
if ! grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$' alpine-packages.txt; then
174+
echo "INFO: No pinned Alpine packages (~=X.Y) found in alpine-packages.txt"
175+
exit 0
176+
fi
177+
178+
tmp_out=".tmp/alpine-packages.updated.txt"
179+
: > "$tmp_out"
180+
updated=0
181+
while IFS= read -r line || [ -n "$line" ]; do
182+
if [ -z "$line" ] || printf '%s' "$line" | grep -Eq '^[[:space:]]*#'; then
183+
echo "$line" >> "$tmp_out"
184+
continue
185+
fi
186+
if ! printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$'; then
187+
echo "$line" >> "$tmp_out"
188+
continue
189+
fi
190+
191+
pkg="$(printf '%s' "$line" | sed -E 's/^([a-zA-Z0-9+_.-]+)(=~|~=).*/\1/')"
192+
current_minor="$(printf '%s' "$line" | sed -E 's/^[a-zA-Z0-9+_.-]+(=~|~=)([0-9]+\.[0-9]+).*$/\2/')"
193+
latest_full="$(lookup_latest "$pkg" || true)"
194+
if [ -z "$latest_full" ]; then
195+
echo "WARN: Could not resolve latest version for $pkg; keeping $line"
196+
echo "$line" >> "$tmp_out"
197+
continue
198+
fi
199+
200+
latest_minor="$(normalize_minor "$latest_full")"
201+
if [ "$latest_minor" = "$current_minor" ]; then
202+
echo "OK: $pkg already up to date at $current_minor"
203+
echo "$pkg~=$current_minor" >> "$tmp_out"
204+
continue
205+
fi
206+
echo "UPDATE: $pkg $current_minor -> $latest_minor"
207+
echo "$pkg~=$latest_minor" >> "$tmp_out"
208+
updated=1
209+
done < alpine-packages.txt
210+
211+
if ! cmp -s alpine-packages.txt "$tmp_out"; then
212+
mv "$tmp_out" alpine-packages.txt
213+
else
214+
rm -f "$tmp_out"
215+
fi
216+
217+
if [ "$updated" -eq 0 ]; then
218+
echo "INFO: No Alpine package updates were required"
219+
fi
220+
90221
version:get:
91222
desc: Get current version
92223
cmds:

alpine-packages.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bash~=5.3
2+
docker~=29.1
3+
make~=4.4
4+
ncurses~=6.5
5+
python3~=3.12
6+
py3-pip~=25.1
File renamed without changes.

0 commit comments

Comments
 (0)