Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): Add system flatpaks #1022

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2348ffe
chore(ci): added flatpak_remote_refs
noelmiller Mar 12, 2024
c8a0a69
chore(ci): Replaced entire script with single line to update flatpaks
noelmiller Mar 12, 2024
1cb5447
chore(ci): re-enabled service
noelmiller Mar 12, 2024
e490ce3
chore(ci): remove fedora flatpak repo
noelmiller Mar 12, 2024
628ad62
chore(ci): push before SCALE
noelmiller Mar 14, 2024
e9d48d5
chore(ci): use apt and checkout repo
noelmiller Mar 16, 2024
3f787c4
chore(ci): combine workflows into one
noelmiller Mar 19, 2024
db05cd6
Merge branch 'testing' into add_system_flatpaks
noelmiller Mar 19, 2024
1a74138
chore(ci): ignored asus images for 38 and added 38 back
noelmiller Mar 19, 2024
57dba2a
chore(ci): fixup image exclusions and exclude 38 for ISO builds
noelmiller Mar 19, 2024
dd6a08e
chore(ci): removed unneeded job
noelmiller Mar 19, 2024
ea2156d
chore(ci): removed h264 due to requirement for internet connection
noelmiller Mar 19, 2024
564cc53
chore(ci): use unified build-action
noelmiller Mar 19, 2024
af09759
chore(ci): added needs for just file syntax check
noelmiller Mar 19, 2024
ed044d5
chore(ci): add AKMODS, remove when 38 is not longer needed
noelmiller Mar 20, 2024
6c83b10
chore(ci): ignore building latest for 38 and ignore building gts for 39
noelmiller Mar 20, 2024
e40ef61
chore(ci): add target to build proper container file
noelmiller Mar 20, 2024
98327f8
chore(ci): move to input not in matrix
noelmiller Mar 20, 2024
9b090fd
chore(ci): move from matrix to specific line
noelmiller Mar 20, 2024
bd44925
chore(ci): fixup pr detection
noelmiller Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
306 changes: 102 additions & 204 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:
- testing
paths-ignore:
- '**.md'
- '.github/workflows/build_iso.yml'
push:
branches:
- main
- testing
paths-ignore:
- '**.md'
- '.github/workflows/build_iso.yml'
tags:
- v*.*.*
workflow_dispatch:
env:
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
Expand All @@ -26,228 +26,126 @@ concurrency:
cancel-in-progress: true

jobs:
push-ghcr:
name: Make
check-just-files:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Check just syntax
uses: ublue-os/just-action@v1

build-container:
runs-on: ubuntu-22.04
needs: [check-just-files]
permissions:
contents: read
packages: write
id-token: write
continue-on-error: false
strategy:
fail-fast: false
matrix:
image_flavor: [main, nvidia, asus, asus-nvidia, framework, surface, surface-nvidia]
base_name: [bluefin, bluefin-dx]
major_version: [38, 39]
include:
- major_version: 38
is_latest_version: false
is_stable_version: true
is_gts_version: true
- major_version: 39
is_latest_version: true
is_stable_version: true
is_gts_version: false
image_name: [bluefin, bluefin-dx]
image_variant: [main, nvidia, asus, asus-nvidia, framework, surface, surface-nvidia]
version: [38, 39]
support: [latest, gts]
exclude:
- version: 38
image_variant: asus
- version: 38
image_variant: asus-nvidia
- version: 38
support: latest
- version: 39
support: gts
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Verify base image
uses: EyeCantCU/cosign-action/verify@v0.2.2
with:
containers: silverblue-${{ matrix.image_flavor }}:${{ matrix.major_version }}

- name: Verify Chainguard images
if: matrix.base_name != 'bluefin'
uses: EyeCantCU/cosign-action/verify@v0.2.2
with:
containers: dive, flux, helm, ko, minio, kubectl
cert-identity: https://github.com/chainguard-images/images/.github/workflows/release.yaml@refs/heads/main
oidc-issuer: https://token.actions.githubusercontent.com
registry: cgr.dev/chainguard

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

