hyperion.ng/.github/workflows/apt.yml
dependabot[bot] a7654f5a37
Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-01 20:16:53 +00:00

155 lines
5.4 KiB
YAML

name: Hyperion APT Build
on:
workflow_call:
inputs:
head_sha:
type: string
description: The branch, tag or SHA to checkout
required: true
secrets:
APT_GPG:
required: true
APT_USER:
required: true
APT_PASSWORD:
required: true
APT_DRAFT:
required: true
workflow_dispatch:
inputs:
head_sha:
type: string
description: The branch, tag or SHA to checkout
required: true
secrets:
APT_GPG:
required: true
APT_USER:
required: true
APT_PASSWORD:
required: true
APT_DRAFT:
required: true
jobs:
setup:
name: Setup APT build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set APT matrix
id: apt-ppa
run: |
APT=$(jq -n '.include |= [ inputs[] | select(.["exclude"] != true)]' .github/workflows/apt/*.json --compact-output)
echo "apt=$APT" >> $GITHUB_OUTPUT
outputs:
apt-matrix: ${{ steps.apt-ppa.outputs.apt }}
build:
name: ${{ matrix.description }}
needs: [setup]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.setup.outputs.apt-matrix) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.head_sha || github.event.client_payload.head_sha }}
submodules: true
- name: Generate environment variables
run: |
tr -d '\n' < .version > temp && mv temp .version
VERSION=$(cat .version)
echo VERSION=${VERSION} >> $GITHUB_ENV
if [[ $VERSION == *"-"* ]]; then
echo STANDARDS_VERSION=$(echo ${VERSION%-*}) >> $GITHUB_ENV
echo TARBALL_VERSION=$(echo ${VERSION%-*}) >> $GITHUB_ENV
echo DEBIAN_FORMAT='3.0 (quilt)' >> $GITHUB_ENV
else
echo STANDARDS_VERSION=$(echo ${VERSION%+*}) >> $GITHUB_ENV
echo TARBALL_VERSION=${VERSION}~$(echo ${{ matrix.distribution }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo DEBIAN_FORMAT='3.0 (native)' >> $GITHUB_ENV
fi
echo DISTRIBUTION=$(echo ${{ matrix.distribution }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Build package
shell: bash
run: |
mkdir -p "${GITHUB_WORKSPACE}/deploy"
docker run --rm \
-v "${GITHUB_WORKSPACE}/deploy:/deploy" \
-v "${GITHUB_WORKSPACE}:/source:rw" \
ghcr.io/hyperion-project/${{ matrix.architecture }}:${{ env.DISTRIBUTION }} \
/bin/bash -c "cd /source && \
mkdir -p debian/source && echo '${{ env.DEBIAN_FORMAT }}' > debian/source/format && \
dch --create --distribution ${{ env.DISTRIBUTION }} --package 'hyperion' -v '${{ env.VERSION }}~${{ env.DISTRIBUTION }}' '${{ github.event.commits[0].message }}' && \
cp -fr LICENSE debian/copyright && \
sed 's/@BUILD_DEPENDS@/${{ matrix.build-depends }}/g; s/@DEPENDS@/${{ matrix.package-depends }}/g; s/@ARCHITECTURE@/${{ matrix.architecture }}/g; s/@STANDARDS_VERSION@/${{ env.STANDARDS_VERSION }}/g' debian/control.in > debian/control && \
sed 's/@CMAKE_ENVIRONMENT@/${{ matrix.cmake-environment }}/g' debian/rules.in > debian/rules && \
tar -cJf ../hyperion_${{ env.TARBALL_VERSION }}.orig.tar.xz . && \
debuild --no-lintian -uc -us && \
cp ../hyperion_*.deb /deploy"
- name: Upload package artifact
if: ${{ startsWith(github.event.ref, 'refs/tags') || github.event_name == 'workflow_dispatch' }}
uses: actions/upload-artifact@v3
with:
path: deploy
retention-days: 1
publish:
name: Publish APT packages
if: ${{ startsWith(github.event.ref, 'refs/tags') || github.event_name == 'workflow_dispatch' }}
needs: [setup, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.head_sha || github.event.client_payload.head_sha }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5.3.0
with:
gpg_private_key: ${{ secrets.APT_GPG }}
- name: Install reprepro
run: sudo apt -y install reprepro
- name: Make build folders, export public GPG key and copy distributions file
run: |
mkdir -p apt/{conf,dists,db}
gpg --armor --output apt/hyperion.pub.key --export 'admin@hyperion-project.org'
cp debian/distributions apt/conf/distributions
- name: Create initial structure/packages files and symbolic links
run: |
reprepro -Vb apt createsymlinks
reprepro -Vb apt export
- name: Download artifacts
uses: actions/download-artifact@v3.0.2
- name: Include artifacts into the package source
run: |
for file in artifact/hyperion_*.deb; do
if [ -f "$file" ]; then
dist=${file#*~}
dist=${dist%_*}
reprepro -Vb apt/ includedeb "$dist" "$file"
fi
done
- name: Upload packages to APT server (DRAFT)
uses: SamKirkland/FTP-Deploy-Action@v4.3.4
with:
server: apt.hyperion-project.org
username: ${{ secrets.APT_USER }}
password: ${{ secrets.APT_PASSWORD }}
local-dir: "./apt/"
server-dir: ${{ secrets.APT_DRAFT }}
dangerous-clean-slate: true