Skip to content

Commit

Permalink
Migrate to Github Action build ...
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjswan committed Mar 23, 2024
1 parent 30266bb commit d3bab40
Show file tree
Hide file tree
Showing 10 changed files with 1,092 additions and 20 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2

updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
day: monday
time: "12:00"
labels:
- dependencies
commit-message:
prefix: "DEP"
open-pull-requests-limit: 10
319 changes: 319 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
name: Build / WiFi Remote

on:
push:
# On Push to Master branch
branches:
- develop
# Ignore all Tags / Release
tags-ignore:
- '**'

workflow_call:
inputs:
retention-build:
description: "Retention Period for Setup files. Default is 90"
default: 90
required: false
type: number
outputs:
version:
description: "MPE1 Version"
value: ${{ jobs.mpe.outputs.version }}

jobs:
build:
name: WiFi Remote / Build
runs-on: windows-2019
steps:
- name: Setup Visual Studio 2019
uses: microsoft/setup-msbuild@v2
with:
vs-version: 16.11

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

- name: Nuget
run: |
nuget restore
working-directory: ${{ github.workspace }}\Sources
shell: cmd

- name: Build
run: |
build_git.bat < nul
working-directory: ${{ github.workspace }}\Installer
shell: cmd

- name: Upload Artifact / Plugin
uses: actions/upload-artifact@v4
if: ${{ success() }}
with:
name: WiFiRemote
path: |
${{ github.workspace }}\Sources\WifiRemote\bin\Release\WifiRemote.dll
retention-days: ${{ inputs.retention-build || 90 }}
if-no-files-found: error

- name: Save cache
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}
key: plugin

changes:
name: XMP2 / Changed
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.changes.outputs.xmp }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
xmp:
- '**.xmp2'
codeql:
name: CodeQL
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: andrewjswan/MPE/.github/workflows/codeql.yml@master
with:
build-path: WiFiRemote\Installer
needs:
- build
- changes
permissions:
security-events: write
secrets: inherit

mpe:
name: WiFi Remote / MPE
runs-on: windows-2019
needs:
- build
- changes
outputs:
version: ${{ steps.version.outputs.version }}
changes: ${{ needs.changes.outputs.changes }}
steps:
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}
key: plugin

- name: Git Checkout / MPE / XPath
uses: actions/checkout@v4
with:
repository: andrewjswan/MPE
path: MPE

- name: MP folder for MPEMaker
run: |
mkdir "C:\Team MediaPortal"
shell: cmd

- name: Link to MPEMaker
run: |
mklink /J "C:\Team MediaPortal\MediaPortal" "${{ github.workspace }}\MPE\MPEMaker"
shell: cmd

- name: Clear Build folder
run: |
del /F /Q *.mpe1
working-directory: ${{ github.workspace }}\Installer
shell: cmd

- name: Get MPE1 Version
id: version
run: |
FOR /F "tokens=*" %%i IN ('Tools\sigcheck.exe -accepteula -nobanner -n "..\Sources\WifiRemote\bin\Release\WifiRemote.dll"') DO (ECHO version=%%i >> %GITHUB_OUTPUT%)
working-directory: ${{ github.workspace }}\Installer
shell: cmd

- name: Build MPE1
run: |
Create_Installer.bat
working-directory: ${{ github.workspace }}\Installer
shell: cmd

- name: Upload Artifact / MPE1
uses: actions/upload-artifact@v4
if: ${{ success() }}
with:
name: WiFiRemote MPE1
path: |
${{ github.workspace }}\Installer\WifiRemote-*.mpe1
retention-days: ${{ inputs.retention-build || 90 }}
if-no-files-found: error

- name: Upload Artifact / MPE XML
uses: actions/upload-artifact@v4
if: ${{ success() && needs.changes.outputs.changes == 'true' }}
with:
name: WiFiRemote XML
path: |
${{ github.workspace }}\Installer\update.xml
retention-days: ${{ inputs.retention-build || 90 }}
if-no-files-found: error

- name: Get Release Version Description
if: ${{ success() && needs.changes.outputs.changes == 'true' }}
run: |
call ..\..\MPE\XPath\xpath.cmd "update.xml" "//Items/PackageClass/GeneralInfo/VersionDescription" last > description.txt
working-directory: ${{ github.workspace }}\Installer
shell: cmd

