Skip to content

Commit b458e2f

Browse files
committed
github ci build
1 parent 66f0dc0 commit b458e2f

7 files changed

Lines changed: 343 additions & 6 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: "Build Debian packages with Podman"
2+
description: "Builds Debian packages for amd64 and arm64"
3+
author: "Thomas Willetal"
4+
5+
inputs:
6+
path:
7+
description: "Path to the Debian package directory (for changelog parsing)"
8+
required: true
9+
10+
outputs:
11+
version:
12+
description: "Parsed Debian version from changelog"
13+
value: ${{ steps.changelog.outputs.version }}
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Install dependencies (Podman, Python, dpkg-dev)
22+
shell: bash
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y podman python3-pip dpkg-dev
26+
27+
- name: Install podman-compose from PyPI
28+
shell: bash
29+
run: |
30+
pip install --upgrade pip
31+
pip install podman-compose
32+
33+
- name: Verify Podman and podman-compose
34+
shell: bash
35+
run: |
36+
podman --version
37+
podman-compose version
38+
39+
- name: Prepare build environment
40+
shell: bash
41+
run: make builder
42+
43+
- name: Build amd64 package
44+
shell: bash
45+
run: make build-deb
46+
47+
- name: Get Debian version
48+
id: changelog
49+
uses: ./.github/actions/get-deb-version
50+
with:
51+
path: ${{ inputs.path }}
52+
53+
- name: Show parsed version
54+
shell: bash
55+
run: echo "Version=${{ steps.changelog.outputs.version }}"
56+
57+
- name: Upload build artifacts
58+
if: success()
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: python-apt-${{ steps.changelog.outputs.version }}
62+
path: |
63+
build/*.deb
64+
build/*.changes
65+
build/*.buildinfo
66+
retention-days: 10
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "Get Debian Package Version"
2+
description: "Parse Debian version from a debian/changelog file"
3+
4+
inputs:
5+
path:
6+
description: "Path to the folder containing debian/changelog"
7+
required: false
8+
default: '.'
9+
10+
outputs:
11+
version:
12+
description: "Version extracted from debian/changelog"
13+
value: ${{ steps.parse.outputs.version }}
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Ensure dpkg-parsechangelog is available
19+
shell: bash
20+
run: |
21+
if ! command -v dpkg-parsechangelog >/dev/null 2>&1; then
22+
sudo apt-get update
23+
sudo apt-get install -y dpkg-dev
24+
fi
25+
26+
- name: Parse Debian version
27+
id: parse
28+
shell: bash
29+
working-directory: ${{ inputs.path }}
30+
run: |
31+
set -e
32+
if [ ! -f debian/changelog ]; then
33+
echo "error debian/changelog not found"
34+
exit 1
35+
fi
36+
VERSION=$(dpkg-parsechangelog --show-field Version)
37+
echo "Detected version: $VERSION"
38+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Prepare builder"
2+
description: "Prepares the build environment for Debian packages"
3+
author: "embtom"
4+
5+
inputs:
6+
service:
7+
description: "The service that was built"
8+
required: true
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
# - name: Set up QEMU
17+
# uses: docker/setup-qemu-action@v3
18+
19+
- name: Install Podman and podman-compose
20+
uses: ./.github/actions/setup-podman
21+
22+
- name: Prepare build environment
23+
shell: bash
24+
run: |
25+
SERVICE="${{ inputs.service }}"
26+
27+
if [ -z "$SERVICE" ]; then
28+
echo "ERROR: No service provided."
29+
exit 1
30+
fi
31+
32+
podman-compose -f docker-compose.yml \
33+
build "$SERVICE"
34+
35+
36+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Run build"
2+
description: "Run the build based on prepared builder environment"
3+
author: "embtom"
4+
5+
inputs:
6+
service:
7+
description: "The service that was used for built"
8+
required: true
9+
build-target:
10+
description: "The build target to run"
11+
required: true
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
# - name: Checkout repository (clean, discard local changes)
17+
# uses: actions/checkout@v4
18+
# with:
19+
# fetch-depth: 0 # full clone if needed
20+
# clean: true # ensures local untracked changes are removed
21+
# ref: ${{ github.sha }} # checkout exact commit that triggered workflow
22+
23+
- name: Run build
24+
shell: bash
25+
run: |
26+
SERVICE="${{ inputs.service }}"
27+
BUILD_TARGET="${{ inputs.build-target }}"
28+
if [ -z "$SERVICE" ]; then
29+
echo "ERROR: No service provided."
30+
exit 1
31+
fi
32+
podman-compose -f docker-compose.yml \
33+
run --rm "$SERVICE" "$BUILD_TARGET"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
name: "Setup Podman Environment"
3+
description: "Prepare Podman for rootless builds"
4+
5+
runs:
6+
using: "composite"
7+
steps:
8+
9+
- name: Remove Docker if installed
10+
shell: bash
11+
run: |
12+
if command -v docker >/dev/null 2>&1; then
13+
echo "Docker found removing"
14+
sudo systemctl stop docker docker.socket || true
15+
sudo apt-get purge -y \
16+
docker \
17+
docker.io \
18+
docker-ce \
19+
docker-ce-cli \
20+
containerd runc || true
21+
sudo apt-get autoremove -y
22+
sudo rm -rf /var/lib/docker /var/lib/containerd
23+
else
24+
echo "Docker not installed"
25+
fi
26+
27+
- name: Install dependencies
28+
shell: bash
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y \
32+
podman \
33+
python3-pip \
34+
fuse-overlayfs \
35+
uidmap \
36+
qemu-user-static
37+
38+
- name: Enable lingering for current user
39+
shell: bash
40+
run: |
41+
sudo loginctl enable-linger $USER || true
42+
43+
- name: Create Podman config directories
44+
shell: bash
45+
run: |
46+
mkdir -p ~/.config/containers
47+
mkdir -p ~/.local/share/containers
48+
49+
- name: Configure rootless Podman storage
50+
shell: bash
51+
run: |
52+
cat <<'EOF' > ~/.config/containers/storage.conf
53+
[storage]
54+
driver = "overlay"
55+
runroot = "/tmp/run-$(id -u)"
56+
graphroot = "$HOME/.local/share/containers/storage"
57+
[storage.options]
58+
mount_program = "/usr/bin/fuse-overlayfs"
59+
EOF
60+
61+
- name: Migrate Podman storage (if needed)
62+
shell: bash
63+
run: |
64+
podman system migrate || true
65+
66+
- name: Install podman-compose from PyPI
67+
shell: bash
68+
run: |
69+
pip install --upgrade pip
70+
pip install podman-compose
71+
72+
- name: Verify Podman and podman-compose
73+
shell: bash
74+
run: |
75+
podman --version
76+
podman-compose version

.github/workflows/ci-build.yml

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,56 @@ on:
99

1010
jobs:
1111
build:
12-
runs-on: ubuntu-latest
13-
12+
strategy:
13+
matrix:
14+
include:
15+
- platform: linux-amd64
16+
runner: ubuntu-24.04
17+
service: builder
18+
- platform: linux-arm64
19+
runner: ubuntu-24.04-arm
20+
service: builder-arm64
21+
22+
runs-on: ${{ matrix.runner }}
1423
steps:
1524
- name: Checkout repository
1625
uses: actions/checkout@v4
1726

18-
- name: hello
19-
shell: bash
20-
run: echo "hello"
21-
27+
- name: Get Debian version
28+
id: changelog
29+
uses: ./.github/actions/get-deb-version
30+
with:
31+
path: "."
32+
33+
- name: Show parsed version
34+
run: echo Version=${{ steps.changelog.outputs.version }}
35+
36+
- name: Prepare build environment
37+
uses: ./.github/actions/prepare-builder
38+
with:
39+
service: ${{ matrix.service }}
40+
41+
- name: Run build
42+
uses: ./.github/actions/run-build
43+
with:
44+
service: ${{ matrix.service }}
45+
build-target: build-deb
46+
47+
- name: Run build"
48+
uses: ./.github/actions/run-build
49+
with:
50+
service: ${{ matrix.service }}
51+
build-target: all
52+
53+
- name: Upload build artifacts
54+
if: success()
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: python-apt-${{ steps.changelog.outputs.version }}-${{ matrix.platform }}
58+
path: |
59+
build/*.deb
60+
build/*.changes
61+
build/*.buildinfo
62+
dist/*.whl
63+
retention-days: 10
64+

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Run Debian build
16+
id: builddeb
17+
uses: ./.github/actions/build-deb
18+
with:
19+
path: "uds-daemon-example"
20+
21+
- name: Show Debian version
22+
run: echo "Built version is ${{ steps.builddeb.outputs.version }}"
23+
24+
- name: Download build artifacts
25+
uses: actions/download-artifact@v4
26+
with:
27+
name: uds-daemon-example-${{ steps.builddeb.outputs.version }}
28+
path: ./release-artifacts
29+
30+
- name: Show downloaded files
31+
run: ls -l release-artifacts
32+
33+
- name: Create GitHub Release
34+
if: github.ref == 'refs/heads/main'
35+
env:
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
VERSION="${{ steps.builddeb.outputs.version }}"
39+
TAG="v${VERSION}"
40+
gh release create "${TAG}" \
41+
--title "Release ${TAG}" \
42+
--notes "Automated release for version ${TAG}" \
43+
./release-artifacts/*
44+
45+

0 commit comments

Comments
 (0)