dpkg-deb rejects a control directory with mode 777, which is what mkdir -p produces on runners running with umask 000. Normalize the package tree after copying (directories 0755, files 0644, binary 0755) and build with dpkg-deb --root-owner-group so the archives record root:root ownership instead of the runner's uid.
145 lines
5.4 KiB
YAML
145 lines
5.4 KiB
YAML
name: package
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v[0-9]+.[0-9]+'
|
|
|
|
jobs:
|
|
apt:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: registry.rznet.fr/tchivert/ubuntu:act-latest
|
|
steps:
|
|
- name: Setup go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '>=1.26'
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0 # all history for all branches and tags
|
|
|
|
- name: Install dependencies
|
|
run: go mod download
|
|
|
|
- name: Run tests
|
|
run: |
|
|
go vet ./...
|
|
go test -race ./...
|
|
|
|
- name: Linux build amd64
|
|
run: GOOS=linux GOARCH=amd64 go build -o bin/rdns-linux-amd64
|
|
|
|
- name: Linux build arm64
|
|
run: GOOS=linux GOARCH=arm64 go build -o bin/rdns-linux-arm64
|
|
|
|
- name: Darwin build amd64
|
|
run: GOOS=darwin GOARCH=amd64 go build -o bin/rdns-darwin-amd64
|
|
|
|
- name: Darwin build arm64
|
|
run: GOOS=darwin GOARCH=arm64 go build -o bin/rdns-darwin-arm64
|
|
|
|
- name: Create deb dir tree
|
|
run: |
|
|
for arch in amd64 arm64; do
|
|
mkdir -p rdns-$arch/usr/local/bin
|
|
mkdir -p rdns-$arch/etc/rdns
|
|
mkdir -p rdns-$arch/DEBIAN
|
|
mkdir -p rdns-$arch/lib/systemd/system
|
|
mkdir -p rdns-$arch/etc/logrotate.d
|
|
mkdir -p rdns-$arch/etc/rsyslog.d
|
|
done
|
|
|
|
- name: Copy binaries
|
|
run: |
|
|
cp bin/rdns-linux-amd64 rdns-amd64/usr/local/bin/rdns
|
|
cp bin/rdns-linux-arm64 rdns-arm64/usr/local/bin/rdns
|
|
|
|
- name: Copy configuration example
|
|
run: |
|
|
cp -r conf/* rdns-amd64/etc/rdns/
|
|
cp -r conf/* rdns-arm64/etc/rdns/
|
|
|
|
- name: Copy service and log configs
|
|
run: |
|
|
for arch in amd64 arm64; do
|
|
cp utils/services/rdns.service rdns-$arch/lib/systemd/system/
|
|
cp utils/logrotate.d/rdns rdns-$arch/etc/logrotate.d/
|
|
cp utils/rsyslog.d/56-rdns.conf rdns-$arch/etc/rsyslog.d/
|
|
done
|
|
|
|
- name: Get version
|
|
run: |
|
|
TAG=${{ gitea.ref_name }}
|
|
echo "VERSION=${TAG#v}" | tee -a $GITEA_ENV
|
|
|
|
- name: Prepare amd64 control file
|
|
run: |
|
|
echo "Package: rdns" > rdns-amd64/DEBIAN/control
|
|
echo "Version: $VERSION" >> rdns-amd64/DEBIAN/control
|
|
echo "Installed-Size: $(du -sk rdns-amd64 | cut -f1)" >> rdns-amd64/DEBIAN/control
|
|
echo "Maintainer: tchivert <me@tchv.fr>" >> rdns-amd64/DEBIAN/control
|
|
echo "Architecture: amd64" >> rdns-amd64/DEBIAN/control
|
|
echo "Homepage: https://git.rznet.fr/tchivert/rdns-go" >> rdns-amd64/DEBIAN/control
|
|
echo "Description: caching and forwarding DNS resolver" >> rdns-amd64/DEBIAN/control
|
|
echo " Acts as a local recursive DNS resolver: forwards queries to" >> rdns-amd64/DEBIAN/control
|
|
echo " configured upstream nameservers and caches the responses." >> rdns-amd64/DEBIAN/control
|
|
|
|
- name: Prepare arm64 control file
|
|
run: |
|
|
echo "Package: rdns" > rdns-arm64/DEBIAN/control
|
|
echo "Version: $VERSION" >> rdns-arm64/DEBIAN/control
|
|
echo "Installed-Size: $(du -sk rdns-arm64 | cut -f1)" >> rdns-arm64/DEBIAN/control
|
|
echo "Maintainer: tchivert <me@tchv.fr>" >> rdns-arm64/DEBIAN/control
|
|
echo "Architecture: arm64" >> rdns-arm64/DEBIAN/control
|
|
echo "Homepage: https://git.rznet.fr/tchivert/rdns-go" >> rdns-arm64/DEBIAN/control
|
|
echo "Description: caching and forwarding DNS resolver" >> rdns-arm64/DEBIAN/control
|
|
echo " Acts as a local recursive DNS resolver: forwards queries to" >> rdns-arm64/DEBIAN/control
|
|
echo " configured upstream nameservers and caches the responses." >> rdns-arm64/DEBIAN/control
|
|
|
|
- name: Register conffiles
|
|
run: |
|
|
for arch in amd64 arm64; do
|
|
echo "/etc/rdns/hosts" > rdns-$arch/DEBIAN/conffiles
|
|
echo "/etc/rdns/rdns.zones" >> rdns-$arch/DEBIAN/conffiles
|
|
done
|
|
|
|
- name: Set deb file permissions
|
|
run: |
|
|
# Runners may use umask 000, which makes dpkg-deb reject the
|
|
# control directory (must be 0755-0775). Set permissions
|
|
# explicitly: directories 0755, files 0644, binary 0755.
|
|
for arch in amd64 arm64; do
|
|
find rdns-$arch -type d -exec chmod 0755 {} +
|
|
find rdns-$arch -type f -exec chmod 0644 {} +
|
|
chmod 0755 rdns-$arch/usr/local/bin/rdns
|
|
done
|
|
|
|
- name: Build deb files
|
|
run: |
|
|
dpkg-deb --build --root-owner-group rdns-amd64 bin/rdns-amd64.deb
|
|
dpkg-deb --build --root-owner-group rdns-arm64 bin/rdns-arm64.deb
|
|
|
|
- name: Create release
|
|
uses: https://gitea.com/actions/release-action@main
|
|
with:
|
|
draft: false
|
|
prerelease: false
|
|
files: |-
|
|
bin/**
|
|
api_key: "${{ secrets.RELEASE_TOKEN }}"
|
|
|
|
- name: Prepare apt repo upload
|
|
run: |
|
|
mv bin/rdns-amd64.deb rdns_$VERSION-1_amd64.deb
|
|
mv bin/rdns-arm64.deb rdns_$VERSION-1_arm64.deb
|
|
|
|
- name: Release packages
|
|
run: |
|
|
curl -s -u "${{ secrets.PACKAGE_TOKEN }}" --upload-file rdns_$VERSION-1_amd64.deb \
|
|
https://git.rznet.fr/api/packages/tchivert/debian/pool/stable/main/upload
|
|
curl -s -u "${{ secrets.PACKAGE_TOKEN }}" --upload-file rdns_$VERSION-1_arm64.deb \
|
|
https://git.rznet.fr/api/packages/tchivert/debian/pool/stable/main/upload
|