Skip to content

Commit efbbd48

Browse files
committed
fix: Create RPM source tarball on host to avoid QEMU emulation issues
Move tarball creation from inside the container to the GitHub Actions host to work around QEMU emulation problems with tar operations.
1 parent 00fa18a commit efbbd48

File tree

3 files changed

+47
-41
lines changed

3 files changed

+47
-41
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ permissions:
1111
jobs:
1212
build-rpm:
1313
name: Build RPM Package (${{ matrix.arch }})
14-
runs-on: ubuntu-latest
14+
# Use native runners for each architecture to avoid QEMU emulation issues
15+
# QEMU has known problems with tar operations that cause rpmbuild to fail
16+
runs-on: ${{ matrix.runner }}
1517
strategy:
1618
matrix:
17-
arch: [x86_64, aarch64]
19+
include:
20+
- arch: x86_64
21+
runner: ubuntu-latest
22+
docker_platform: linux/amd64
23+
- arch: aarch64
24+
runner: ubuntu-24.04-arm
25+
docker_platform: linux/arm64
1826
fail-fast: false
1927

2028
steps:
@@ -23,11 +31,6 @@ jobs:
2331
with:
2432
fetch-depth: 0 # Fetch all history for git describe
2533

26-
- name: Set up QEMU
27-
uses: docker/setup-qemu-action@v3
28-
with:
29-
platforms: arm64,amd64
30-
3134
- name: Set up Docker Buildx
3235
uses: docker/setup-buildx-action@v3
3336

@@ -38,37 +41,42 @@ jobs:
3841
echo "version=$VERSION" >> $GITHUB_OUTPUT
3942
echo "Building version: $VERSION for architecture: ${{ matrix.arch }}"
4043
41-
- name: Set architecture-specific variables
42-
id: arch
43-
run: |
44-
if [ "${{ matrix.arch }}" = "x86_64" ]; then
45-
echo "docker_platform=linux/amd64" >> $GITHUB_OUTPUT
46-
echo "docker_arch=amd64" >> $GITHUB_OUTPUT
47-
else
48-
echo "docker_platform=linux/arm64" >> $GITHUB_OUTPUT
49-
echo "docker_arch=arm64" >> $GITHUB_OUTPUT
50-
fi
51-
5244
- name: Build RPM builder Docker image
5345
run: |
5446
docker buildx build \
55-
--platform ${{ steps.arch.outputs.docker_platform }} \
47+
--platform ${{ matrix.docker_platform }} \
5648
--load \
5749
--cache-from type=gha,scope=rpmbuild-${{ matrix.arch }} \
5850
--cache-to type=gha,mode=max,scope=rpmbuild-${{ matrix.arch }} \
5951
-f support/rpm/Dockerfile.rpmbuild \
6052
-t mygramdb-rpmbuild:${{ steps.version.outputs.version }}-${{ matrix.arch }} \
6153
.
6254
55+
- name: Create source tarball
56+
run: |
57+
VERSION="${{ steps.version.outputs.version }}"
58+
NAME="mygramdb"
59+
TARBALL="${NAME}-${VERSION}.tar.gz"
60+
61+
mkdir -p "$GITHUB_WORKSPACE/rpmsources"
62+
63+
# Create tarball using git archive for clean reproducible builds
64+
git archive --format=tar.gz --prefix="${NAME}-${VERSION}/" HEAD \
65+
> "$GITHUB_WORKSPACE/rpmsources/${TARBALL}"
66+
67+
echo "Created source tarball:"
68+
ls -lh "$GITHUB_WORKSPACE/rpmsources/${TARBALL}"
69+
6370
- name: Build RPM packages
6471
run: |
6572
# Create output directory in workspace
6673
mkdir -p "$GITHUB_WORKSPACE/dist/rpm"
6774
68-
# Run RPM build with absolute paths
75+
# Run RPM build with pre-created tarball mounted
6976
docker run --rm \
70-
--platform ${{ steps.arch.outputs.docker_platform }} \
77+
--platform ${{ matrix.docker_platform }} \
7178
-e MYGRAMDB_VERSION="${{ steps.version.outputs.version }}" \
79+
-v "$GITHUB_WORKSPACE/rpmsources:/rpmsources:ro" \
7280
-v "$GITHUB_WORKSPACE/dist:/workspace/dist" \
7381
mygramdb-rpmbuild:${{ steps.version.outputs.version }}-${{ matrix.arch }}
7482
@@ -99,7 +107,7 @@ jobs:
99107
echo "Testing RPM: $MAIN_RPM"
100108
101109
docker run --rm \
102-
--platform ${{ steps.arch.outputs.docker_platform }} \
110+
--platform ${{ matrix.docker_platform }} \
103111
-v "$GITHUB_WORKSPACE/dist:/dist" \
104112
almalinux:9 bash -c "
105113
set -e

