Skip to content

feat: add homebrew tarball generating action #37

feat: add homebrew tarball generating action

feat: add homebrew tarball generating action #37

Workflow file for this run

name: Build packages in CI
on:
merge_group:
pull_request:
jobs:
changed_files:
runs-on: ubuntu-latest
name: Get changed files
outputs:
all_changed_files: ${{ steps.changed-package-files.outputs.all_changed_files }}
any_changed: ${{ steps.changed-package-files.outputs.any_changed }}
specs: ${{ steps.packages.outputs.specs }}
steps:
- uses: actions/checkout@v4
- name: Get directories with spec files
id: specdirs
run: |
set -x
FILESLIST=./files.txt
# The extra xargs there is so that the changed-files action can find all the files
find . -type f -iname '*.spec' -exec 'dirname' '{}' ';' 2>/dev/null | xargs -I{} echo "{}/**" > $FILESLIST
echo "fileslist=$FILESLIST" >> $GITHUB_OUTPUT
- name: Get all changed files from package directores
id: changed-package-files
uses: tj-actions/changed-files@v45
with:
files_from_source_file: ${{ steps.specdirs.outputs.fileslist }}
- name: Get all packages that need to be rebuilt
id: packages
if: steps.changed-package-files.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-package-files.outputs.all_changed_files }}
run: |
set -x
MATRIX="{\"specs\":[]}"
for file in ${ALL_CHANGED_FILES}; do
for spec in $(dirname $file)/*.spec ; do
[ -e "$spec" ] && MATRIX=$(echo $MATRIX | jq -c ".specs += [\"$spec\"]")
done
done
echo "specs=$(echo $MATRIX | jq -c '.specs')" >> $GITHUB_OUTPUT
build_packages:
runs-on: ${{ matrix.platform == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
needs: changed_files
name: Build RPM package
if: needs.changed_files.outputs.any_changed == 'true'
strategy:
fail-fast: false
matrix:
platform: ["arm64","amd64"]
# These are our target environments
# FIXME: renovate rule for this would be awesome
chroot: ["fedora-40", "fedora-41", "epel-10"]
spec: ${{ fromJson(needs.changed_files.outputs.specs) }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
if: matrix.platform == 'arm64'
run: |
sudo apt update -y
sudo apt install -y \
podman
- name: Setup Just
uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2
- name: Build ${{ matrix.spec }}
id: build_package
run: |
set -x
just=$(which just)
mkdir -p containers
MOCK_DIR=./mock
CONTAINERS_DIR=./containers
export CONTAINERS_DIR
$just build ${{ matrix.spec }} -r ${{ matrix.chroot }}-$(arch)
echo "mock_dir=$MOCK_DIR" >> "$GITHUB_OUTPUT"
echo "containers_dir=$CONTAINERS_DIR" >> "$GITHUB_OUTPUT"
sudo chown -R $(id -u):$(id -g) $MOCK_DIR
- name: Upload to Job Artifacts
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: ${{ matrix.chroot }}-${{ matrix.platform }}-rpms
if-no-files-found: error
path: |
${{ steps.build_package.outputs.mock_dir }}/**/*.rpm