Skip to content

Commit

Permalink
Build pipeline using Github Actions
Browse files Browse the repository at this point in the history
* build macOS, Linux, Win64, Docker packages on Github
* reach back out to local build machine for legacy packages for Win32 and OSX - when the box dies, those builds will be gone
* cron job runs nightlies once a day
  • Loading branch information
michaelherger committed Sep 2, 2024
1 parent c31e12e commit 9ace074
Show file tree
Hide file tree
Showing 3 changed files with 405 additions and 0 deletions.
137 changes: 137 additions & 0 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Build Logitech Media Server
description: Build Logitech Media Server with the given parameters
inputs:
build-params:
description: Parameters needed to run the `buildme.pl` script
required: true
default: ubuntu-latest
build-type:
description: "`nightly` or `production`"
required: true
default: nightly
ssh-connect-string:
description: Connection string to be used to to connect to the locally run build host.
AWS_KEY_ID:
description: The key ID to use to upload to S3
AWS_SECRET_ACCESS_KEY:
description: The secret to use to upload to S3

runs:
using: composite
steps:
- name: Get LMS version number
shell: bash
id: getversion
run: |
MAJOR=$(grep "\$VERSION" server/slimserver.pl | head -n1 | cut -d"'" -f2 | cut -d. -f1)
MINOR=$(grep "\$VERSION" server/slimserver.pl | head -n1 | cut -d"'" -f2 | cut -d. -f2)
echo "LMS_VERSION=$MAJOR.$MINOR" >> $GITHUB_OUTPUT
echo "GIT_BRANCH=public/$MAJOR.$MINOR" >> $GITHUB_OUTPUT
- name: Check out LMS platform code
uses: actions/checkout@v4
with:
repository: Logitech/slimserver-platforms
path: platforms
ref: ${{ steps.getversion.outputs.GIT_BRANCH }}


