Skip to content

Build

Build #42

Workflow file for this run

name: Build
on:
workflow_dispatch:
inputs:
package:
description: 'Package to build'
required: true
default: 'syno-magnet'
publish:
description: 'Publish to repository'
required: false
default: 'false'
pull_request:
paths:
- 'spk/**'
- 'cross/**'
- 'native/**'
push:
branches:
- "**"
paths:
- 'spk/**'
- 'cross/**'
- 'native/**'
jobs:
prepare:
name: Prepare for Build
runs-on: ubuntu-latest
# provide results to other jobs
outputs:
arch_packages: ${{ steps.dependencies.outputs.arch_packages }}
noarch_packages: ${{ steps.dependencies.outputs.noarch_packages }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Get changed files for pull request
if: github.event_name == 'pull_request'
id: getfile_pr
run: |
git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | xargs
echo "files=$(git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | xargs)" >> $GITHUB_OUTPUT
- name: Get changed files for push
if: github.event_name == 'push'
id: getfile
run: |
git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | xargs
echo "files=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
- name: Evaluate dependencies
id: dependencies
run: ./.github/actions/prepare.sh
env:
GH_FILES: ${{ steps.getfile.outputs.files }} ${{ steps.getfile_pr.outputs.files }}
SPK_TO_BUILD: ${{ github.event.inputs.package }}
- name: Cache downloaded files
uses: actions/cache@v3
with:
path: distrib
# use run_id in key to cache within workflow only.
key: distrib-${{ github.run_id }}
- name: Download source files
run: ./.github/actions/download.sh
env:
DOWNLOAD_PACKAGES: ${{ steps.dependencies.outputs.download_packages }}
ARCH_PACKAGES: ${{ needs.prepare.outputs.arch_packages }}
NOARCH_PACKAGES: ${{ needs.prepare.outputs.noarch_packages }}
build:
name: Build
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# x64=x86_64, evansport=i686, aarch64=armv8, armv7, hi3535=armv7l, 88f6281=armv5, qoriq=ppc
# https://github.com/SynoCommunity/spksrc/wiki/Synology-and-SynoCommunity-Package-Architectures
arch: [noarch, noarch-6.1, noarch-7.0, x64-6.2.4, x64-7.1, evansport-6.2.4, evansport-7.1, aarch64-6.2.4, aarch64-7.1, armv7-6.2.4, armv7-7.1, hi3535-6.2.4, 88f6281-6.2.4, qoriq-6.2.4, comcerto2k-7.1]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache toolchains
uses: actions/cache@v3
with:
path: toolchain/*/work
key: toolchain-${{ matrix.arch }}-v3-${{ hashFiles('toolchain/*/digests') }}
- name: Use cache of downloaded files
uses: actions/cache@v3
with:
path: distrib
key: distrib-${{ github.run_id }}
- name: Build Package (based on changed files)
# We don't want to stop the build on errors.
# Errors are reported in "Build Status"
continue-on-error: true
uses: docker://ghcr.io/synocommunity/spksrc:latest
with:
entrypoint: ./.github/actions/build.sh
env:
ARCH_PACKAGES: ${{ needs.prepare.outputs.arch_packages }}
NOARCH_PACKAGES: ${{ needs.prepare.outputs.noarch_packages }}
PUBLISH: ${{ github.event.inputs.publish }}
API_KEY: ${{ secrets.PUBLISH_API_KEY }}
PACKAGE_TO_PUBLISH: ${{ github.event.inputs.package }}
# https://github.com/SynoCommunity/spksrc/wiki/Compile-and-build-rules
GH_ARCH: ${{ matrix.arch }}
BUILD_ERROR_FILE: /github/workspace/build_errors.txt
BUILD_ERROR_LOGFILE: /github/workspace/build_log_errors.txt
BUILD_UNSUPPORTED_FILE: /github/workspace/build_unsupported.txt
BUILD_SUCCESS_FILE: /github/workspace/build_success.txt
- name: Build Status
id: build_status
# We need this status since we don't want to stop the build on errors.
# Here we fail on build errors found in the build error file.
uses: docker://ghcr.io/synocommunity/spksrc:latest
with:
entrypoint: ./.github/actions/build_status.sh
env:
BUILD_ERROR_FILE: /github/workspace/build_errors.txt
BUILD_ERROR_LOGFILE: /github/workspace/build_log_errors.txt
BUILD_UNSUPPORTED_FILE: /github/workspace/build_unsupported.txt
BUILD_SUCCESS_FILE: /github/workspace/build_success.txt
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: Packages for ${{ matrix.arch }}
path: packages/*.spk
if-no-files-found: ignore