support/rpm/Dockerfile.rpmbuild

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ RUN rpmdev-setuptree
3838

3939
WORKDIR /workspace
4040

41-
# Copy source files
42-
COPY . /workspace/
41+
# Copy spec file only (tarball will be mounted at runtime)
42+
COPY support/rpm/mygramdb.spec /root/rpmbuild/SPECS/
4343

4444
# Create build script
45+
# NOTE: The source tarball must be pre-created and mounted at /rpmsources/
46+
# This avoids QEMU emulation issues with tar operations inside containers
4547
RUN cat > /build-rpm.sh << 'EOF' && chmod +x /build-rpm.sh \
4648
&& echo "Build script created successfully"
4749
#!/bin/bash
@@ -62,21 +64,17 @@ NAME="mygramdb"
6264
echo -e "${YELLOW}Building ${NAME}-${VERSION}${NC}"
6365
echo -e "${YELLOW}Architecture: $(uname -m)${NC}"
6466

65-
# Create source tarball
66-
echo -e "${YELLOW}Creating source tarball...${NC}"
67+
# Expect tarball to be mounted at /rpmsources/
6768
TARBALL="${NAME}-${VERSION}.tar.gz"
68-
cd /workspace
69-
# Create tarball from workspace (excluding build artifacts)
70-
tar --exclude='./build' \
71-
--exclude='./dist' \
72-
--exclude='./.git' \
73-
--exclude='*.o' \
74-
--exclude='*.a' \
75-
--transform "s,^\.,${NAME}-${VERSION}," \
76-
-czf "/root/rpmbuild/SOURCES/${TARBALL}" .
77-
78-
# Copy spec file
79-
cp support/rpm/mygramdb.spec /root/rpmbuild/SPECS/
69+
if [ ! -f "/rpmsources/${TARBALL}" ]; then
70+
echo -e "${RED}Error: Source tarball not found at /rpmsources/${TARBALL}${NC}"
71+
echo -e "${RED}The tarball must be pre-created and mounted into the container.${NC}"
72+
exit 1
73+
fi
74+
75+
# Copy tarball to RPM SOURCES directory
76+
echo -e "${YELLOW}Copying source tarball to RPM build directory...${NC}"
77+
cp "/rpmsources/${TARBALL}" "/root/rpmbuild/SOURCES/${TARBALL}"
8078

8179
# Build RPM
8280
echo -e "${YELLOW}Building RPM package...${NC}"

support/rpm/mygramdb.spec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,19 @@ fi
136136
# Static build - no devel package needed
137137

138138
%changelog
139-
* Tue Nov 19 2025 libraz <libraz@libraz.net> - 1.2.0-1
139+
* Wed Nov 19 2025 libraz <libraz@libraz.net> - 1.2.0-1
140140
- Network ACL deny-by-default security enhancement
141141
- Configuration hot reload via SIGHUP
142142
- MySQL failover detection with server UUID tracking
143143
- Rate limiting and connection limits
144144
- See CHANGELOG.md for full details
145145

146-
* Sun Nov 17 2025 libraz <libraz@libraz.net> - 1.1.0-1
146+
* Mon Nov 17 2025 libraz <libraz@libraz.net> - 1.1.0-1
147147
- Query result caching with n-gram invalidation
148148
- Network ACL with CIDR filtering
149149
- Prometheus metrics endpoint
150150
- MySQL SSL/TLS support
151151
- See docs/releases/v1.1.0.md for details
152152

153-
* Wed Nov 13 2025 libraz <libraz@libraz.net> - 1.0.0-1
153+
* Thu Nov 13 2025 libraz <libraz@libraz.net> - 1.0.0-1
154154
- Initial RPM release

0 commit comments

Comments
 (0)