Skip to content

Commit

Permalink
Refactor (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulchen-Panther authored Feb 15, 2025
1 parent ee3921e commit 73c6e94
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 212 deletions.
71 changes: 71 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build Hyperion packages
description: Builds Hyperion for specified distribution, codename and architecture
inputs:
distribution:
description: Linux distribution to build
required: true
default: 'debian'
codename:
description: Linux codename to build
required: true
default: 'bullseye'
architecture:
description: Linux architecture to build
required: false
default: 'amd64'
qtVersion:
description: Qt version to be used
required: false
default: '6'
ghcr:
description: GitHub Container Registry (Repository) to be used
required: false
default: 'hyperion-project'
dockerArchitecture:
description: Docker architecture under which to build
required: false
default: 'linux/amd64'
dockerEntrypoint:
description: Docker Entrypoint
required: false
default: ''
workingDirectory:
description: Working directory
required: false
default: ${{ github.workspace }}
runs:
using: composite
steps:
- name: 👷 Building Hyperion
shell: bash
working-directory: ${{ inputs.workingDirectory }}
run: |
mkdir -p "deploy"
VERSION=$(cat .version)
if [[ ${{ inputs.distribution }} == @(debian|ubuntu) ]]; then
docker run --rm --privileged --platform=${{ inputs.dockerArchitecture }} ${{ inputs.dockerEntrypoint }} \
-w "/source" \
-v "${{ inputs.workingDirectory }}/deploy:/deploy" \
-v "${{ inputs.workingDirectory }}:/source:rw" \
ghcr.io/${{ inputs.ghcr }}/${{ inputs.distribution }}:${{ inputs.qtVersion == '6' && format('{0}-qt6', inputs.codename) || inputs.codename }} \
/bin/bash -c "git config --global --add safe.directory '*' && \
mkdir -p debian/source && echo '$([[ $VERSION == *-* ]] && echo "3.0 (quilt)" || echo "3.0 (native)")' > debian/source/format && echo 10 > debian/compat && \
dch --create --distribution ${{ inputs.codename }} --package 'hyperion' -v '$(echo ${VERSION})~${{ inputs.codename }}' '${{ github.event.commits[0].message }}' && \
cp -fr LICENSE debian/copyright && \
sed 's/@ARCHITECTURE@/${{ inputs.architecture }}/g; s/@STANDARDS_VERSION@/$(echo ${VERSION%[-+]*})/g' debian/control.in > debian/control && \
debuild -b -uc -us && \
cp ../hyperion_*.deb ./deploy"
else
docker run --rm --platform=${{ inputs.dockerArchitecture }} ${{ inputs.dockerEntrypoint }} \
-w "/root" \
-v "${{ inputs.workingDirectory }}/deploy:/deploy" \
-v "${{ inputs.workingDirectory }}:/root/hyperion.ng:rw" \
ghcr.io/${{ inputs.ghcr }}/${{ inputs.distribution }}:${{ inputs.qtVersion == '6' && format('{0}-qt6', inputs.codename) || inputs.codename }} \
/bin/bash -c "tar -czf rpmbuild/SOURCES/hyperion.ng.tar.gz hyperion.ng/ && \
cp -f hyperion.ng/rpmbuild/hyperion.spec.in rpmbuild/SPECS/hyperion.spec && \
rpmdev-bumpspec --comment='${{ github.event.commits[0].message }}' --userstring='${{ env.ACTOR }}' rpmbuild/SPECS/hyperion.spec && \
rpmbuild -ba --define 'hyperion_version $(echo ${VERSION} | sed s/-/~/g | sed s/+/^/g)' rpmbuild/SPECS/hyperion.spec --clean && \
cp -fv rpmbuild/RPMS/$(uname -m)/hyperion* /deploy"
fi
env:
ACTOR: "Hyperion Project <[email protected]>"
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
inputs:
repo_checkout:
type: string
description: The GitHub Repository to checkout
default: hyperion-project
description: The GitHub Repository to checkout (lower case)
default: hyperion-project/hyperion.ng
required: false
head_sha:
type: string
description: The branch, tag or SHA to checkout
description: The branch, tag or SHA to checkout (case sensitive)
default: master
required: false
nightly:
Expand All @@ -24,14 +24,10 @@ on:
default: false
required: false

env:
repository: ${{ inputs.repo_checkout }}
ghcr: hyperion-project

jobs:
build:
name: 🐧 ${{ matrix.os.description }} (${{ matrix.architecture[0] }})
runs-on: ubuntu-22.04
runs-on: ${{ matrix.architecture[0] == 'amd64' && 'ubuntu-22.04' || 'ubuntu-22.04-arm' }}
strategy:
fail-fast: false
matrix:
Expand All @@ -43,7 +39,10 @@ jobs:
{ distribution: debian, codename: buster, description: Debian 10.x (Buster), qt_version: '5' }, # Qt 6 not available
{ distribution: debian, codename: bullseye, description: Debian 11.x (Bullseye), qt_version: '5' }, # Qt 6 only available from bullseye-backports
{ distribution: debian, codename: bookworm, description: Debian 12.x (Bookworm), qt_version: '6' },
{ distribution: debian, codename: trixie, description: Debian 13.x (Trixie), qt_version: '6' }
{ distribution: debian, codename: trixie, description: Debian 13.x (Trixie), qt_version: '6' },
{ distribution: fedora, codename: 39, description: Fedora 39, qt_version: '6' },
{ distribution: fedora, codename: 40, description: Fedora 40, qt_version: '6' },
{ distribution: fedora, codename: 41, description: Fedora 41, qt_version: '6' }
]
architecture: [
[ amd64, linux/amd64 ],
Expand All @@ -62,12 +61,16 @@ jobs:
architecture: [ armhf, linux/arm/v7 ]
- os: { distribution: debian, codename: trixie, } # Trixie armv6 not available yet (https://hub.docker.com/r/balenalib/rpi-raspbian/tags)
architecture: [ armhf, linux/arm/v6 ]
- os: { distribution: fedora }
architecture: [ armhf, linux/arm/v6 ]
- os: { distribution: fedora }
architecture: [ armhf, linux/arm/v7 ]

steps:
- name: ⬇ Checkout hyperion.ng
uses: actions/checkout@v4
with:
repository: ${{ env.repository }}/hyperion.ng
repository: ${{ inputs.repo_checkout }}
ref: ${{ inputs.head_sha || 'master' }}
submodules: recursive

Expand All @@ -78,48 +81,28 @@ jobs:

- name: 🔧 Prepare
run: |
echo '::group::Checking the version number'
if [[ "${{ inputs.nightly }}" = true ]]; then
echo "$(tr -d '\n' < .version)+nightly$(date '+%Y%m%d')${{ inputs.head_sha }}" > .version
else
tr -d '\n' < .version > temp && mv temp .version
fi
echo '::endgroup::'
echo '::group::Copy debian folder'
if [[ ${{ matrix.os.distribution }} == @(debian|ubuntu) ]]; then
cp -r releases-ci/debian ${GITHUB_WORKSPACE}/
echo '::endgroup::'
else
cp -r releases-ci/rpmbuild ${GITHUB_WORKSPACE}/
fi
echo '::group::Generate environment variables'
VERSION=$(cat .version)
echo VERSION=${VERSION} >> $GITHUB_ENV
if [[ $VERSION == *"-"* ]]; then
echo STANDARDS_VERSION=$(echo ${VERSION%-*}) >> $GITHUB_ENV
echo DEBIAN_FORMAT='3.0 (quilt)' >> $GITHUB_ENV
else
echo STANDARDS_VERSION=$(echo ${VERSION%+*}) >> $GITHUB_ENV
echo DEBIAN_FORMAT='3.0 (native)' >> $GITHUB_ENV
fi
echo '::endgroup::'
if [[ "${{ inputs.nightly }}" = true ]]; then
echo "$(tr -d '\n' < .version)+nightly$(date '+%Y%m%d')${{ inputs.head_sha }}" > .version
else
tr -d '\n' < .version > temp && mv temp .version
fi
- name: 👷 Build
shell: bash
run: |
mkdir -p "${GITHUB_WORKSPACE}/deploy"
docker run --rm --platform=${{ matrix.architecture[1] }} \
-v "${GITHUB_WORKSPACE}/deploy:/deploy" \
-v "${GITHUB_WORKSPACE}:/source:rw" \
ghcr.io/${{ env.ghcr }}/${{ matrix.os.distribution }}:${{ env.DOCKER_IMAGE }} \
/bin/bash -c "cd /source && \
git config --global --add safe.directory '*' && \
mkdir -p debian/source && echo '${{ env.DEBIAN_FORMAT }}' > debian/source/format && echo 10 > debian/compat && \
dch --create --distribution ${{ matrix.os.codename }} --package 'hyperion' -v '${{ env.VERSION }}~${{ matrix.os.codename }}' '${{ github.event.commits[0].message }}' && \
cp -fr LICENSE debian/copyright && \
sed 's/@ARCHITECTURE@/${{ matrix.architecture[0] }}/g; s/@STANDARDS_VERSION@/${{ env.STANDARDS_VERSION }}/g' debian/control.in > debian/control && \
debuild -b -uc -us && \
cp ../hyperion_*.deb /deploy"
env:
DOCKER_IMAGE: ${{ matrix.os.qt_version == '6' && format('{0}-qt6', matrix.os.codename) || matrix.os.codename }}
uses: ./releases-ci/.github/actions/build
with:
workingDirectory: ${{ github.workspace }}/
distribution: ${{ matrix.os.distribution }}
codename: ${{ matrix.os.codename }}
architecture: ${{ matrix.architecture[0] }}
qtVersion: ${{ matrix.os.qt_version }}
dockerArchitecture: ${{ matrix.architecture[1] }}
dockerEntrypoint: ${{ matrix.architecture[0] != 'amd64' && '--entrypoint /usr/bin/env' || '' }}

- name: 📦 Upload
if: ${{ inputs.upload }}
Expand Down
102 changes: 0 additions & 102 deletions .github/workflows/build_rpm.yml

This file was deleted.

26 changes: 7 additions & 19 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,23 @@ jobs:
echo "commit-has-changed=true" >> $GITHUB_OUTPUT
fi
# Build DEB Packages for APT Repository
deb_build:
name: 👷 Build DEB Packages
if: ${{ needs.check.outputs.build-apt-nightly == 'true' || inputs.forceRun }}
needs: [check]
uses: ./.github/workflows/build_deb.yml
secrets: inherit
with:
head_sha: ${{ needs.check.outputs.current-head-sha }}
nightly: true
upload: true

# Build RPM Packages for DNF Repository
rpm_build:
name: 👷 Build RPM Packages
if: ${{ needs.check.outputs.build-dnf-nightly == 'true' || inputs.forceRun }}
# Build DEB/RPM Packages for APT Repository
build_packages:
name: 👷 Build DEB/RPM Packages
if: ${{ needs.check.outputs.build-apt-nightly == 'true' || needs.check.outputs.build-dnf-nightly == 'true' || inputs.forceRun }}
needs: [check]
uses: ./.github/workflows/build_rpm.yml
uses: ./.github/workflows/build_deb_rpm.yml
secrets: inherit
with:
head_sha: ${{ needs.check.outputs.current-head-sha }}
nightly: true
upload: true

# Publish RPM Packages to DNF Repository
# Publish DEB/RPM Packages to DNF Repository
publish_packages:
name: 🚀 Publish Packages
if: ${{ needs.check.outputs.build-apt-nightly == 'true' || needs.check.outputs.build-dnf-nightly == 'true' || inputs.forceRun }}
needs: [ check, deb_build, rpm_build ]
needs: [ check, build_packages ]
uses: ./.github/workflows/publish_deb_rpm.yml
secrets: inherit
with:
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/push_pull.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Push/Pull Request
run-name: |
${{ github.event_name == 'push' && '🌱 Push builds -' || '' }}
${{ github.event_name == 'pull_request' && format('👷 PR {0} builds - {1}', github.event.pull_request.number, github.event.pull_request.title) || github.event.head_commit.message }}
${{ github.event_name == 'pull_request' && format('👷 PR #{0} build - {1}', github.event.pull_request.number, github.event.pull_request.title) || github.event.head_commit.message }}
on:
push:
Expand All @@ -12,22 +12,15 @@ on:
- 'main'

jobs:
deb_build:
name: 👷 Build DEB Packages
uses: ./.github/workflows/build_deb.yml
secrets: inherit
with:
upload: true

rpm_build:
name: 👷 Build RPM Packages
uses: ./.github/workflows/build_rpm.yml
build_packages:
name: 👷 Build DEB/RPM Packages
uses: ./.github/workflows/build_deb_rpm.yml
secrets: inherit
with:
upload: true

publish_test:
name: 🚀 Create Repository Structure (Test)
needs: [ deb_build, rpm_build ]
needs: build_packages
uses: ./.github/workflows/publish_deb_rpm.yml
secrets: inherit
Loading

0 comments on commit 73c6e94

Please sign in to comment.