Skip to content

Improve workflow system for EP further (#4891) #631

Improve workflow system for EP further (#4891)

Improve workflow system for EP further (#4891) #631

Workflow file for this run

# references:
# https://trstringer.com/github-actions-multiline-strings/
# https://trstringer.com/github-actions-create-release-upload-artifacts/
# https://github.com/Speedy37/sws/blob/444c67157a98652c4e7ffd3b6d6bbfb664071926/.github/workflows/msbuild.yml
# https://stackoverflow.com/questions/58886293/getting-current-branch-and-commit-hash-in-github-action
name: Build
on:
push:
pull_request:
workflow_dispatch:
inputs:
ref:
description: 'Commit'
required: true
config:
description: 'Configuration'
required: false
build_dir:
description: 'Build dir'
required: false
env:
SOLUTION_FILE_PATH: .
BUILD_CONFIGURATION: Release
permissions:
contents: write
jobs:
build:
runs-on: windows-2025
timeout-minutes: 30
steps:
- name: Print inputs
shell: bash
run: |
echo "ref: ${GITHUB_EVENT_INPUTS_REF}"
echo "config: ${GITHUB_EVENT_INPUTS_CONFIG}"
echo "build_dir: ${GITHUB_EVENT_INPUTS_BUILD_DIR}"
env:
GITHUB_EVENT_INPUTS_REF: ${{ github.event.inputs.ref }}
GITHUB_EVENT_INPUTS_CONFIG: ${{ github.event.inputs.config }}
GITHUB_EVENT_INPUTS_BUILD_DIR: ${{ github.event.inputs.build_dir }}
- name: Checkout latest build and submodules
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
if: github.event.inputs.ref == ''
with:
submodules: recursive
persist-credentials: false
- name: Checkout specific build and submodules
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
if: github.event.inputs.ref != ''
with:
ref: ${{ github.event.inputs.ref }}
submodules: recursive
persist-credentials: false
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # 2.0.0
- name: Declare some variables
id: vars
shell: bash
run: |
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Enable SimpleWindowSwitcher support for newer Windows SDKs
shell: cmd
run: |
cd libs/sws
C:\msys64\usr\bin\wget.exe https://github.com/valinet/sws/commit/972acb76d1e6429133c92ed7cdefd29b9a2c6179.patch
C:\msys64\usr\bin\dos2unix.exe 972acb76d1e6429133c92ed7cdefd29b9a2c6179.patch
C:\msys64\usr\bin\dos2unix.exe SimpleWindowSwitcher/sws_def.h
C:\msys64\usr\bin\patch.exe -N SimpleWindowSwitcher/sws_def.h 972acb76d1e6429133c92ed7cdefd29b9a2c6179.patch
C:\msys64\usr\bin\unix2dos.exe SimpleWindowSwitcher/sws_def.h
exit /b 0
- name: Setup NuGet
uses: nuget/setup-nuget@323ab0502cd38fdc493335025a96c8fdb0edc71f # 2.0.1
with:
nuget-version: '7.x'
- name: Restore NuGet packages
run: |
nuget restore ExplorerPatcher.sln
- name: Build dependencies
shell: cmd
run: |
BuildDependencies%BUILD_CONFIGURATION%.bat
- name: Download ep_taskbar
uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # 1.12
with:
repository: ExplorerPatcher/ep_taskbar_releases
fileName: ep_taskbar.*.dll
latest: true
out-file-path: build/Release
# build/Release/ep_taskbar.*.amd64.dll -> build/Release/x64/ep_taskbar.*.dll
# build/Release/ep_taskbar.*.arm64.dll -> build/Release/ARM64/ep_taskbar.*.dll
- name: Move ep_taskbar
shell: bash
run: |
if ls build/Release/ep_taskbar.*.amd64.dll 1> /dev/null 2>&1; then
mkdir -p build/Release/x64
for file in build/Release/ep_taskbar.*.amd64.dll; do
mv "$file" "build/Release/x64/$(basename "$file" .amd64.dll).dll"
done
fi
if ls build/Release/ep_taskbar.*.arm64.dll 1> /dev/null 2>&1; then
mkdir -p build/Release/ARM64
for file in build/Release/ep_taskbar.*.arm64.dll; do
mv "$file" "build/Release/ARM64/$(basename "$file" .arm64.dll).dll"
done
fi
- name: Build ExplorerPatcher (IA-32)
if: github.event.inputs.config == ''
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=IA-32 ${{env.SOLUTION_FILE_PATH}}
- name: Build ExplorerPatcher (amd64)
if: github.event.inputs.config == ''
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=amd64 ${{env.SOLUTION_FILE_PATH}}
- name: Build ExplorerPatcher (arm64)
if: github.event.inputs.config == ''
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=arm64 /p:WithArm64XBinaries=true ${{env.SOLUTION_FILE_PATH}}
- name: Build ExplorerPatcher (Custom Build)
if: github.event.inputs.config != ''
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=$env:GITHUB_EVENT_INPUTS_CONFIG ${{env.SOLUTION_FILE_PATH}}
env:
GITHUB_EVENT_INPUTS_CONFIG: ${{ github.event.inputs.config }}
- name: Create expected build directory
if: github.event.inputs.build_dir != ''
shell: bash
run: |
mkdir build
cp -r ${GITHUB_EVENT_INPUTS_BUILD_DIR}/Release build/Release
env:
GITHUB_EVENT_INPUTS_BUILD_DIR: ${{ github.event.inputs.build_dir }}
- name: Generate dxgi.dll
shell: bash
run: |
if [[ -f "build/Release/x64/ExplorerPatcher.amd64.dll" ]]; then cp build/Release/x64/ExplorerPatcher.amd64.dll build/Release/x64/dxgi.dll; fi
if [[ -f "build/Release/ARM64/ExplorerPatcher.arm64.dll" ]]; then cp build/Release/ARM64/ExplorerPatcher.arm64.dll build/Release/ARM64/dxgi.dll; fi
- name: Patch amd64 setup
shell: cmd
run: |
if exist "build\Release\x64\ExplorerPatcher.amd64.dll" (
"build\Release\x64\ep_setup_patch.exe" "build\Release\x64\ExplorerPatcher.amd64.dll" "build\Release\x64\ep_setup.exe"
)
exit /b 0
- name: Patch arm64 setup
shell: cmd
run: |
if exist "build\Release\ARM64\ExplorerPatcher.arm64.dll" (
"build\Release\x64\ep_setup_patch.exe" "build\Release\ARM64\ExplorerPatcher.arm64.dll" "build\Release\ARM64\ep_setup.exe"
)
exit /b 0
- name: Delete intermediate files
shell: bash
run: |
rm -rf build/Release/x64/ep_setup_files
rm -f build/Release/x64/ep_setup_files.zip.bin
rm -rf build/Release/ARM64/ep_setup_files
rm -f build/Release/ARM64/ep_setup_files.zip.bin
- name: Upload artifacts
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: ep_bin_multi_${{ steps.vars.outputs.sha_short }}_${{ steps.vars.outputs.branch }}
path: |
build/Release/
if-no-files-found: error
# build/Release/x64/ep_setup.exe -> build/Release/ep_setup.exe
# build/Release/ARM64/ep_setup.exe -> build/Release/ep_setup_arm64.exe
- name: Stage files for release
if: github.ref == 'refs/heads/master' && github.event.inputs.ref == ''
shell: bash
run: |
if [ -d "build/Release/x64" ] && ls build/Release/x64/ep_setup.exe 1> /dev/null 2>&1; then
cp build/Release/x64/ep_setup.exe build/Release/ep_setup.exe
fi
if [ -d "build/Release/ARM64" ] && ls build/Release/ARM64/ep_setup.exe 1> /dev/null 2>&1; then
cp build/Release/ARM64/ep_setup.exe build/Release/ep_setup_arm64.exe
fi
- name: Generate release name
shell: bash
working-directory: build/Release/x64
if: github.ref == 'refs/heads/master' && github.event.inputs.ref == ''
run: |
echo "data=$(./ep_generate_release_name.exe)" >> $GITHUB_OUTPUT
id: release_name
- name: Generate release notes
shell: bash
working-directory: build/Release/x64
if: github.ref == 'refs/heads/master' && github.event.inputs.ref == ''
run: |
echo "data<<EP_RELEASE_DESCRIPTION_DELIM" >> $GITHUB_OUTPUT
echo "$(./ep_generate_release_description.exe ${STEPS_VARS_OUTPUTS_SHA_SHORT} ${STEPS_VARS_OUTPUTS_BRANCH} ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_OUTPUT
echo "EP_RELEASE_DESCRIPTION_DELIM" >> $GITHUB_OUTPUT
id: release_description
env:
STEPS_VARS_OUTPUTS_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
STEPS_VARS_OUTPUTS_BRANCH: ${{ steps.vars.outputs.branch }}
- name: Create/update release (valinet)
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # 2.5.0
if: github.repository_owner == 'valinet' && github.ref == 'refs/heads/master' && github.event.inputs.ref == ''
id: create_release
with:
draft: false
prerelease: ${{ !startsWith(github.event.head_commit.message, 'rel_') }}
name: ${{ steps.release_name.outputs.data }}
tag_name: ${{ steps.release_name.outputs.data }}_${{ steps.vars.outputs.sha_short }}
body: ${{ steps.release_description.outputs.data }}
files: |
build/Release/ep_setup.exe
build/Release/ep_setup_arm64.exe
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Create/update release (forks)
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # 2.5.0
if: github.repository_owner != 'valinet' && github.ref == 'refs/heads/master' && github.event.inputs.ref == ''
id: create_release_fork
with:
draft: false
prerelease: ${{ !startsWith(github.event.head_commit.message, 'rel_') }}
name: ${{ steps.release_name.outputs.data }}
tag_name: ${{ steps.release_name.outputs.data }}_${{ steps.vars.outputs.sha_short }}
body: ${{ steps.release_description.outputs.data }}
files: |
build/Release/ep_setup.exe
build/Release/ep_setup_arm64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}