pkg: arch: Move to script based workflow
This commit is contained in:
parent
da389ab837
commit
854c619a8f
77
.github/scripts/package/arch.sh
vendored
Normal file
77
.github/scripts/package/arch.sh
vendored
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
if [ -z "${1:-}" ]; then
|
||||||
|
$0 setup-builddeps
|
||||||
|
$0 setup-secureboot
|
||||||
|
$0 build-packages
|
||||||
|
$0 sign-packages
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
pacman()
|
||||||
|
{
|
||||||
|
command pacman --noconfirm "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
|
setup-builddeps)
|
||||||
|
# Update the container
|
||||||
|
pacman -Syu
|
||||||
|
|
||||||
|
# Install makepkg deps
|
||||||
|
pacman -S sudo binutils fakeroot base-devel git
|
||||||
|
|
||||||
|
# Install tools for singing the kernel for secureboot
|
||||||
|
pacman -S sbsigntools
|
||||||
|
;;
|
||||||
|
setup-secureboot)
|
||||||
|
if [ -z "${SB_KEY:-}" ]; then
|
||||||
|
echo "WARNING: No secureboot key configured, skipping signing."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install the surface secureboot certificate
|
||||||
|
echo "${SB_KEY}" | base64 -d > pkg/arch/kernel/MOK.key
|
||||||
|
cp pkg/keys/surface.crt pkg/arch/kernel/MOK.crt
|
||||||
|
;;
|
||||||
|
build-packages)
|
||||||
|
pushd pkg/arch/kernel || exit 1
|
||||||
|
|
||||||
|
# Fix permissions (can't makepkg as root)
|
||||||
|
echo "nobody ALL=(ALL) NOPASSWD: /usr/bin/pacman" >> /etc/sudoers
|
||||||
|
chown -R nobody .
|
||||||
|
|
||||||
|
# Package compression settings (Matches latest Arch)
|
||||||
|
export PKGEXT='.pkg.tar.zst'
|
||||||
|
export COMPRESSZST=(zstd -c -T0 --ultra -20 -)
|
||||||
|
export MAKEFLAGS="-j2"
|
||||||
|
|
||||||
|
# Build
|
||||||
|
su nobody --pty -p -s /bin/bash -c 'makepkg -sf --skippgpcheck --noconfirm'
|
||||||
|
|
||||||
|
# Prepare release
|
||||||
|
mkdir release
|
||||||
|
find . -name '*.pkg.tar.zst' -type f -exec mv {} release \;
|
||||||
|
|
||||||
|
popd || exit 1
|
||||||
|
;;
|
||||||
|
sign-packages)
|
||||||
|
if [ -z "${GPG_KEY:-}" ] || [ -z "${GPG_KEY_ID:-}" ]; then
|
||||||
|
echo "WARNING: No GPG key configured, skipping signing."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd pkg/arch/kernel/release || exit 1
|
||||||
|
|
||||||
|
# import GPG key
|
||||||
|
echo "${GPG_KEY}" | base64 -d | gpg --import --no-tty --batch --yes
|
||||||
|
|
||||||
|
# sign packages
|
||||||
|
find . -name '*.pkg.tar.zst' -type f -exec \
|
||||||
|
gpg --detach-sign --batch --no-tty -u "${GPG_KEY_ID}" {} \;
|
||||||
|
|
||||||
|
popd || exit 1
|
||||||
|
;;
|
||||||
|
esac
|
66
.github/scripts/repository/arch.sh
vendored
Normal file
66
.github/scripts/repository/arch.sh
vendored
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
pacman()
|
||||||
|
{
|
||||||
|
command pacman --noconfirm "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${GIT_REF:-}" ]; then
|
||||||
|
echo "GIT_REF is unset!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${GITHUB_REPOSITORY:-}" ]; then
|
||||||
|
echo "GITHUB_REPOSITORY is unset!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${SURFACEBOT_TOKEN:-}" ]; then
|
||||||
|
echo "SURFACEBOT_TOKEN is unset!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${BRANCH_STAGING:-}" ]; then
|
||||||
|
echo "BRANCH_STAGING is unset!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
REPONAME="$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f2)"
|
||||||
|
REPO="https://surfacebot:${SURFACEBOT_TOKEN}@github.com/linux-surface/repo.git"
|
||||||
|
|
||||||
|
# parse git tag from ref
|
||||||
|
GIT_TAG="${GIT_REF#refs/tags/}"
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
pacman -Syu
|
||||||
|
pacman -S base-devel git
|
||||||
|
|
||||||
|
# clone package repository
|
||||||
|
git clone -b "${BRANCH_STAGING}" "${REPO}" repo
|
||||||
|
|
||||||
|
# copy packages
|
||||||
|
find arch-latest -type f -exec cp {} repo/arch \;
|
||||||
|
pushd repo/arch || exit 1
|
||||||
|
|
||||||
|
# convert packages into references
|
||||||
|
while read -rd $'\n' FILE; do
|
||||||
|
echo "${REPONAME}:${GIT_TAG}/$(basename "${FILE}")" > "${FILE}.blob"
|
||||||
|
rm "${FILE}"
|
||||||
|
done <<< "$(find . -name '*.pkg.tar.zst')"
|
||||||
|
|
||||||
|
RAND="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 32 | head -n 1)"
|
||||||
|
BRANCH="${BRANCH_STAGING}-${RAND}"
|
||||||
|
|
||||||
|
# set git identity
|
||||||
|
git config --global user.name "surfacebot"
|
||||||
|
git config --global user.email "surfacebot@users.noreply.github.com"
|
||||||
|
|
||||||
|
# commit and push
|
||||||
|
git checkout -b "${BRANCH}"
|
||||||
|
git add .
|
||||||
|
git commit -m "Update Arch Linux ${REPONAME} package"
|
||||||
|
git push --set-upstream origin "${BRANCH}"
|
||||||
|
|
||||||
|
popd || exit 1
|
200
.github/workflows/arch.yml
vendored
200
.github/workflows/arch.yml
vendored
|
@ -1,146 +1,120 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'arch-*'
|
|
||||||
|
|
||||||
name: Arch
|
name: Arch
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GPG_KEY_ID: 56C464BAAC421453
|
GPG_KEY_ID: 56C464BAAC421453
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'arch-*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build Kernel
|
name: Build Kernel
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: archlinux
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Maximize disk space
|
||||||
uses: actions/checkout@v3
|
uses: easimon/maximize-build-space@master
|
||||||
|
with:
|
||||||
|
root-reserve-mb: 5120
|
||||||
|
remove-dotnet: true
|
||||||
|
remove-android: true
|
||||||
|
remove-docker-images: true
|
||||||
|
|
||||||
- name: Install build dependencies
|
- name: Checkout code
|
||||||
run: |
|
uses: actions/checkout@v3
|
||||||
# Install makepkg deps
|
|
||||||
pacman -Syu --noconfirm
|
|
||||||
pacman -S --noconfirm sudo binutils fakeroot grep base-devel git sbsigntools libffi python
|
|
||||||
|
|
||||||
- name: Setup secureboot certificate
|
- name: Initialize containers
|
||||||
env:
|
run: |
|
||||||
SB_KEY: ${{ secrets.SURFACE_SB_KEY }}
|
bash ./.github/scripts/container/create.sh \
|
||||||
run: |
|
archlinux
|
||||||
cd pkg
|
|
||||||
|
|
||||||
# Install the surface secureboot certificate
|
- name: Install build dependencies
|
||||||
echo "$SB_KEY" | base64 -d > arch/kernel/MOK.key
|
run: |
|
||||||
cp keys/surface.crt arch/kernel/MOK.crt
|
bash ./.github/scripts/container/exec.sh \
|
||||||
|
-- \
|
||||||
|
bash ./.github/scripts/package/arch.sh setup-builddeps
|
||||||
|
|
||||||
- name: Build
|
- name: Setup secureboot certificate
|
||||||
run: |
|
env:
|
||||||
cd pkg/arch/kernel
|
SB_KEY: ${{ secrets.SURFACE_SB_KEY }}
|
||||||
|
run: |
|
||||||
|
bash ./.github/scripts/container/exec.sh \
|
||||||
|
-e SB_KEY \
|
||||||
|
-- \
|
||||||
|
bash ./.github/scripts/package/arch.sh setup-secureboot
|
||||||
|
|
||||||
# Fix permissions (can't makepkg as root)
|
- name: Build packages
|
||||||
echo "nobody ALL=(ALL) NOPASSWD: /usr/bin/pacman" >> /etc/sudoers
|
run: |
|
||||||
chown -R nobody .
|
bash ./.github/scripts/container/exec.sh \
|
||||||
|
-- \
|
||||||
|
bash ./.github/scripts/package/arch.sh build-packages
|
||||||
|
|
||||||
# Package compression settings (Matches latest Arch)
|
- name: Sign packages
|
||||||
export PKGEXT='.pkg.tar.zst'
|
env:
|
||||||
export COMPRESSZST=(zstd -c -T0 --ultra -20 -)
|
GPG_KEY: ${{ secrets.LINUX_SURFACE_GPG_KEY }}
|
||||||
export MAKEFLAGS="-j2"
|
run: |
|
||||||
|
bash ./.github/scripts/container/exec.sh \
|
||||||
|
-e GPG_KEY \
|
||||||
|
-e GPG_KEY_ID \
|
||||||
|
-- \
|
||||||
|
bash ./.github/scripts/package/arch.sh sign-packages
|
||||||
|
|
||||||
# Build
|
- name: Upload artifacts
|
||||||
su nobody --pty -p -s /bin/bash -c 'makepkg -f --syncdeps --skippgpcheck --noconfirm'
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
- name: Prepare release
|
name: arch-latest
|
||||||
run: |
|
path: pkg/arch/kernel/release
|
||||||
mkdir release
|
|
||||||
mv pkg/arch/kernel/*.pkg.tar.zst release
|
|
||||||
|
|
||||||
- name: Sign packages
|
|
||||||
env:
|
|
||||||
GPG_KEY: ${{ secrets.LINUX_SURFACE_GPG_KEY }}
|
|
||||||
run: |
|
|
||||||
cd release
|
|
||||||
|
|
||||||
# import GPG key
|
|
||||||
echo "$GPG_KEY" | base64 -d | gpg --import --no-tty --batch --yes
|
|
||||||
export GPG_TTY=$(tty)
|
|
||||||
|
|
||||||
# sign packages
|
|
||||||
ls *.pkg.tar.zst | xargs -L1 gpg --detach-sign --batch --no-tty -u $GPG_KEY_ID
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: arch-latest
|
|
||||||
path: release
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
name: Publish release
|
name: Publish release
|
||||||
needs: [build]
|
needs: [build]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: arch-latest
|
name: arch-latest
|
||||||
path: arch-latest
|
path: arch-latest
|
||||||
|
|
||||||
- name: Upload assets
|
- name: Upload assets
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.LINUX_SURFACE_BOT_TOKEN }}
|
repo_token: ${{ secrets.LINUX_SURFACE_BOT_TOKEN }}
|
||||||
file: ./*-latest/*
|
file: ./*-latest/*
|
||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
file_glob: true
|
file_glob: true
|
||||||
|
|
||||||
repo:
|
repo:
|
||||||
name: Update package repository
|
name: Update package repository
|
||||||
needs: [release]
|
needs: [release]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: archlinux
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install dependencies
|
- name: Checkout repository
|
||||||
run: |
|
uses: actions/checkout@v3
|
||||||
pacman -Syu --noconfirm
|
|
||||||
pacman -S --noconfirm base-devel git
|
|
||||||
|
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: arch-latest
|
name: arch-latest
|
||||||
path: arch-latest
|
path: arch-latest
|
||||||
|
|
||||||
- name: Update repository
|
- name: Initialize containers
|
||||||
env:
|
run: |
|
||||||
SURFACEBOT_TOKEN: ${{ secrets.LINUX_SURFACE_BOT_TOKEN }}
|
bash ./.github/scripts/container/create.sh \
|
||||||
BRANCH_STAGING: u/staging
|
archlinux
|
||||||
GIT_REF: ${{ github.ref }}
|
|
||||||
run: |
|
|
||||||
repo="https://surfacebot:${SURFACEBOT_TOKEN}@github.com/linux-surface/repo.git"
|
|
||||||
|
|
||||||
# clone package repository
|
- name: Update repository
|
||||||
git clone -b "${BRANCH_STAGING}" "${repo}" repo
|
env:
|
||||||
|
SURFACEBOT_TOKEN: ${{ secrets.LINUX_SURFACE_BOT_TOKEN }}
|
||||||
# copy packages
|
GIT_REF: ${{ github.ref }}
|
||||||
cp arch-latest/* repo/arch/
|
BRANCH_STAGING: u/staging
|
||||||
cd repo/arch
|
run: |
|
||||||
|
bash ./.github/scripts/container/exec.sh \
|
||||||
# parse git tag from ref
|
-e SURFACEBOT_TOKEN \
|
||||||
GIT_TAG=$(echo $GIT_REF | sed 's|^refs/tags/||g')
|
-e GIT_REF \
|
||||||
|
-e BRANCH_STAGING \
|
||||||
# convert packages into references
|
-e GITHUB_REPOSITORY \
|
||||||
for pkg in $(find . -name '*.pkg.tar.zst'); do
|
-- \
|
||||||
echo "linux-surface:$GIT_TAG/$(basename $pkg)" > $pkg.blob
|
bash ./.github/scripts/repository/arch.sh
|
||||||
rm $pkg
|
|
||||||
done
|
|
||||||
|
|
||||||
# set git identity
|
|
||||||
git config --global user.email "surfacebot@users.noreply.github.com"
|
|
||||||
git config --global user.name "surfacebot"
|
|
||||||
|
|
||||||
# commit and push
|
|
||||||
update_branch="${BRANCH_STAGING}-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
|
|
||||||
git switch -c "${update_branch}"
|
|
||||||
git add .
|
|
||||||
git commit -m "Update Arch Linux kernel"
|
|
||||||
git push --set-upstream origin "${update_branch}"
|
|
Loading…
Reference in a new issue