- name: Check just syntax
uses: ublue-os/just-action@v1

- name: Matrix Variables
- name: Determine AKMODS_FLAVOR
run: |
if [[ "${{ matrix.image_flavor }}" == "main" ]]; then
echo "IMAGE_NAME=${{ matrix.base_name }}" >> $GITHUB_ENV
else
echo "IMAGE_NAME=${{ format('{0}-{1}', matrix.base_name, matrix.image_flavor) }}" >> $GITHUB_ENV
fi
if [[ "${{ matrix.image_flavor }}" =~ "asus" ]]; then
if [[ "${{ matrix.image_variant }}" =~ ^asus* ]]; then
echo "AKMODS_FLAVOR=asus" >> $GITHUB_ENV
elif [[ "${{ matrix.image_flavor }}" =~ "surface" ]]; then
elif [[ "${{ matrix.image_variant }}" =~ ^surface* ]]; then
echo "AKMODS_FLAVOR=surface" >> $GITHUB_ENV
else
echo "AKMODS_FLAVOR=main" >> $GITHUB_ENV
fi

- name: Generate tags
id: generate-tags
shell: bash
run: |
# Generate a timestamp for creating an image version history
TIMESTAMP="$(date +%Y%m%d)"
MAJOR_VERSION="${{ matrix.major_version }}"
COMMIT_TAGS=()
BUILD_TAGS=()
# Have tags for tracking builds during pull request
SHA_SHORT="${GITHUB_SHA::7}"
COMMIT_TAGS+=("pr-${{ github.event.number }}-${MAJOR_VERSION}")
COMMIT_TAGS+=("${SHA_SHORT}-${MAJOR_VERSION}")
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=("${MAJOR_VERSION}" "${MAJOR_VERSION}-${TIMESTAMP}")