- name: Set up Docker environment
if: ${{ startsWith(inputs.build-params, 'docker') }}
id: dockersetup
shell: bash
run: |
if [ "${{ steps.getversion.outputs.LMS_VERSION }}" = "8.5" ]; then
echo "LMS_TAG=--tag=dev" >> $GITHUB_OUTPUT
else
echo "LMS_TAG=--tag=stable" >> $GITHUB_OUTPUT
fi
# TODO - correct Docker registry!
echo TEMPORARY DOCKER DEV ONLY!!!!
sed -ie "s/lmscommunity/mherger/" platforms/buildme.pl
egrep "tag.*logitechmediaserver" platforms/buildme.pl
- name: Set up macOS environment
if: ${{ startsWith(inputs.build-params, 'macos') }}
shell: bash
run: |
# set up Platypus - see https://github.com/sveinbjornt/Platypus/issues/270#issuecomment-2312235079
echo "Creating directory structures"
mkdir -p /usr/local/bin || echo $?
mkdir -p /usr/local/share/platypus || echo $?
cd platforms/osx/platypus
echo "Copying resources to share directory"
sudo cp -nfr ScriptExec MainMenu.nib /usr/local/share/platypus
sudo chmod -R 755 /usr/local/share/platypus
echo "Installing command line tool"
sudo cp -nf platypus /usr/local/bin
sudo chmod +x /usr/local/bin/platypus
- name: Set up Windows environment
if: ${{ startsWith(inputs.build-params, 'win64') }}
shell: bash
run: |
cp -nf platforms/win32/tools/* 'c:\Program Files\Git\usr\bin\'
- name: Build ${{ inputs.build-params }} package on ${{ runner.os }} (self-hosted runner)
if: ${{ inputs.ssh-connect-string != '' }}
shell: bash
run: |
ssh ${{ inputs.ssh-connect-string }} "mkdir -p $BASEDIR; rm -rf $BASEDIR/publish"
rsync -a --delete server platforms ${{ inputs.ssh-connect-string }}:$BASEDIR/
ssh ${{ inputs.ssh-connect-string }} "cd $BASEDIR && platforms/buildme.pl --build ${{ inputs.build-params }} --buildDir \$(pwd)/work --sourceDir \$(pwd) --destDir \$(pwd)/publish --releaseType ${{ inputs.build-type }}"
rm -rf publish
mkdir -p publish
scp ${{ inputs.ssh-connect-string }}:$BASEDIR/publish/* publish/
- name: Build ${{ inputs.build-params }} package on ${{ runner.os }}
if: ${{ inputs.ssh-connect-string == '' }}
shell: bash
run: |
SRC_PATH=$PWD
BUILD_PATH=$SRC_PATH/work
DEST_PATH=$SRC_PATH/publish
mkdir -p $BUILD_PATH
mkdir -p $DEST_PATH
platforms/buildme.pl --build ${{ inputs.build-params }} ${{ steps.dockersetup.outputs.LMS_TAG }} --buildDir $BUILD_PATH --sourceDir $SRC_PATH --destDir $DEST_PATH --releaseType ${{ inputs.build-type }}
- name: Verify results
if: ${{ !startsWith(inputs.build-params, 'docker') }}
shell: bash
run: |
if [ ! -f publish/* ]; then
exit 1;
fi
- name: Upload artifacts
if: ${{ !startsWith(inputs.build-params, 'docker') }}
shell: bash
run: |
mkdir -p $HOME/.aws
echo "[downloads]" > $HOME/.aws/credentials
# region is irrelevant for Cloudflare R2, but required by the aws CLI tool
echo "region=us-east-1" >> $HOME/.aws/credentials
echo "aws_access_key_id=${{ inputs.AWS_KEY_ID }}" >> $HOME/.aws/credentials
echo "aws_secret_access_key=${{ inputs.AWS_SECRET_ACCESS_KEY }}" >> $HOME/.aws/credentials
for f in publish/?yrion?usic?erver*;
do
aws --profile downloads --endpoint-url https://e83bc03c881257fada7ca16c243e9298.eu.r2.cloudflarestorage.com s3 cp $f s3://downloads/${{ inputs.build-type }}/
done
rm -f $HOME/.aws/credentials
189 changes: 189 additions & 0 deletions .github/workflows/00_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
name: Build LMS

# Test using act: act -W .github/workflows/00_build.yaml --pull=false

on:
workflow_dispatch:
inputs:
branch:
type: string
description: 'The branch from which to build from'
required: true
default: ${{ github.event.repository.default_branch }}
build_type:
type: choice
description: 'Is this a nightly or a release build?'
required: true
default: 'nightly'
options:
- nightly
- release

jobs:
macLegacy:
name: Build LMS for Mac (Legacy)
runs-on: self-hosted
timeout-minutes: 20
env:
BASEDIR: gh-build
steps:
# we must check out here, as otherwise the build action is not available
- name: Check out LMS code
uses: actions/checkout@v4
with:
path: server
ref: ${{ inputs.branch }}

- name: Launch build process
uses: ./server/.github/actions/build
with:
build-params: macosx
build-type: ${{ inputs.build_type }}
ssh-connect-string: ${{ secrets.MAC_CONNECT_STRING }}
AWS_KEY_ID: ${{ secrets.R2_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}

mac:
name: Build LMS for Mac (MenuBar Item)
runs-on: macos-12
steps:
# we must check out here, as otherwise the build action is not available
- name: Check out LMS code
uses: actions/checkout@v4
with:
path: server
ref: ${{ inputs.branch }}

- name: Launch build process
uses: ./server/.github/actions/build
with:
build-params: macos
build-type: ${{ inputs.build_type }}
AWS_KEY_ID: ${{ secrets.R2_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}

linux:
name: Build LMS for Linux
runs-on: ubuntu-22.04
strategy:
matrix:
flavour:
- [debian, "--x86_64"]
- [debian, "--arm"]
- [debian, "--i386"]
- [debian, ""]
- [rpm, ""]
- [tarball, "--arm"]
- [tarball, ""]
- [tarball, "--encore"]
- [tarball, "--noCPAN"]

steps:
# we must check out here, as otherwise the build action is not available
- name: Check out LMS code
uses: actions/checkout@v4
with:
path: server
ref: ${{ inputs.branch }}

- name: Prepare build environment
if: ${{ matrix.flavour[0] != 'tarball' }}
run: |
sudo apt update
sudo apt install apt-transport-https debhelper devscripts
- name: Launch build process
uses: ./server/.github/actions/build
with:
build-params: ${{ matrix.flavour[0] }} ${{ matrix.flavour[1] }}
build-type: ${{ inputs.build_type }}
AWS_KEY_ID: ${{ secrets.R2_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}

docker:
if: false
name: Build LMS for Docker
runs-on: ubuntu-22.04

steps:
# we must check out here, as otherwise the build action is not available
- name: Check out LMS code
uses: actions/checkout@v4
with:
path: server
ref: ${{ inputs.branch }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Launch build process
uses: ./server/.github/actions/build
with:
build-params: docker
build-type: ${{ inputs.build_type }}

win64:
name: Build LMS for Windows (64-bit)
runs-on: windows-2022
steps:
# we must check out here, as otherwise the build action is not available
- name: Check out LMS code
uses: actions/checkout@v4
with:
path: server
ref: ${{ inputs.branch }}

- name: Launch build process
uses: ./server/.github/actions/build
with:
build-params: win64
build-type: ${{ inputs.build_type }}
AWS_KEY_ID: ${{ secrets.R2_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}

win32:
name: Build LMS for Windows (Legacy 32-bit)
runs-on: self-hosted
timeout-minutes: 30
env:
BASEDIR: gh-build
steps:
# we must check out here, as otherwise the build action is not available
- name: Check out LMS code
uses: actions/checkout@v4
with:
path: server
ref: ${{ inputs.branch }}

- name: Launch build process
uses: ./server/.github/actions/build
with:
build-params: win32
build-type: ${{ inputs.build_type }}
ssh-connect-string: ${{ secrets.WIN_CONNECT_STRING }}
AWS_KEY_ID: ${{ secrets.R2_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}

updateRepoFile:
name: Trigger repository file update
if: ${{ always() && inputs.build_type == 'nightly' }}
runs-on: ubuntu-latest
timeout-minutes: 2
needs:
- macLegacy
- mac
- linux
- win64
- win32
permissions:
actions: write
steps:
- env:
GH_TOKEN: ${{ secrets.DEPLOYMENT_KEY }}
run: gh workflow run update-server-repository.yml -R https://github.com/LMS-Community/lms-server-repository
Loading

0 comments on commit 9ace074

Please sign in to comment.