Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
auricom committed May 11, 2024
1 parent 247d2b5 commit 820e55a
Show file tree
Hide file tree
Showing 22 changed files with 532 additions and 126 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/renovate-config.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
"docker:enableMajor",
":automergeBranch",
":disableRateLimiting",
":dependencyDashboard",
":semanticCommits",
":skipStatusChecks",
":timezone(Europe/Paris)",
"github>auricom/ucore-custom//.github/renovate/customManagers.json5",
],
"dependencyDashboardTitle": "Renovate Dashboard 🤖",
"suppressNotifications": ["prEditedNotification", "prIgnoreNotification"],
}
3 changes: 3 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}
24 changes: 24 additions & 0 deletions .github/renovate/customManagers.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"customManagers": [
{
"customType": "regex",
"description": ["Process container versions"],
"fileMatch": ["(^|/)containers/.+\\.container$"],
"matchStrings": [
"Image=(?<depName>[^:]+):(?<currentValue>[^\\s@]+)(@(?<currentDigest>sha256:[0-9a-f]+))?"
],
"datasourceTemplate": "docker",
"versioningTemplate": "docker"
},
{
"customType": "regex",
"description": ["Process taskfile dependencies"],
"fileMatch": ["(^|/)Taskfile\\.ya?ml$"],
"matchStrings": [
"datasource=(?<datasource>\\S+) depName=(?<depName>\\S+)( repository=(?<registryUrl>\\S+))?\\n.+: (&\\S+\\s)?(?<currentValue>\\S+)"
],
"datasourceTemplate": "{{#if datasource}}{{{datasource}}}{{else}}github-releases{{/if}}"
}
]
}
138 changes: 100 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
name: build-ublue-custom
name: build-ucore-custom
on:
pull_request:
branches:
- main
schedule:
- cron: '05 10 * * *' # 10:05am UTC everyday
- cron: 15 1 * * * # approx 1.5 hours after ublue-os/ucore images publish
push:
branches:
- main
Expand All @@ -14,46 +13,82 @@ on:
workflow_dispatch:

env:
MY_IMAGE_NAME: "${{ github.event.repository.name }}" # the name of the image produced by this build, matches repo names
MY_IMAGE_DESC: "My Customized Universal Blue Image"
IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}" # do not edit
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
build_push:
name: Build and push image
push-ghcr:
name: custom image
runs-on: ubuntu-latest

# trunk-ignore(checkov/CKV2_GHA_1)
permissions:
contents: read
packages: write
id-token: write

strategy:
fail-fast: false
matrix:
image_name: [ucore-minimal]
tag_name: [stable,stable-zfs]
include:
- tag_name: stable
is_latest_version: true
is_stable_version: true
steps:
# Checkout push-to-registry action GitHub repository
- name: Checkout Push to Registry action
- name: Checkout
uses: actions/checkout@v4

- name: Maximize disk space
uses: ublue-os/remove-unwanted-software@v6

- name: Matrix Variables
shell: bash
run: |
export IMAGE_NAME=${{ matrix.image_name }}
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
- name: Verify base image
uses: EyeCantCU/cosign-action/[email protected]
with:
containers: ${{ env.IMAGE_NAME }}:${{ matrix.tag_name }}