if [[ ${{ github.ref_name }} == "testing" ]]; then
BUILD_TAGS=("${MAJOR_VERSION}-testing" "${MAJOR_VERSION}-testing-${TIMESTAMP}")
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
BUILD_TAGS+=("testing")
elif [[ "${{ matrix.is_gts_version }}" == "true" ]]; then
BUILD_TAGS+=("gts-testing")
fi
elif [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
BUILD_TAGS+=("latest")
elif [[ "${{ matrix.is_gts_version }}" == "true" ]]; then
BUILD_TAGS+=("gts")
fi

if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Generated the following commit tags: "
for TAG in "${COMMIT_TAGS[@]}"; do
echo "${TAG}"
done
alias_tags=("${COMMIT_TAGS[@]}")
else
alias_tags=("${BUILD_TAGS[@]}")
fi
echo "Generated the following build tags: "
for TAG in "${BUILD_TAGS[@]}"; do
echo "${TAG}"
done
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT

- name: Get Current Fedora Version
id: labels
shell: bash
run: |
set -eo pipefail
ver=$(skopeo inspect docker://ghcr.io/ublue-os/silverblue-${{ matrix.image_flavor }}:${{ matrix.major_version }} | jq -r '.Labels["org.opencontainers.image.version"]')
if [ -z "$ver" ] || [ "null" = "$ver" ]; then
echo "inspected image version must not be empty or null"
exit 1
fi
echo "VERSION=$ver" >> $GITHUB_OUTPUT

# Build metadata
- name: Image Metadata
uses: docker/metadata-action@v5
id: meta
- name: Build Container
uses: ublue-os/build-action@main
with:
images: |
${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.version=${{ steps.labels.outputs.VERSION }}
org.opencontainers.image.description=An interpretation of the Ubuntu spirit built on Fedora technology
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/bluefin/bluefin/README.md
io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4

# Build image using Buildah action
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
containerfiles: |
./Containerfile
image: ${{ env.IMAGE_NAME }}
tags: |
${{ steps.generate-tags.outputs.alias_tags }}
build-args: |
IMAGE_NAME=${{ env.IMAGE_NAME }}
IMAGE_FLAVOR=${{ matrix.image_flavor }}
IMAGE_VENDOR=${{ github.repository_owner }}
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
TARGET_BASE=${{ matrix.target_base }}
image_name: ${{ matrix.image_name }}
image_variant: ${{ matrix.image_variant }}
version: ${{ matrix.version }}
support: ${{ matrix.support }}
signing_key: ${{ secrets.SIGNING_SECRET }}
target: ${{ matrix.image_name }}
extra_build_args: |
AKMODS_FLAVOR=${{ env.AKMODS_FLAVOR }}
labels: ${{ steps.meta.outputs.labels }}
oci: false
# TODO(GH-280)
# extra-args: |
# --target=${{ matrix.target_name || matrix.base_name }}
extra-args: |
--target=${{ matrix.base_name }}

# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR.
# https://github.com/macbre/push-to-ghcr/issues/12
- name: Lowercase Registry
id: registry_case
uses: ASzc/change-string-case-action@v6
with:
string: ${{ env.IMAGE_REGISTRY }}
build-iso:
runs-on: ubuntu-latest
needs: [build-container]
permissions:
contents: read
packages: write
id-token: write
continue-on-error: false
strategy:
fail-fast: false
matrix:
image_name: [bluefin, bluefin-nvidia, bluefin-asus, bluefin-asus-nvidia, bluefin-surface, bluefin-surface-nvidia, bluefin-dx, bluefin-dx-nvidia, bluefin-dx-asus, bluefin-dx-surface, bluefin-dx-asus-nvidia, bluefin-dx-surface-nvidia]
major_version: [39]
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1

# Push the image to GHCR (Image Registry)
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
id: push
if: github.event_name != 'pull_request'
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ steps.registry_case.outputs.lowercase }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Checkout repo
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
- name: Build ISOs
uses: jasonn3/build-container-installer@main
id: build
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Sign container image
if: github.event_name != 'pull_request'
run: |
cosign sign -y --key env://COSIGN_PRIVATE_KEY ${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }}@${TAGS}
arch: x86_64
image_name: ${{ matrix.image_name }}
image_repo: ghcr.io/ublue-os
variant: 'Silverblue'
version: ${{ matrix.major_version }}
image_tag: ${{ github.event.number && format('pr-{0}-{1}', github.event.number, matrix.major_version) || 'latest' }}
secure_boot_key_url: 'https://github.com/ublue-os/akmods/raw/main/certs/public_key.der'
enrollment_password: 'ublue-os'
iso_name: ${{ matrix.image_name }}-${{ matrix.image_tag }}-${{ matrix.major_version}}
enable_cache_dnf: "false"
enable_cache_skopeo: "false"
flatpak_remote_refs_dir: /github/workspace/flatpaks

- name: Upload ISOs and Checksum to Job Artifacts
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.iso_name }}
path: |
${{ steps.build.outputs.iso_path }}
${{ steps.build.outputs.iso_path }}-CHECKSUM
if-no-files-found: error
retention-days: 0
compression-level: 0
overwrite: true

- name: Upload ISOs and Checksum to R2
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
env:
TAGS: ${{ steps.push.outputs.digest }}
COSIGN_EXPERIMENTAL: false
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}

- name: Echo outputs
if: github.event_name != 'pull_request'
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_REGION: auto
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
SOURCE_ISO: ${{ steps.build.outputs.iso_path }}
SOURCE_ISO_CHECKSUM: ${{ steps.build.outputs.iso_path }}-CHECKSUM
run: |
echo "${{ toJSON(steps.push.outputs) }}"

check:
name: Check all builds successful
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
needs: [push-ghcr]
steps:
- name: Exit on failure
if: ${{ needs.push-ghcr.result == 'failure' }}
shell: bash
run: exit 1
- name: Exit
shell: bash
run: exit 0
apt-get update
apt-get install -y rclone
rclone copy $SOURCE_ISO R2:bluefin
rclone copy $SOURCE_ISO_CHECKSUM R2:bluefin
Loading
Loading