- name: Add Badges to Release Version Description
if: ${{ success() && needs.changes.outputs.changes == 'true' }}
run: |
ECHO. >> description.txt
ECHO [![Downloads](https://img.shields.io/github/downloads/MPExtended/WifiRemote/${{steps.version.outputs.version}}/total)](https://github.com/MPExtended/WifiRemote/releases/tag/${{steps.version.outputs.version}}) [![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md) >> description.txt
working-directory: ${{ github.workspace }}\Installer
shell: cmd

- name: Clean Release Version Description
if: ${{ success() && needs.changes.outputs.changes == 'true' }}
run: |
sed.exe -i "s/ \//\//g" description.txt
working-directory: ${{ github.workspace }}\Installer
shell: cmd

- name: Upload Artifact / Version Description
uses: actions/upload-artifact@v4
if: ${{ success() && needs.changes.outputs.changes == 'true' }}
with:
name: WiFiRemote Version Description
path: |
${{ github.workspace }}\Installer\description.txt
retention-days: ${{ inputs.retention-build || 90 }}
if-no-files-found: error

xml:
name: WiFi Remote / XML
runs-on: ubuntu-latest
if: ${{ needs.mpe.outputs.changes == 'true' }}
needs:
- mpe
permissions:
contents: write
outputs:
changes: ${{ needs.mpe.outputs.changes }}
steps:
- name: Git Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: WiFiRemote XML
path: ${{ github.workspace }}/Installer

- name: Update / MPE1 XML
uses: EndBug/add-and-commit@v9
with:
message: 'WiFi Remote ${{needs.mpe.outputs.version}} / Release'
add: '${{ github.workspace }}/Installer/update.xml'

- name: Delete XML Artifact
uses: geekyeggo/delete-artifact@v5
with:
name: WiFiRemote XML
failOnError: false

release:
name: WiFi Remote / Release
if: ${{ needs.mpe.outputs.changes == 'true' }}
needs:
- mpe
- xml
permissions:
contents: write

runs-on: ubuntu-latest

steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: WiFiRemote MPE1
path: release-files

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: WiFiRemote Version Description
path: release-description

- name: Check Artifacts
run: |
ls -l
working-directory: release-files

- name: Release
uses: softprops/action-gh-release@v2
with:
name: WiFi Remote v${{needs.mpe.outputs.version}}
tag_name: ${{needs.mpe.outputs.version}}
body_path: release-description/description.txt
generate_release_notes: true
files: |
release-files/*.mpe1
- name: Delete MPE1 Artifact
uses: geekyeggo/delete-artifact@v5
with:
name: WiFiRemote MPE1
failOnError: false

- name: Delete Version Description Artifact
uses: geekyeggo/delete-artifact@v5
with:
name: WiFiRemote Version Description
failOnError: false

ci-status:
name: Build Status
runs-on: ubuntu-latest
needs:
- build
- mpe
if: always()
steps:
- name: Success
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Failure
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1

release-status:
name: Release Status
if: ${{ needs.release.outputs.changes == 'true' }}
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Success
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Failure
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1

cache-clear:
name: Clear cache
runs-on: ubuntu-latest
needs:
- mpe
if: always()
steps:
- name: Clear cache
uses: easimon/wipe-cache@main
34 changes: 34 additions & 0 deletions Installer/Build_GIT.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@echo off
cls
Title Building MediaPortal WiFi Remote (RELEASE)

ECHO.
ECHO Building WiFiRemote ...

cd ..\Sources

setlocal enabledelayedexpansion

if "%programfiles(x86)%XXX"=="XXX" goto 32BIT
:: 64-bit
set PROGS=%programfiles(x86)%
goto CONT
:32BIT
set PROGS=%ProgramFiles%
:CONT
IF NOT EXIST "%PROGS%\Team MediaPortal\MediaPortal\" SET PROGS=C:

:: Prepare version
for /f "tokens=*" %%a in ('git rev-list HEAD --count') do set REVISION=%%a
set REVISION=%REVISION: =%
"..\Installer\Tools\sed.exe" -i "s/\$WCREV\$/%REVISION%/g" WifiRemote\Properties\AssemblyInfo.cs

:: Build
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\MSBUILD.exe" /target:Rebuild /property:Configuration=RELEASE /property:Platform="Any CPU" /fl /flp:logfile=WiFiRemote.log;verbosity=diagnostic WiFiRemote.sln

: Revert version
git checkout WifiRemote\Properties\AssemblyInfo.cs

cd ..\Installer

pause
26 changes: 26 additions & 0 deletions Installer/Create_Installer.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@echo off
cls
Title Creating MediaPortal WiFiRemote Installer

ECHO Building Installer ...

if "%programfiles(x86)%XXX"=="XXX" goto 32BIT
:: 64-bit
set PROGS=%programfiles(x86)%
goto CONT
:32BIT
set PROGS=%ProgramFiles%
:CONT

IF NOT EXIST "%PROGS%\Team MediaPortal\MediaPortal\" SET PROGS=C:

:: Copy files
COPY /Y ..\Sources\WifiRemote\bin\Release\WifiRemote.dll Files\
COPY /Y ..\Sources\WifiRemote\Resources\WifiRemote.xml Files\

:: Get version from DLL
FOR /F "tokens=*" %%i IN ('Tools\sigcheck.exe /accepteula /nobanner /n "Files\WifiRemote.dll"') DO (SET version=%%i)

:: Build MPE1
"%PROGS%\Team MediaPortal\MediaPortal\MPEMaker.exe" WifiRemoteInstaller.xmp2 /B /V=%version% /UpdateXML

Binary file added Installer/Tools/sed.exe
Binary file not shown.
Binary file added Installer/Tools/sigcheck.exe
Binary file not shown.
Loading

0 comments on commit d3bab40

Please sign in to comment.