-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Krystian Hebel <[email protected]>
- Loading branch information
1 parent
9367f3e
commit 1e8d4f0
Showing
1 changed file
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Test build and package QubesOS RPMs | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
qubes-component: | ||
description: > | ||
Name of QubesOS component as recognized by its build system. | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build-and-package: | ||
runs-on: ubuntu-latest | ||
name: Compile and package as QubesOS RPM | ||
permissions: | ||
# for publishing releases | ||
contents: write | ||
|
||
steps: | ||
- name: Install dependencies of builder script | ||
# README also specified: python3-yaml rpm tree gpg openssl python3-setuptools | ||
run: | | ||
sudo apt install python3-packaging createrepo-c devscripts \ | ||
docker python3-docker reprepro python3-pathspec \ | ||
mktorrent python3-lxml python3-dateutil | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: QubesOS/qubes-builderv2 | ||
|
||
- name: Cache Docker image and dom0 stuff | ||
uses: actions/cache@v3 | ||
id: docker-cache | ||
with: | ||
path: | | ||
/tmp/qubes-builder-fedora.tar | ||
/tmp/cache/dom0.tar | ||
key: | | ||
${{ hashFiles('tools/*') }}-docker-container | ||
- name: Load Docker image | ||
if: steps.docker-cache.outputs.cache-hit == 'true' | ||
run: | | ||
docker load --input /tmp/qubes-builder-fedora.tar | ||
- name: Build Docker image (optional) | ||
if: steps.docker-cache.outputs.cache-hit != 'true' | ||
run: | | ||
sed -i "s/RUN useradd -m user$/RUN useradd -m user -u $UID/" dockerfiles/fedora.Dockerfile | ||
tools/generate-container-image.sh docker | ||
- name: Export Docker image (optional) | ||
if: steps.docker-cache.outputs.cache-hit != 'true' | ||
run: | | ||
docker save --output /tmp/qubes-builder-fedora.tar \ | ||
qubes-builder-fedora:latest | ||
- name: Prepare dom0 cache storage (optional) | ||
if: steps.docker-cache.outputs.cache-hit != 'true' | ||
run: | | ||
mkdir --mode=777 /tmp/cache | ||
- name: Prepare configuration | ||
# FIXME: head_ref probably doesn't work on tag pushes | ||
env: | ||
URL: ${{ github.repositoryUrl }} | ||
BRANCH: ${{ fromJSON('{"tag": "github.ref_name", "branch": "github.head_ref"}')[github.ref_type] }} | ||
run: | | ||
cp example-configs/builder-devel.yml builder.yml | ||
sed -i "s#^ prefix: fepitre/qubes-# prefix: QubesOS/qubes-#" builder.yml | ||
sed -i "s#^ branch: builderv2# branch: main#" builder.yml | ||
sed -i "s#^artifacts-dir: .*#artifacts-dir: $PWD/artifacts#" builder.yml | ||
sed -i "1,/^ - ${{ inputs.qubes-component }}/s#^ - ${{ inputs.qubes-component }}#&:#" builder.yml | ||
sed -i "/^ - ${{ inputs.qubes-component }}:/a\ verification-mode: insecure-skip-checking" builder.yml | ||
sed -i "/^ - ${{ inputs.qubes-component }}:/a\ branch: ${BRANCH}" builder.yml | ||
sed -i "/^ - ${{ inputs.qubes-component }}:/a\ url: ${URL/git:/https:}" builder.yml | ||
cat builder.yml | ||
- name: Build and package | ||
run: | | ||
./qb --debug --verbose -c ${{ inputs.qubes-component }} package fetch prep build | ||
- name: Save built packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
if-no-files-found: error | ||
name: qubesos.dom0.fc37-${{ inputs.qubes-component }}-${{ github.sha }} | ||
path: | | ||
artifacts/components/${{ inputs.qubes-component }}/**/build/rpm/*.rpm | ||
artifacts/components/${{ inputs.qubes-component }}/**/build/rpm/*.buildinfo | ||
- name: Construct release's description | ||
if: github.event_name == 'push' && github.ref_type == 'tag' | ||
run: | | ||
for artifact in *.rpm; do | ||
echo "### $artifact" >> release-body.md | ||
echo '```' >> release-body.md | ||
echo "wget --quiet '${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}/$artifact'" >> release-body.md | ||
echo '```' >> release-body.md | ||
echo '```' >> release-body.md | ||
echo "curl --remote-name '${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}/$artifact'" >> release-body.md | ||
echo '```' >> release-body.md | ||
done | ||
- name: Create release for a new tag | ||
if: github.event_name == 'push' && github.ref_type == 'tag' | ||
uses: ncipollo/[email protected] | ||
with: | ||
artifacts: '*.rpm' | ||
artifactErrorsFailBuild: true | ||
bodyFile: "release-body.md" |