diff options
| -rw-r--r-- | .github/workflows/build-installer-iso.yml | 6 | ||||
| -rw-r--r-- | .github/workflows/build.yml | 12 | ||||
| -rw-r--r-- | .github/workflows/promote-acr.yml | 8 | ||||
| -rw-r--r-- | .github/workflows/validate-installer-iso.yml | 3 | ||||
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Justfile | 2 | ||||
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | image-template.env | 2 | ||||
| -rwxr-xr-x | tests/test-dotenv-precedence.sh | 28 |
9 files changed, 60 insertions, 14 deletions
diff --git a/.github/workflows/build-installer-iso.yml b/.github/workflows/build-installer-iso.yml index 9073077..da3ef10 100644 --- a/.github/workflows/build-installer-iso.yml +++ b/.github/workflows/build-installer-iso.yml @@ -26,6 +26,7 @@ jobs: env: IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} + IMAGE_NAME: ${{ vars.IMAGE_NAME || github.event.repository.name }} IMAGE_TAG: ${{ inputs.image_tag || 'latest' }} ISO_FILE_TAG: ${{ github.ref_name == 'testing' && 'testing' || (inputs.image_tag || 'latest') }} # Keep these aligned with the Fedora major used by the target bazzite-deck base image. @@ -51,12 +52,9 @@ jobs: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - - name: Install just - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 - - name: Prepare image references run: | - image_name="$(just image_name)" + image_name="${IMAGE_NAME,,}" image_registry="${IMAGE_REGISTRY,,}" echo "IMAGE_NAME=${image_name,,}" >> "$GITHUB_ENV" echo "IMAGE_REGISTRY=${image_registry}" >> "$GITHUB_ENV" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78b6dc6..908a18f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,18 @@ on: env: IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}" # do not edit + IMAGE_NAME: ${{ vars.IMAGE_NAME || github.event.repository.name }} + REPO_ORGANIZATION: ${{ vars.REPO_ORGANIZATION || github.repository_owner }} + IMAGE_DESC: ${{ vars.IMAGE_DESC || 'AeroCore customized Bazzite Deck image' }} + IMAGE_KEYWORDS: ${{ vars.IMAGE_KEYWORDS || 'bootc,oci,linux,bazzite,steam-deck,aerocore' }} + IMAGE_LOGO_URL: ${{ vars.IMAGE_LOGO_URL || 'https://avatars.githubusercontent.com/u/120078124?s=200&v=4' }} + DEFAULT_TAG: ${{ vars.DEFAULT_TAG || 'stable' }} + BIB_IMAGE: ${{ vars.BIB_IMAGE || 'quay.io/centos-bootc/bootc-image-builder:latest' }} + BASE_IMAGE: ${{ vars.BASE_IMAGE || 'ghcr.io/ublue-os/bazzite-deck:stable' }} + FLATPAK_REMOTE_URL: ${{ vars.FLATPAK_REMOTE_URL }} + HOMEBREW_BOTTLE_DOMAIN: ${{ vars.HOMEBREW_BOTTLE_DOMAIN }} + HOMEBREW_API_DOMAIN: ${{ vars.HOMEBREW_API_DOMAIN }} + OSTREE_IMAGE_REF: ${{ vars.OSTREE_IMAGE_REF }} concurrency: group: ${{ github.workflow }}-${{ github.ref || github.run_id }} diff --git a/.github/workflows/promote-acr.yml b/.github/workflows/promote-acr.yml index 6b00e3b..ceb5c0f 100644 --- a/.github/workflows/promote-acr.yml +++ b/.github/workflows/promote-acr.yml @@ -13,12 +13,13 @@ on: required: false type: string image_name: - description: "Image name override; defaults to IMAGE_NAME var, then image-template.env" + description: "Image name override; defaults to the runtime IMAGE_NAME variable" required: false type: string env: IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}" + IMAGE_NAME: ${{ vars.IMAGE_NAME || github.event.repository.name }} concurrency: group: ${{ github.workflow }}-${{ inputs.image_name || 'default' }}-${{ inputs.source_tag }} @@ -37,9 +38,6 @@ jobs: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - - name: Install just - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 #v4.0.0 - - name: Install skopeo run: | sudo apt-get update @@ -54,7 +52,7 @@ jobs: run: | set -euo pipefail - image_name="${IMAGE_NAME_INPUT:-${IMAGE_NAME_VAR:-$(just image_name)}}" + image_name="${IMAGE_NAME_INPUT:-${IMAGE_NAME_VAR:-${IMAGE_NAME}}}" target_tags="${TARGET_TAGS_INPUT:-$SOURCE_TAG}" { diff --git a/.github/workflows/validate-installer-iso.yml b/.github/workflows/validate-installer-iso.yml index 2151a23..466d2c4 100644 --- a/.github/workflows/validate-installer-iso.yml +++ b/.github/workflows/validate-installer-iso.yml @@ -32,6 +32,9 @@ jobs: run: | just --unstable --fmt --check -f Justfile + - name: Test dotenv precedence + run: tests/test-dotenv-precedence.sh + - name: Validate build scripts run: | for script in build_files/*.sh installer/*.sh just_scripts/*.sh tests/*.sh; do @@ -3,3 +3,4 @@ _build_* output _build-*/** .DS_Store +.env @@ -1,4 +1,4 @@ -set dotenv-filename := "image-template.env" +set dotenv-filename := ".env" set dotenv-load export image_name := env_var("IMAGE_NAME") @@ -41,13 +41,19 @@ with `INSTRUMENTS_RELEASE_REPOSITORY` and `INSTRUMENTS_RELEASE_API_BASE`. ## Local Build -To build AeroCore OS locally, edit `image-template.env` to match your target configurations and then run: +To build AeroCore OS locally, you may create a private `.env` from the +committed template and edit it to match your target configuration: ```bash -sudo just build - +cp image-template.env .env +# edit .env ``` +`.env` is ignored by Git and optional. When it is absent, Just reads the +required values from the runtime environment. Variables supplied by the shell +or CI environment override matching values in `.env`, so you can test a +different upstream base without changing files. + To test a different upstream base image directly without modifying the environment files: ```bash diff --git a/image-template.env b/image-template.env index 22a387b..f210b06 100644 --- a/image-template.env +++ b/image-template.env @@ -4,7 +4,7 @@ IMAGE_NAME=aerocore-os # Make this the same as your github username/organisation -REPO_ORGANIZATION="AeroCore-IO" +REPO_ORGANIZATION="aerocore-io" IMAGE_DESC="AeroCore customized Bazzite Deck image" IMAGE_KEYWORDS="bootc,oci,linux,bazzite,steam-deck,aerocore" diff --git a/tests/test-dotenv-precedence.sh b/tests/test-dotenv-precedence.sh new file mode 100755 index 0000000..f2cc760 --- /dev/null +++ b/tests/test-dotenv-precedence.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -euo pipefail + +project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +tmp_dir="$(mktemp -d)" +trap 'rm -rf "${tmp_dir}"' EXIT + +grep -Fqx 'set dotenv-filename := ".env"' "${project_root}/Justfile" +grep -Fqx '.env' "${project_root}/.gitignore" +if rg -F -- '--dotenv-path image-template.env' "${project_root}/.github/workflows"; then + echo 'CI must not load image-template.env as a dotenv file' >&2 + exit 1 +fi + +printf '%s\n' \ + 'set dotenv-load' \ + 'value := env_var("VALUE")' \ + 'show:' \ + ' @echo "{{value}}"' > "${tmp_dir}/justfile" +printf '%s\n' 'VALUE=from-dotenv' > "${tmp_dir}/.env" + +[[ "$(cd "${tmp_dir}" && just show)" == 'from-dotenv' ]] +[[ "$(cd "${tmp_dir}" && VALUE=from-runtime just show)" == 'from-runtime' ]] + +mkdir "${tmp_dir}/without-dotenv" +cp "${tmp_dir}/justfile" "${tmp_dir}/without-dotenv/justfile" +[[ "$(cd "${tmp_dir}/without-dotenv" && VALUE=from-runtime just show)" == 'from-runtime' ]] |
