C# Compiler #91
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
name: Compiler | |
on: | |
push: | |
branches: [master] | |
paths: | |
- "src/**" | |
- "compiled/**" | |
- "utils/Compiler.ps1" | |
- ".github/workflows/compiler.yaml" | |
pull_request: | |
paths: ["src/**", "compiled/**", "utils/Compiler.ps1"] | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
outputs: | |
compiled: ${{ steps.changes.outputs.compiled }} | |
src: ${{ steps.changes.outputs.src }} | |
src_deleted: ${{ steps.changes.outputs.src_deleted }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Checks for changes in the 'compiled' and 'src' directories | |
# We include 'utils/Compiler.ps1' in the 'src' directory incase it is modified | |
# As this can affect all scripts in the src directory. | |
# We also check for deleted files so we can cleanup the compiled directory | |
- name: Collect Changes for Upcoming Jobs | |
uses: dorny/[email protected] | |
id: changes | |
with: | |
list-files: shell | |
filters: | | |
compiled: | |
- 'compiled/**' | |
src: | |
- 'src/**' | |
- 'utils/Compiler.ps1' | |
src_deleted: | |
- deleted: 'src/**' | |
cleanup-directory: | |
runs-on: ubuntu-latest | |
needs: changes | |
if: needs.changes.outputs.src_deleted == 'true' | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Delete Compiled versions of deleted files | |
id: delete_files | |
run: | | |
for file in $(find compiled -type f); do | |
no_prefix=${file#compiled/} | |
if [ ! -f "src/${no_prefix}" ]; then | |
echo ::set-output name=found_deleted::true | |
echo "Found deleted src file ${no_prefix}, deleting compiled version." | |
rm $file | |
fi | |
done | |
- name: Commit Changes | |
if: ${{ steps.delete_files.outputs.found_deleted == 'true' && github.event_name == 'push' }} | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "chore(compiled): Remove compiled versions of deleted files" | |
compile-scripts: | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.src == 'true' }} | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Compile Scripts | |
shell: pwsh | |
run: ./utils/Invoke-CompileAllScripts.ps1 -Debug -Verbose | |
- name: Commit Changes | |
if: ${{ needs.changes.outputs.src == 'true' && github.event_name == 'push' }} | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "chore(compiled): Compile scripts" |