- name: Generate tags
id: generate-tags
shell: bash
run: |
# Generate a timestamp for creating an image version history
TIMESTAMP="$(date +%Y%m%d)"
VARIANT="${{ matrix.tag_name }}"
COMMIT_TAGS=()
BUILD_TAGS=()
# Have tags for tracking builds during pull request
SHA_SHORT="${GITHUB_SHA::7}"
COMMIT_TAGS+=("pr-${{ github.event.number }}")
COMMIT_TAGS+=("${SHA_SHORT}")
COMMIT_TAGS+=("pr-${{ github.event.number }}-${VARIANT}")
COMMIT_TAGS+=("${SHA_SHORT}-${VARIANT}")
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
COMMIT_TAGS+=("pr-${{ github.event.number }}")
COMMIT_TAGS+=("${SHA_SHORT}")
fi
BUILD_TAGS=("${VARIANT}")
# Append matching timestamp tags to keep a version history
for TAG in "${BUILD_TAGS[@]}"; do
BUILD_TAGS+=("${TAG}-${TIMESTAMP}")
done
BUILD_TAGS+=("${TIMESTAMP}")
BUILD_TAGS+=("latest")
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
BUILD_TAGS+=("${TIMESTAMP}")
BUILD_TAGS+=("latest")
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Generated the following commit tags: "
Expand All @@ -73,18 +108,24 @@ jobs:
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT
- name: Get current version
id: labels
run: |
ver=$(skopeo inspect docker://ghcr.io/ublue-os/${{ env.IMAGE_NAME }}:${{ matrix.tag_name }} | jq -r '.Labels["org.opencontainers.image.version"]')
echo "IMAGE_NAME_VERSION=$ver" >> $GITHUB_ENV
# Build metadata
- name: Image Metadata
uses: docker/metadata-action@v5
id: meta
with:
images: |
${{ env.MY_IMAGE_NAME }}
${{ env.IMAGE_NAME }}
labels: |
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/main/README.md
org.opencontainers.image.description=${{ env.MY_IMAGE_DESC }}
org.opencontainers.image.title=${{ env.MY_IMAGE_NAME }}
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.version=${{ env.IMAGE_NAME_VERSION }}
org.opencontainers.image.description=Custom ${{ matrix.image_name }}
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/auricom/ublue-custom/main/README.md
# Build image using Buildah action
- name: Build Image
Expand All @@ -95,9 +136,12 @@ jobs:
./Containerfile
# Postfix image name with -custom to make it a little more descriptive
# Syntax: https://docs.github.com/en/actions/learn-github-actions/expressions#format
image: ${{ env.MY_IMAGE_NAME }}
image: ${{ env.IMAGE_NAME }}
tags: |
${{ steps.generate-tags.outputs.alias_tags }}
build-args: |
IMAGE_NAME=${{ matrix.image_name }}
IMAGE_TAG=${{ matrix.tag_name }}
labels: ${{ steps.meta.outputs.labels }}
oci: false

Expand All @@ -109,14 +153,8 @@ jobs:
with:
string: ${{ env.IMAGE_REGISTRY }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Image to GHCR
# Push the image to GHCR (Image Registry)
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
id: push
env:
Expand All @@ -128,23 +166,47 @@ jobs:
registry: ${{ steps.registry_case.outputs.lowercase }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
extra-args: |
--disable-content-trust

# This section is optional and only needs to be enabled in you plan on distributing
# your project to others to consume. You will need to create a public and private key
# using Cosign and save the private key as a repository secret in Github for this workflow
# to consume. For more details, review the image signing section of the README.
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Sign container
- uses: sigstore/cosign-installer@v3.5.0
- uses: sigstore/cosign-installer@v3.4.0
if: github.event_name != 'pull_request'

- name: Sign container image
- name: Sign container image with keypair
if: github.event_name != 'pull_request'
run: |
cosign sign -y --key env://COSIGN_PRIVATE_KEY ${{ steps.registry_case.outputs.lowercase }}/${{ steps.build_image.outputs.image }}@${TAGS}
env:
TAGS: ${{ steps.push.outputs.digest }}
COSIGN_EXPERIMENTAL: false
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}

- name: Verify keypair signature
if: github.event_name != 'pull_request'
run: |
cosign verify \
--key cosign.pub \
${{ steps.registry_case.outputs.lowercase }}/${{ steps.build_image.outputs.image }}:${{ matrix.tag_name }}
- name: Sign container image with OIDC
if: github.event_name != 'pull_request'
run: cosign sign -y ${{ steps.registry_case.outputs.lowercase }}/${{ steps.build_image.outputs.image }}:${{ matrix.tag_name }}

- name: Verify OIDC signature
if: github.event_name != 'pull_request'
run: |
cosign verify \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
--certificate-identity-regexp "${{ github.server_url }}/${{ github.repository }}" \
${{ steps.registry_case.outputs.lowercase }}/${{ steps.build_image.outputs.image }}:${{ matrix.tag_name }}
- name: Echo outputs
if: github.event_name != 'pull_request'
run: |
echo "${{ toJSON(steps.push.outputs) }}"
10 changes: 10 additions & 0 deletions .sops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
creation_rules:
- path_regex: \.sops\.env$
input_type: dotenv
key_groups:
- age:
- age1c8cqpw6gnlrf82ewm2vj0yalzszvtzd0mmk5yzr4nfpqqseynq7q86f3sq
stores:
yaml:
indent: 2
66 changes: 14 additions & 52 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,59 +1,21 @@
## 1. BUILD ARGS
# These allow changing the produced image by passing different build args to adjust
# the source from which your image is built.
# Build args can be provided on the commandline when building locally with:
# podman build -f Containerfile --build-arg FEDORA_VERSION=40 -t local-image

# SOURCE_IMAGE arg can be anything from ublue upstream which matches your desired version:
# See list here: https://github.com/orgs/ublue-os/packages?repo_name=main
# - "silverblue"
# - "kinoite"
# - "sericea"
# - "onyx"
# - "lazurite"
# - "vauxite"
# - "base"
#
# "aurora", "bazzite", "bluefin" or "ucore" may also be used but have different suffixes.
ARG SOURCE_IMAGE="silverblue"

## SOURCE_SUFFIX arg should include a hyphen and the appropriate suffix name
# These examples all work for silverblue/kinoite/sericea/onyx/lazurite/vauxite/base
# - "-main"
# - "-nvidia"
# - "-asus"
# - "-asus-nvidia"
# - "-surface"
# - "-surface-nvidia"
#
# aurora, bazzite and bluefin each have unique suffixes. Please check the specific image.
# ucore has the following possible suffixes
# - stable
# - stable-nvidia
# - stable-zfs
# - stable-nvidia-zfs
# - (and the above with testing rather than stable)
ARG SOURCE_SUFFIX="-main"

## SOURCE_TAG arg must be a version built for the specific image: eg, 39, 40, gts, latest
ARG SOURCE_TAG="latest"
### 1. BUILD ARGS
## IMAGE_NAME arg can be anything from ublue upstream: silverblue, kinoite, sericea, vauxite, mate, lxqt, base
ARG IMAGE_NAME="${IMAGE_NAME:-ucore-minimal}"

## FEDORA_VERSION arg must be a version built by ublue: 39 or 40 as of today (stable for ucore)
ARG IMAGE_TAG="${IMAGE_TAG:-stable-zfs}"

### 2. SOURCE IMAGE
## this is a standard Containerfile FROM using the build ARGs above to select the right upstream image
FROM ghcr.io/ublue-os/${SOURCE_IMAGE}${SOURCE_SUFFIX}:${SOURCE_TAG}
FROM ghcr.io/ublue-os/${IMAGE_NAME}:${IMAGE_TAG}
ENV UCORE_UPSTREAM_IMAGE_TAG=${IMAGE_TAG}

COPY usr /usr
COPY scripts /tmp/
COPY .sops.yaml /usr/share/sops/

### 3. MODIFICATIONS
## make modifications desired in your image and install packages by modifying the build.sh script
## the following RUN directive does all the things required to run "build.sh" as recommended.

COPY build.sh /tmp/build.sh

RUN mkdir -p /var/lib/alternatives && \
/tmp/build.sh && \
ostree container commit
## NOTES:
# - /var/lib/alternatives is required to prevent failure with some RPM installs
# - All RUN commands must end with ostree container commit
# see: https://coreos.github.io/rpm-ostree/container/#using-ostree-container-commit
## make modifications desired in your image and install packages here, a few examples follow
RUN /tmp/install.sh && \
/tmp/post-install.sh && \
ostree container commit
Loading

0 comments on commit 820e55a

Please sign in to comment.