hyperion.ng/.github/workflows/nightly.yml

149 lines
5.5 KiB
YAML
Raw Normal View History

name: Nightly build
# Create nightly builds at the end of every day
on:
schedule:
- cron: '0 0 * * *'
jobs:
2021-10-09 13:10:55 +02:00
check:
name: Compare local <-> nightly
2021-10-10 12:24:03 +02:00
if: github.repository_owner == 'hyperion-project'
2021-10-09 13:10:55 +02:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check if commit has changed
id: build-necessary
run: |
2021-10-26 19:55:33 +02:00
if wget --spider "https://nightly.apt.hyperion-project.org/$(git rev-parse --short HEAD)" 2>/dev/null; then
2021-10-09 13:10:55 +02:00
echo "::set-output name=commit-has-changed::false"
else
echo "::set-output name=commit-has-changed::true"
fi
outputs:
build-nightly: ${{ steps.build-necessary.outputs.commit-has-changed }}
setup:
name: Setup nightly build
2021-10-09 13:10:55 +02:00
needs: [check]
if: ${{ needs.check.outputs.build-nightly == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set nightly matrix
id: nightly-ppa
run: |
NIGHTLY=$(jq -n '.include |= [inputs[]]' .github/workflows/apt/*.json --compact-output)
echo "::set-output name=nightly::$NIGHTLY"
outputs:
nightly-matrix: ${{ steps.nightly-ppa.outputs.nightly }}
build:
name: ${{ matrix.description }}
needs: [setup]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.setup.outputs.nightly-matrix) }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Generate environment variables
run: |
echo "$(tr -d '\n' < .version)+nightly$(date '+%Y%m%d')$(git rev-parse --short HEAD)" > .version
VERSION=$(cat .version)
echo VERSION=${VERSION} >> $GITHUB_ENV
2021-12-13 20:07:45 +01:00
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 && \
2021-12-13 20:07:45 +01:00
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 && \
2021-11-18 17:18:34 +01:00
sed 's/@CMAKE_ENVIRONMENT@/${{ matrix.cmake-environment }}/g' debian/rules.in > debian/rules && \
2021-12-13 20:07:45 +01:00
tar -cJf ../hyperion_${{ env.TARBALL_VERSION }}.orig.tar.xz . && \
debuild --no-lintian -uc -us && \
cp ../hyperion_* /deploy"
- name: Upload package artifact
uses: actions/upload-artifact@v2.2.4
with:
path: deploy
retention-days: 1
publish:
name: Publish nightly packages
needs: [setup, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v3.1.0
with:
gpg-private-key: ${{ secrets.APT_GPG }}
- name: Install reprepro
run: sudo apt -y install reprepro
2021-10-09 13:10:55 +02:00
- name: Make build folders, export public GPG key, copy distributions file and create short sha file for nightly build check
run: |
2021-10-09 13:10:55 +02:00
mkdir -p nightly/{conf,dists,db}
gpg --armor --output nightly/hyperion.pub.key --export 'admin@hyperion-project.org'
cp debian/distributions nightly/conf/distributions
touch "nightly/$(git rev-parse --short HEAD)"
- name: Create initial structure/packages files and symbolic links
run: |
2021-10-09 13:10:55 +02:00
reprepro -Vb nightly createsymlinks
reprepro -Vb nightly export
- name: Download artifacts
uses: actions/download-artifact@v2.0.10
- name: Include artifacts into the package source
run: |
for file in artifact/*.deb; do
if [ -f "$file" ]; then
dist=${file#*~}
dist=${dist%_*}
2021-10-09 13:10:55 +02:00
reprepro -Vb nightly/ includedeb "$dist" "$file"
fi
done
- name: Upload packages to nightly server
uses: SamKirkland/FTP-Deploy-Action@4.1.0
with:
2021-10-26 19:55:33 +02:00
server: nightly.apt.hyperion-project.org
2021-10-09 13:10:55 +02:00
username: ${{ secrets.NIGHTLY_USER }}
password: ${{ secrets.NIGHTLY_PASSWORD }}
local-dir: "./nightly/"
server-dir: "./"
dangerous-clean-slate: true
- name: Remove intermediate artifacts
uses: geekyeggo/delete-artifact@v1
with:
name: artifact
failOnError: false