Skip to content

Commit

Permalink
Build workflows update (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
phnzb authored Dec 9, 2024
1 parent 433fd23 commit 8464336
Show file tree
Hide file tree
Showing 15 changed files with 470 additions and 203 deletions.
103 changes: 85 additions & 18 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,116 @@ on:
workflow_call:
workflow_dispatch:

env:
BUILD_ARCHS: "aarch64-ndk armhf-ndk i686-ndk x86_64-ndk"
BUILD_TYPES: ${{ (github.ref_name == 'develop' || github.ref_name == 'main') && 'release debug' || 'release' }}
BUILD_TESTING: ${{ (github.ref_name != 'main') && 'testing' || '' }}

jobs:
build:
runs-on: [self-hosted, nzbget-android]

prepare-build-matrix:
runs-on: ubuntu-24.04
outputs:
archs: ${{ steps.matrix-vars.outputs.ARCHS }}
types: ${{ steps.matrix-vars.outputs.TYPES }}
steps:

- name: Calculate matrix variables
id: matrix-vars
run: |
echo ARCHS=[\"$BUILD_ARCHS\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT"
echo TYPES=[\"$BUILD_TYPES\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT"
build-bin:
runs-on: ubuntu-24.04
needs: prepare-build-matrix
strategy:
matrix:
arch: ${{ fromJSON(needs.prepare-build-matrix.outputs.archs) }}
type: ${{ fromJSON(needs.prepare-build-matrix.outputs.types) }}

steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build
- name: Prepare ${{ matrix.arch }} / ${{ matrix.type }} environment
run: |
BUILD_PARAMS="android bin installer"
if [ "$GITHUB_REF_NAME" == "develop" ] || [ "$GITHUB_REF_NAME" == "main" ]; then
BUILD_PARAMS="$BUILD_PARAMS debug release"
else
BUILD_PARAMS="$BUILD_PARAMS release"
fi
if [ "$GITHUB_REF_NAME" != "main" ]; then
BUILD_PARAMS="$BUILD_PARAMS testing"
fi
bash linux/build-nzbget.sh $BUILD_PARAMS
sudo mkdir -p /build
sudo chown $USER:$USER /build
mkdir -p /build/android
mkdir -p /build/lib
curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/android-${{ matrix.arch }}.tar.gz -o /build/android/ndk.tar.gz
curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/lib-${{ matrix.arch }}.tar.gz -o /build/lib/lib.tar.gz
tar zxf /build/android/ndk.tar.gz -C /build/android
tar zxf /build/lib/lib.tar.gz -C /build/lib
sudo apt-get update
sudo apt-get install -y autoconf automake bc build-essential cmake cpio curl file git libtool pkg-config rsync unzip wget libtinfo6
- name: Build
run: bash linux/build-nzbget.sh bin ${{ matrix.arch }} ${{ matrix.type }} ${{ env.BUILD_TESTING }}

- name: Upload full build log on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: nzbget-android-build-log
name: nzbget-android-${{ matrix.arch }}-${{ matrix.type }}-build-log
path: build/*/build.log
retention-days: 5

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: nzbget-${{ matrix.arch }}-${{ matrix.type }}-bin
path: build/*.tar.gz
retention-days: 5

build-installer:
runs-on: ubuntu-24.04
needs: build-bin

steps:

- name: Checkout
uses: actions/checkout@v4

- name: Prepare build environment
run: |
sudo mkdir -p /build
sudo chown $USER:$USER /build
curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/android-unpack.tar.gz -o /build/unpack.tar.gz
tar zxf /build/unpack.tar.gz -C /build
- name: Download build artifacts
uses: actions/download-artifact@v4

- name: Build installer
run: |
mkdir -p build
for ARCH in ${{ env.BUILD_ARCHS }}; do
for TYPE in ${{ env.BUILD_TYPES }}; do
cp nzbget-$ARCH-$TYPE-bin/*.tar.gz build/
done
done
bash linux/build-nzbget.sh android installer ${{ env.BUILD_TYPES }} ${{ env.BUILD_TESTING }}
- name: Rename build artifacts
if: github.ref_name != 'main' && github.ref_name != 'develop'
run: |
cd build
SUFFIX="-${GITHUB_REF_NAME/\//-}-bin-android.run"
SUFFIX="-${GITHUB_REF_NAME/\//-}-bin-android"
for FILE in *.run; do
[ -f $FILE ] || continue
NEW_FILE=${FILE/-bin-android.run/$SUFFIX}
NEW_FILE=${FILE/-bin-android/$SUFFIX}
mv $FILE $NEW_FILE
done
- name: Delete unneeded platform-specific artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: |
nzbget-*-*-*-bin
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
permissions:
actions: write
secrets: inherit

build-linux-pkg:
uses: ./.github/workflows/linux-pkg.yml
with:
Expand All @@ -45,15 +45,15 @@ jobs:
generate-signatures:
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: [build-windows, build-linux, build-osx, build-android, build-freebsd, repack-qnap, build-linux-pkg]
permissions:
actions: write
steps:

- name: Download build artifacts
uses: actions/download-artifact@v4

- name: Generate signatures
run: |
mkdir -p builds
Expand Down Expand Up @@ -97,15 +97,15 @@ jobs:
cd ..
echo
echo "Done."
- name: Upload build artifacts with signatures
uses: actions/upload-artifact@v4
with:
name: nzbget-installers
path: builds/*
retention-days: 5

- name: Delete unneded platform-specific artifacts
- name: Delete unneeded platform-specific artifacts
uses: geekyeggo/delete-artifact@v4
with:
name: |
Expand All @@ -116,7 +116,7 @@ jobs:
nzbget-osx-installers
nzbget-qnap-packages
- name: Delete unneded linux packages artifacts
- name: Delete unneeded linux packages artifacts
uses: geekyeggo/delete-artifact@v4
with:
name: |
Expand All @@ -130,7 +130,7 @@ jobs:
contents: write
if: github.ref_name == 'develop'
steps:

- name: Delete tag and release
uses: dev-drprasad/[email protected]
with:
Expand Down
Loading

0 comments on commit 8464336

Please sign in to comment.