add GHA build

This commit is contained in:
sebthom 2022-11-13 20:59:55 +01:00
parent 278673a980
commit 8417dcf705
2 changed files with 210 additions and 2 deletions

210
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,210 @@
# Copyright (C) 2022 Vegard IT GmbH
# SPDX-License-Identifier: MIT
#
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
name: Build
on:
push:
branches:
- '**'
tags-ignore:
- '**'
paths-ignore:
- '**/*.md'
- '**/*.rst'
- '.github/*.yml'
pull_request:
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
inputs:
DSM_VERSION:
description: 'DSM Version'
required: true
default: '7.1'
defaults:
run:
shell: bash
env:
DSM_VERSION: '7.1'
jobs:
###########################################################
build:
###########################################################
strategy:
fail-fast: false
matrix:
# see https://kb.synology.com/en-uk/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have
PACKAGE_ARCH:
- apollolake # e.g. DS918+
- armada37xx
- armada38x
- avoton
- braswell # e.g. DS716+II
- broadwell
- broadwellnk
- bromolow
- cedarview
- denverton # e.g. RS2418+
- geminilake
- grantley
- kvmx64
- monaco
- purley
- rtd1296
- v1000
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3 #https://github.com/actions/checkout
- name: Set effective DSM version
run: |
set -eux
if [[ -n "${{ github.event.inputs.DSM_VERSION }}" ]]; then
echo "DSM_VERSION=${{ github.event.inputs.DSM_VERSION }}" >> $GITHUB_ENV
fi
- name: Build synobuild Docker image
run: |
set -eux
docker build -t synobuild .
- uses: actions/cache@v3
with:
path: toolkit_tarballs/ds.*
key: synology_toolkit_tarballs_DSM${{ env.DSM_VERSION }}_${{ matrix.PACKAGE_ARCH }}
- uses: actions/cache@v3
with:
path: toolkit_tarballs/base_env-*
key: synology_toolkit_tarballs_DSM${{ env.DSM_VERSION }}_base_env
- name: Download Synology Toolkit tarballs
run: |
set -eux
mkdir -p toolkit_tarballs
pushd toolkit_tarballs/
archive_base_url="https://global.download.synology.com/download/ToolChain/toolkit/$DSM_VERSION"
archive=base_env-${DSM_VERSION}.txz
[[ -f $archive ]] || curl -sSf "$archive_base_url/base/$archive" -o $archive
archive=ds.${{ matrix.PACKAGE_ARCH }}-$DSM_VERSION.dev.txz
[[ -f $archive ]] || curl -sSf "$archive_base_url/${{ matrix.PACKAGE_ARCH }}/$archive" -o $archive
archive=ds.${{ matrix.PACKAGE_ARCH }}-$DSM_VERSION.env.txz
[[ -f $archive ]] || curl -sSf "$archive_base_url/${{ matrix.PACKAGE_ARCH }}/$archive" -o $archive
popd
- name: Build SPK files
continue-on-error: true
run: |
set -eux
mkdir artifacts
docker run --rm --privileged \
--env PACKAGE_ARCH=${{ matrix.PACKAGE_ARCH }} \
--env DSM_VER=${DSM_VERSION} \
-v $(pwd)/artifacts:/result_spk \
-v $(pwd)/toolkit_tarballs:/toolkit_tarballs \
synobuild
ls -l artifacts
ls -l artifacts/*
for spk in artifacts/*/*.spk; do
sudo mv "$spk" "${spk%.spk}_DSM${DSM_VERSION}.spk"
done
- name: Upload SPKs
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v3
with:
name: artifacts-${{ matrix.PACKAGE_ARCH }}
path: artifacts/**
###########################################################
publish-release:
###########################################################
runs-on: ubuntu-latest
needs:
- build
if: github.ref == 'refs/heads/master'
concurrency: publish-latest-release # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idconcurrency
steps:
- name: Git checkout
# only required by "hub release create" to prevent "fatal: Not a git repository"
uses: actions/checkout@v3 #https://github.com/actions/checkout
- name: Download build artifacts
uses: actions/download-artifact@v3
- name: Set effective DSM version
run: |
set -eux
if [[ -n "${{ github.event.inputs.DSM_VERSION }}" ]]; then
echo "DSM_VERSION=${{ github.event.inputs.DSM_VERSION }}" >> $GITHUB_ENV
fi
- name: Set effective WireGuard version
run: |
set -eux
spks=($(ls artifacts-*/WireGuard-*/*.spk))
[[ ${spks[0]} =~ ([0-9.]+) ]] && echo "${BASH_REMATCH[1]}"
echo "WG_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
- name: "Delete previous release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eux
api_base_url="$GITHUB_API_URL/repos/$GITHUB_REPOSITORY"
release_name=WireGuard-${WG_VERSION}-DSM${DSM_VERSION}
# https://hub.github.com/hub-release.1.html
hub release delete "${release_name}" || true
# delete git tag
tag_url="$api_base_url/git/refs/tags/${release_name}"
if curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -fsLo /dev/null --head "$tag_url"; then
echo "Deleting tag [$tag_url]..."
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -fsSL -X DELETE "$tag_url"
fi
- name: "Create release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eux
release_name=WireGuard-${WG_VERSION}-DSM${DSM_VERSION}
spks=($(ls artifacts-*/WireGuard-*/*.spk))
# https://hub.github.com/hub-release.1.html
hub release create "${release_name}" \
--message "${release_name}" \
--message "See https://kb.synology.com/en-uk/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have to find the right architecture of your NAS" \
${spks[@]/#/--attach }
- name: "Delete intermediate build artifacts"
uses: geekyeggo/delete-artifact@v2 # https://github.com/GeekyEggo/delete-artifact/
with:
name: "*"
failOnError: false

View File

@ -16,7 +16,6 @@ recover the data, this might not be for you.
FAQ/Known issues FAQ/Known issues
---------------- ----------------
* The releases in the releases page are for DSM 6 only. For DSM7, you'll need to follow the instructions in this readme and compile it yourself.
* The ``Dns = x.x.x.x`` setting is unsupported. If you try it you will get the * The ``Dns = x.x.x.x`` setting is unsupported. If you try it you will get the
following message: following message:
``/usr/local/bin/wg-quick: line 31: resolvconf: command not found`` ``/usr/local/bin/wg-quick: line 31: resolvconf: command not found``
@ -41,7 +40,6 @@ Compatibility list
All models marked *Is working* have been confirmed by users to work. If your All models marked *Is working* have been confirmed by users to work. If your
model has the same platform as one of the working ones, chances are it will model has the same platform as one of the working ones, chances are it will
work for you too. work for you too.
**Note**: the releases in the releases page are for DSM 6 only. For DSM7, you'll need to follow the instructions in this readme and compile it yourself.
=========== ========== =========== =========================== =========== ========== =========== ===========================
Model Platform DSM Version Is working? Model Platform DSM Version Is working?