Skip to content

zen-browser: lint template #39

zen-browser: lint template

zen-browser: lint template #39

Workflow file for this run

name: build
on:
push:
branches:
- master
paths:
- 'srcpkgs/**'
workflow_dispatch:
jobs:
build:
name: Build packages
runs-on: ubuntu-latest
container:
image: ghcr.io/void-linux/void-${{ matrix.config.libc }}-full:20250616R1
options: --platform ${{ matrix.config.platform }} --privileged
volumes:
- /dev:/dev
env:
ARCH: '${{ matrix.config.arch }}'
BOOTSTRAP: '${{ matrix.config.host }}'
TEST: '${{ matrix.config.test }}'
strategy:
fail-fast: false
matrix:
config:
- { arch: x86_64, host: x86_64, libc: glibc, platform: linux/amd64, test: 1 }
- { arch: aarch64, host: x86_64, libc: glibc, platform: linux/amd64, test: 0 }
- { arch: x86_64-musl, host: x86_64-musl, libc: musl, platform: linux/amd64, test: 1 }
- { arch: aarch64-musl, host: x86_64-musl, libc: musl, platform: linux/amd64, test: 0 }
permissions:
contents: write
steps:
- name: Prepare container
run: |
# switch to repo-ci mirror
mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
sed -i 's|repo-default|repo-ci|g' /etc/xbps.d/*-repository-*.conf
# install dependencies
xbps-install -Syu xbps && xbps-install -yu && xbps-install -y sudo bash curl git
# create non-root user
useradd -G xbuilder -M builder
- name: Checkout this repo
run: |
git clone --depth 1 "https://github.com/${{ github.repository }}.git" extra
cd extra
# we need the previous revision to diff against
if [ -n "${{ github.event.before }}" ] && [ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then
git fetch --no-tags origin "${{ github.event.before }}" --depth 1 || true
fi
git fetch --no-tags origin "${{ github.sha }}" --depth 1
git checkout --detach "${{ github.sha }}"
- name: Determine changed templates
id: changed
run: |
cd extra
base="${{ github.event.before }}"
tip="${{ github.sha }}"
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then
changed_pkgs=$(find srcpkgs -maxdepth 1 -mindepth 1 -type d -printf "%f ")
removed_pkgs=""
else
changed_pkgs=$(git diff --name-only "$base" "$tip" --diff-filter=AM -- 'srcpkgs/*/template' \
| cut -d/ -f2 \
| sort -u \
| tr '\n' ' ')
removed_pkgs=$(git diff --name-status "$base" "$tip" -- 'srcpkgs/*/template' \
| awk '$1=="D"{print $2}' \
| cut -d/ -f2 \
| sort -u \
| tr '\n' ' ')
fi
changed_pkgs="${changed_pkgs%% }"
removed_pkgs="${removed_pkgs%% }"
echo "Changed templates: ${changed_pkgs:-<none>}"
echo "Removed templates: ${removed_pkgs:-<none>}"
echo "pkgs=$changed_pkgs" >> "$GITHUB_OUTPUT"
echo "removed=$removed_pkgs" >> "$GITHUB_OUTPUT"
- name: Checkout void-packages
run: |
git clone https://github.com/void-linux/void-packages.git void-packages
cd void-packages
git checkout --detach master
- name: Merge templates and edit shlibs
run: |
echo "==> copying templates..."
cp -rv extra/srcpkgs/* void-packages/srcpkgs/
SHLIBS_FILE="void-packages/common/shlibs"
APPEND_FILE="extra/shlibs_append"
REMOVE_FILE="extra/shlibs_remove"
echo "==> updating common/shlibs..."
if [ -f "$REMOVE_FILE" ]; then
while IFS= read -r line; do
[ -z "$line" ] && continue
grep -vF "$line" "$SHLIBS_FILE" > "$SHLIBS_FILE.tmp" && mv "$SHLIBS_FILE.tmp" "$SHLIBS_FILE"
echo " - removed: $line"
done < "$REMOVE_FILE"
fi
if [ -f "$APPEND_FILE" ]; then
while IFS= read -r line; do
[ -z "$line" ] && continue
if ! grep -qF "$line" "$SHLIBS_FILE"; then
echo "$line" >> "$SHLIBS_FILE"
echo " + added: $line"
fi
done < "$APPEND_FILE"
fi
echo "=> applying inline edits..."
if [ -d "void-packages/srcpkgs/hyprutils/patches" ]; then
echo " - removing void-packages/srcpkgs/hyprutils/patches"
rm -rf void-packages/srcpkgs/hyprutils/patches
fi
- name: Prepare masterdir
run: |
cd void-packages
chown -R builder:builder . &&
sudo -Eu builder common/travis/set_mirror.sh &&
sudo -Eu builder common/travis/prepare.sh &&
common/travis/fetch-xtools.sh
- name: Build
id: build_step
run: |
export PATH="/opt/xbps/usr/bin/:$PATH"
cd void-packages
changed="${{ steps.changed.outputs.pkgs }}"
removed="${{ steps.changed.outputs.removed }}"
if [ -z "$changed" ]; then
echo "No changed templates, skipping build."
echo "built=" >> "$GITHUB_OUTPUT"
echo "failed=" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "$BOOTSTRAP" != "$ARCH" ]; then
arch="-a $ARCH"
fi
if [ "$TEST" = 1 ]; then
test="-Q"
fi
PKGS=$(sudo -Eu builder ./xbps-src $test sort-dependencies $changed)
built=""
failed=""
for pkg in ${PKGS}; do
if sudo -Eu builder ./xbps-src -j"$(nproc)" -s $arch $test pkg "${pkg}"; then
built="$built $pkg"
else
echo "!! build failed for ${pkg}"
failed="$failed $pkg"
fi
done
built="${built%% }"
failed="${failed%% }"
echo "Built packages: ${built:-<none>}"
echo "Failed packages: ${failed:-<none>}"
echo "built=$built" >> "$GITHUB_OUTPUT"
echo "failed=$failed" >> "$GITHUB_OUTPUT"
- name: Write failed list into repo branch
if: ${{ steps.build_step.outputs.failed != '' }}
env:
ACCESS_GIT: ${{ secrets.ACCESS_GIT }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
RESULT_NAME: ${{ matrix.config.arch }}
run: |
set -e
cd extra
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
BRANCH="repository-${RESULT_NAME}"
REMOTE="https://$REPO_OWNER:${ACCESS_GIT}@github.com/${REPO_OWNER}/${REPO_NAME}.git"
if git ls-remote --exit-code --heads "$REMOTE" "$BRANCH" >/dev/null 2>&1; then
git fetch "$REMOTE" "$BRANCH:$BRANCH"
git checkout "$BRANCH"
else
git checkout --orphan "$BRANCH"
find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
fi
echo "${{ steps.build_step.outputs.failed }}" | tr ' ' '\n' > build-failures-${{ matrix.config.arch }}.txt
git add build-failures-${{ matrix.config.arch }}.txt
if git diff --cached --quiet; then
echo "No changes to push for failures file."
else
git commit -m "Record build failures for ${{ matrix.config.arch }}"
git push "$REMOTE" "$BRANCH"
fi
- name: Sign
if: ${{ steps.changed.outputs.pkgs != '' || steps.changed.outputs.removed != '' }}
env:
PRIV_KEY: ${{ secrets.PRIV_KEY }}
XBPS_ARCH: ${{ matrix.config.arch }}
ACCESS_GIT: ${{ secrets.ACCESS_GIT }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
RESULT_NAME: ${{ matrix.config.arch }}
working-directory: void-packages/hostdir/binpkgs/
run: |
set -e
export PATH="/opt/xbps/usr/bin/:$PATH"
# 1. stash newly built packages away
mkdir -p /tmp/newpkgs
cp -v ./*.xbps /tmp/newpkgs/ 2>/dev/null || true
cp -v ./*.xbps.sig /tmp/newpkgs/ 2>/dev/null || true
# 2. pull existing repo branch
BRANCH="repository-${RESULT_NAME}"
REMOTE="https://$REPO_OWNER:${ACCESS_GIT}@github.com/${REPO_OWNER}/${REPO_NAME}.git"
mkdir -p /tmp/oldrepo
rm -f ./*
if git ls-remote --exit-code --heads "$REMOTE" "$BRANCH" >/dev/null 2>&1; then
git clone --depth 1 --branch "$BRANCH" "$REMOTE" /tmp/oldrepo
cp -v /tmp/oldrepo/*.xbps . 2>/dev/null || true
cp -v /tmp/oldrepo/*.xbps.sig . 2>/dev/null || true
cp -v /tmp/oldrepo/index* . 2>/dev/null || true
else
echo "No existing $BRANCH on remote, starting fresh."
fi
# 3. delete packages we just rebuilt successfully
for f in /tmp/newpkgs/*.xbps; do
[ -e "$f" ] || continue
base=$(basename "$f")
# pkgname = everything before the first -<digit>
pkgname=$(printf "%s\n" "$base" | sed -E 's/-[0-9].*$//')
# remove all versions/revisions of that package from current repo dir
rm -f "${pkgname}-"*.xbps "${pkgname}-"*.xbps.sig 2>/dev/null || true
done
# 4. also delete packages for templates that were removed
removed="${{ steps.changed.outputs.removed }}"
if [ -n "$removed" ]; then
echo "==> removing packages for deleted templates..."
for pkg in $removed; do
rm -f "${pkg}-"*.xbps "${pkg}-"*.xbps.sig 2>/dev/null || true
rm -f "${pkg}.xbps" "${pkg}.xbps.sig" 2>/dev/null || true
done
fi
# 5. copy the newly built packages back in
cp -v /tmp/newpkgs/* . 2>/dev/null || true
# 6. sign + reindex
printf "%s\n" "$PRIV_KEY" > private.pem
chmod 600 private.pem
xbps-rindex -a *.xbps || true
xbps-rindex -r "$PWD"
xbps-rindex -s --signedby "Encoded14 <linusken@tuta.io>" --privkey private.pem "$PWD"
xbps-rindex -S --privkey private.pem "$PWD"/*.xbps
xbps-rindex -c "$PWD"
rm -f private.pem
- name: Push binpkgs branch (per arch)
if: ${{ steps.changed.outputs.pkgs != '' || steps.changed.outputs.removed != '' }}
env:
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
ACCESS_GIT: ${{ secrets.ACCESS_GIT }}
RESULT_NAME: ${{ matrix.config.arch }}
run: |
set -e
cd extra
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
BRANCH="repository-${RESULT_NAME}"
REMOTE="https://$REPO_OWNER:${ACCESS_GIT}@github.com/${REPO_OWNER}/${REPO_NAME}.git"
if git ls-remote --exit-code --heads "$REMOTE" "$BRANCH" >/dev/null 2>&1; then
git fetch "$REMOTE" "$BRANCH"
git checkout -B "$BRANCH" FETCH_HEAD
else
git checkout --orphan "$BRANCH"
fi
mkdir -p /tmp/failfiles
cp build-failures-* /tmp/failfiles/ 2>/dev/null || true
find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
cp ../void-packages/hostdir/binpkgs/* ./
cp /tmp/failfiles/* . 2>/dev/null || true
git add -A
if git diff --cached --quiet; then
echo "No changes to push."
else
git commit -m "Update binary repository for ${RESULT_NAME}"
git push "$REMOTE" "$BRANCH"
fi