Skip to content

Push ostree builds to server #14

Push ostree builds to server

Push ostree builds to server #14

Workflow file for this run

name: Build filesystem and export to OSTree
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build:
# https://runs-on.com/configuration/job-labels/
# https://aws.amazon.com/ec2/instance-types/
runs-on:
# x64
- runs-on=${{github.run_id}}/family=m7+c7/cpu=8+16/ram=32+64/image=ubuntu24-full-x64/disk=large/extras=s3-cache
timeout-minutes: 600 # 10 hours
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch BuildStream cache credentials from Vault
uses: hashicorp/vault-action@v3
with:
url: https://vault.endlessos.org
method: jwt
path: ghactions
role: endlessm-eos-build-meta
pki: |
pki/issue/endless-client {"common_name": "[email protected]", "ttl": "12h"} ;
- name: Fetch OSTree credentials from Vault
uses: hashicorp/vault-action@v3
with:
url: https://vault.endlessos.org
method: jwt
path: ghactions
role: endlessm-eos-build-meta
secrets: |
secret/ostree-builder/gpg/eoask1 private | OSTREE_BUILDER_GPG_PRIVATE ;
secret/ostree-builder/ssh private | OSTREE_BUILDER_SSH_PRIVATE ;
- name: Write secrets
run: |
# Certificate for BuildStream cache
echo "${ENDLESSCLIENT_CERT}" > client.crt
echo "${ENDLESSCLIENT_CA_CHAIN}" >> client.crt
echo "${ENDLESSCLIENT_KEY}" > client.key
chmod 600 client.key
# Signing key for OSTree commits
mkdir ./ostree-gpg
chmod 700 ostree-gpg
echo "${OSTREE_BUILDER_GPG_PRIVATE}" | gpg --homedir ./ostree-gpg --import
# SSH key for OSTree pushes
echo "${OSTREE_BUILDER_SSH_KEY}" > $HOME/.ssh/id_rsa
- name: Install BuildStream and dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
python3-pip python3-venv bubblewrap \
lzip xz-utils bzip2 gzip \
git wget curl \
build-essential pkg-config \
autotools-dev automake autoconf libtool \
cmake ninja-build meson \
flex bison gettext \
libssl-dev libffi-dev \
ostree flatpak-builder
python3 -m venv venv
source venv/bin/activate
pip install BuildStream buildstream-plugins dulwich requests tomlkit
pip install ostree-push
- name: Configure BuildStream
run: |
source venv/bin/activate
mkdir -p ~/.config
cat > ~/.config/buildstream.conf << EOF
# BuildStream user configuration
scheduler:
fetchers: 4
builders: 2
pushers: 2
network-retries: 2
build:
# Allow up to 4 parallel processes to execute within the scope of one build
max-jobs: 4
logging:
key-length: 0
verbose: false
error-lines: 20
message-lines: 20
debug: false
element-format: |
%{state: >12} %{full-key} %{name} %{workspace-dirs}
message-format: |
[%{elapsed}][%{key}][%{element}] %{action} %{message}
# Artifact cache configuration
artifacts:
servers:
- url: https://bstcache.endlessos.org
push: true
auth:
client-cert: $(pwd)/client.crt
client-key: $(pwd)/client.key
EOF
- name: Enable unprivileged userns
run: |
source venv/bin/activate
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- uses: runs-on/action@v2
with:
sccache: s3
- uses: mozilla-actions/[email protected]
- name: Build root filesystem
run: |
source venv/bin/activate
bst build eos/repo.bst
- name: Export OSTree commit and push it
env:
product: eos
platform: amd64
branch: eos7
build_element: eos/repo.bst
build_ref: "eos-buildstream"
push_key_id: "00EA12D9A37DD2A7BD810643DFB958DC725AE7CA"
push_ref: "os/${product}/${platform}/${branch}"
run: |
source venv/bin/activate
echo "Check out repo to a temporary directory"
checkout="$(mktemp --suffix="-update-repo" -d -p "$(pwd)")"
bst artifact checkout --hardlinks "${build_element}" --directory "${checkout}"
commit="$(ostree --repo="${checkout}/ostree/repo" rev-parse "${build_ref}")"
echo "Create a new OSTree repo and import commit ${commit}"
ostree init --repo="./ostree-repo" --mode=archive
ostree pull-local "${checkout}/ostree/repo" "${commit}"
echo "Recommit the tree with the autobuilder signing key"
ostree commit --gpg-homedir=ostree-gpg --gpg-sign="$push_key_id" \
--branch="${push_ref}" --tree=ref="${commit}"
echo "Push to the Cloud (WIP)"
ostree-push --help