Skip to content

Commit

Permalink
feat(ci): Split build for Fedora 38 and 39 (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
EyeCantCU authored Sep 20, 2023
1 parent 062dd72 commit bd27a84
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 14 deletions.
62 changes: 49 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: build development package
on:
pull_request:
merge_group:
merge_group:
push:
branches:
- main
workflow_dispatch:
workflow_dispatch:
env:
IMAGE_NAME: ublue-update
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
Expand All @@ -18,7 +18,18 @@ jobs:
contents: read
packages: write
id-token: write
steps:
strategy:
fail-fast: false
matrix:
major_version: [38, 39]
include:
- major_version: 38
is_latest_version: true
is_stable_version: true
- major_version: 39
is_latest_version: true
is_stable_version: false
steps:
# Checkout push-to-registry action GitHub repository
- name: Checkout Push to Registry action
uses: actions/checkout@v4
Expand All @@ -27,16 +38,41 @@ jobs:
id: generate-tags
shell: bash
run: |
echo "sha_short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
alias_tags=()
# Only perform the follow code when the action is spawned from a Pull Request
# 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.pull_request.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.pull_request.number }}")
COMMIT_TAGS+=("${SHA_SHORT}")
fi
BUILD_TAGS=("${MAJOR_VERSION}" "${MAJOR_VERSION}-${TIMESTAMP}")
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
BUILD_TAGS+=("latest")
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
alias_tags+=("pr-${{ github.event.number }}")
echo "Generated the following commit tags: "
for TAG in "${COMMIT_TAGS[@]}"; do
echo "${TAG}"
done
alias_tags=("${COMMIT_TAGS[@]}")
else
# The following is run when the timer is triggered or a merge/push to main
echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT
alias_tags+=("latest")
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
# Build image using Buildah action
Expand All @@ -49,8 +85,8 @@ jobs:
image: ${{ env.IMAGE_NAME }}
tags: |
${{ steps.generate-tags.outputs.alias_tags }}
${{ steps.generate-tags.outputs.date }}
${{ steps.generate-tags.outputs.sha_short }}
build-args: |
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
oci: true

# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR.
Expand Down Expand Up @@ -103,7 +139,7 @@ jobs:
if: github.event_name != 'pull_request'
run: |
echo "${{ toJSON(steps.push.outputs) }}"
copr-build:
permissions:
contents: read
Expand Down
4 changes: 3 additions & 1 deletion Containerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM registry.fedoraproject.org/fedora:latest AS builder
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}"

FROM registry.fedoraproject.org/fedora:${FEDORA_MAJOR_VERSION} AS builder

ENV UBLUE_ROOT=/app/output

Expand Down

0 comments on commit bd27a84

Please sign in to comment.