Updates to mycron app #88
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WD MyCloud package builder CI | |
# by Stefaan Ghysels | |
# | |
# Please note that I started with local development with https://github.com/nektos/act | |
# but once that was working it became clear that many features of github actions were not supported yet | |
# Hence the messy code below. | |
name: WD MyCloud package CI | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
pull_request: | |
types: [ synchronize ] | |
branches: [ master ] | |
paths: | |
- wdpk/** | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow should get 3 jobs: build, test and publish | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
container: | |
image: wdpk/wdpk | |
options: -v ${{github.workspace}}/packages:/github/workspace/packages | |
# define all the OS5 supporting platforms and a prettier name | |
strategy: | |
matrix: | |
include: | |
- model: EX4100 | |
platform: WDMyCloudEX4100 | |
- model: DL4100 | |
platform: WDMyCloudDL4100 | |
- model: EX2100 | |
platform: WDMyCloudEX2100 | |
- model: DL2100 | |
platform: WDMyCloudDL2100 | |
- model: MirrorG2 | |
platform: WDMyCloudMirror | |
- model: EX2Ultra | |
platform: MyCloudEX2Ultra | |
- model: PR4100 | |
platform: MyCloudPR4100 | |
- model: PR2100 | |
platform: MyCloudPR2100 | |
environment: staging | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
- name: Get package that was changed in the last commit | |
id: diff | |
run: | | |
wget ${{ github.event.pull_request.diff_url }} -O pr.diff | |
pkg=$(grep "^\+\+\+ b/wdpk/" pr.diff | cut -d/ -f3 | uniq) | |
# concat packages into single line | |
pkgs="" | |
for p in $pkg; do | |
pkgs="${pkgs}${p} " | |
done | |
echo "Packages: ${pkgs}" | |
echo "PACKAGE=${pkgs}" >> $GITHUB_ENV | |
- name: Make APKG packages for selected platforms | |
id: make_apkg | |
env: | |
PLATFORM: ${{ matrix.platform }} | |
MODEL: ${{ matrix.model }} | |
run: | | |
pkg=$(echo ${PACKAGE:-docker} | cut -d' ' -f1) | |
echo ::set-output name=pkg::"$pkg" | |
cd wdpk/${pkg} | |
DATE="$(date +"%m%d%Y")" | |
CWD="$(pwd)" | |
VERSION="$(awk '/Version/{print $NF}' apkg.rc)" | |
echo ::set-output name=version::"${VERSION}" | |
NAME="$(awk '/AddonShowName/{print $NF}' apkg.rc)" | |
echo ::set-output name=name::"${NAME}" | |
DESCRIPTION="$(awk '/Description/{print $NF}' apkg.rc)" | |
echo ::set-output name=description::"${DESCRIPTION}" | |
echo "Building ${pkg} version ${VERSION}" | |
echo "$(ls -l ../..)" | |
RELEASE_DIR="../../packages/${pkg}/OS5" | |
mkdir -p "${RELEASE_DIR}" | |
echo "PLF ${PLATFORM} - $arr - ${PACKAGE}" | |
echo "Build ${pkg} for $MODEL" | |
../../mksapkg-OS5 -E -s -m ${PLATFORM} > /dev/null | |
mv ../${PLATFORM}*.bin\(* ../${pkg}_${VERSION}_${MODEL}.bin | |
echo "$(ls -l ..)" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ steps.make_apkg.outputs.pkg }}_${{ steps.make_apkg.outputs.version }}_OS5 | |
path: wdpk/*_*_*.bin | |
- name: Publish packages to CloudSmith | |
id: push | |
uses: cloudsmith-io/action@master | |
with: | |
api-key: ${{ secrets.CLOUDSMITH_API_KEY }} | |
command: 'push' | |
format: 'raw' | |
owner: 'wd-community' # Your Cloudsmith account name or org name (namespace) | |
repo: ${{matrix.model}} # Your Cloudsmith Repository name (slug) | |
file: ./wdpk/${{steps.make_apkg.outputs.pkg}}_${{steps.make_apkg.outputs.version}}_${{matrix.model}}.bin # Name of file | |
name: ${{steps.make_apkg.outputs.pkg}} # Name for Raw package | |
summary: ${{ github.sha }} # Optional Summary for Raw Package | |
description: ${{steps.make_apkg.outputs.description}} # Optional description for Raw package | |
version: ${{steps.make_apkg.outputs.version}} | |
republish: "true" |