From 9cb9ed02fc5a436088ce3f26bd3bb6f3aa120c2a Mon Sep 17 00:00:00 2001 From: wutno Date: Fri, 6 Sep 2019 04:25:02 -0400 Subject: [PATCH 1/4] ci: Set-up GitHub Actions to check if a PR builds successfully --- .github/workflows/pr_verify_build.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/pr_verify_build.yml diff --git a/.github/workflows/pr_verify_build.yml b/.github/workflows/pr_verify_build.yml new file mode 100644 index 000000000..d810f4255 --- /dev/null +++ b/.github/workflows/pr_verify_build.yml @@ -0,0 +1,21 @@ +name: Verify PR Builds + +on: pull_request + +jobs: + windows: + name: Windows + runs-on: windows-latest + strategy: + matrix: + configuration: [Debug, Release] + steps: + - uses: actions/checkout@master + - name: Generate cmake files + run: | + git submodule update --init --recursive --force + mkdir build && cd build + cmake .. -G "Visual Studio 16 2019" -A Win32 + - name: Build + run: cmake --build build/ --config ${{ matrix.configuration }} + From 43a1d0182d6bdd24bedabf86fc41210d5ab8840a Mon Sep 17 00:00:00 2001 From: wutno Date: Fri, 6 Sep 2019 04:26:51 -0400 Subject: [PATCH 2/4] ci: Actions to build & artifact develop branch --- .github/workflows/master_artifact_publish.yml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/master_artifact_publish.yml diff --git a/.github/workflows/master_artifact_publish.yml b/.github/workflows/master_artifact_publish.yml new file mode 100644 index 000000000..a480de519 --- /dev/null +++ b/.github/workflows/master_artifact_publish.yml @@ -0,0 +1,34 @@ +name: Release Artifacts + +on: + push: + branches: develop + +jobs: + windows: + name: Windows + runs-on: windows-latest + strategy: + matrix: + configuration: [Release] + steps: + - uses: actions/checkout@master + - name: Generate cmake files + run: | + git submodule update --init --recursive --force + mkdir build && cd build + cmake .. -G "Visual Studio 16 2019" -A Win32 + - name: Build + run: cmake --build build/ --config ${{ matrix.configuration }} + - name: Organize artifact files + shell: bash + run: | + mkdir dist + cp {COPYING,README.md} dist/ + cd build/bin/${{ matrix.configuration }} + [ "${{ matrix.configuration }}" = "Debug" ] && sdl="SDL2d.dll" || sdl=SDL2.dll; cp {Cxbx.exe,glew32.dll,subhook.dll,$sdl} ../../../dist/ + cp {cxbxr-debugger.exe,capstone.dll,cs_x86.dll} ../../../dist/ + - uses: actions/upload-artifact@master + with: + name: CXBX-R-${{ matrix.configuration }}-${{ github.sha }} + path: dist/ From 78e51a7f0178002171f78c0d117a2e3b5a8cf24e Mon Sep 17 00:00:00 2001 From: Margen67 Date: Thu, 19 Mar 2020 00:43:18 -0700 Subject: [PATCH 3/4] ci: Improvements Make into one yml, rename to CI; if conditions and search filtering make multiple ymls unneeded. Build all branches. Ignore unrelated files. Build with VS2019 and VS2017. Set fail-fast to false. Add Debug configuration, and reorder configurations to be consistent. Don't use master version of actions. Fetch submodules with new addition to checkout action. Build in the build directory. Use -j to potentially speed up building. Use default shell/robocopy for artifact preparation. Add SDL2 to artifacts. Add artifacts for PRs. Only do artifacts for Release. Change artifact path to artifacts. (the trailing slash isn't needed) Change artifact name. Add release creation job: This creates a release with VS2019 and VS2017 builds using a CI-shortcommithash tag; For example, CI-31d4ea3 This job is only ran for commits (push) to master, not pull requests, other branches, or forks. Add badge to README --- .github/workflows/CI.yml | 115 ++++++++++++++++++ .github/workflows/master_artifact_publish.yml | 34 ------ .github/workflows/pr_verify_build.yml | 21 ---- README.md | 1 + 4 files changed, 116 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/CI.yml delete mode 100644 .github/workflows/master_artifact_publish.yml delete mode 100644 .github/workflows/pr_verify_build.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000..e744db045 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,115 @@ +name: GitHub CI + +on: + push: + paths-ignore: + - '.github/CONTRIBUTING.md' + - '.github/FUNDING.md' + - '.github/ISSUE_TEMPLATE/*' + - 'doc/*' + - 'doc/*/*' + - '.appveyor.yml' + - '.azure-pipelines.yml' + - '.travis.yml' + - 'gen-msvc-project.bat' + - 'setup.bat' + pull_request: + paths-ignore: + - '.github/CONTRIBUTING.md' + - '.github/FUNDING.md' + - '.github/ISSUE_TEMPLATE/*' + - 'doc/*' + - 'doc/*/*' + - '.appveyor.yml' + - '.azure-pipelines.yml' + - '.travis.yml' + - 'gen-msvc-project.bat' + - 'setup.bat' + +jobs: + build-windows: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + configuration: [Release, Debug] + vsver: [VS2019, VS2017] + include: + - vsver: VS2019 + os: windows-latest + - vsver: VS2017 # TODO: Remove VS2017 once WINE supports VS2019 runtimes; + os: windows-2016 # https://github.com/actions/virtual-environments/issues/68#issuecomment-602652021 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Generate cmake files + run: | + mkdir build && cd build + cmake .. -A Win32 + - name: Build + working-directory: build + run: cmake --build . --config ${{ matrix.configuration }} -j $env:NUMBER_OF_PROCESSORS + - name: Prepare artifacts + if: matrix.configuration == 'Release' + run: | + robocopy . artifacts COPYING README.md /r:0 /w:0 + robocopy build\bin\${{ matrix.configuration }} artifacts ` + Cxbx.exe glew32.dll subhook.dll SDL2.dll ` + cxbxr-debugger.exe capstone.dll cs_x86.dll /r:0 /w:0 + If ($LastExitCode -le 7) { $LastExitCode = 0 } + - uses: actions/upload-artifact@v1 + if: matrix.configuration == 'Release' + with: + name: CxbxReloaded-${{ matrix.configuration }}-${{ matrix.vsver }} + path: artifacts + + release: # TODO: Remove develop once rebased + if: github.event.action != 'pull_request' && github.ref == 'refs/heads/develop' || 'refs/heads/master' && github.repository == 'Cxbx-Reloaded/Cxbx-Reloaded' + needs: build-windows + env: + artifact-1: CxbxReloaded-Release-VS2019 + artifact-2: CxbxReloaded-Release-VS2017 + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Download artifacts (1) + uses: actions/download-artifact@v1 + with: + name: ${{ env.artifact-1 }} + - name: Download artifacts (2) + uses: actions/download-artifact@v1 + with: + name: ${{ env.artifact-2 }} + - name: Prepare artifacts for release + run: | # download-artifact doesn't download a zip, so rezip it + 7z a -mx1 $env:artifact-1.zip .\$env:artifact-1\* + 7z a -mx1 $env:artifact-2.zip .\$env:artifact-2\* + echo "::set-env name=short_commit_sha::$(git rev-parse --short HEAD)" + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: CI-${{ env.short_commit_sha }} + release_name: CI-${{ env.short_commit_sha }} + prerelease: true + - name: Upload Release Asset (1) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ env.artifact-1 }}.zip + asset_name: ${{ env.artifact-1 }}.zip + asset_content_type: application/zip + - name: Upload Release Asset (2) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ env.artifact-2 }}.zip + asset_name: ${{ env.artifact-2 }}.zip + asset_content_type: application/zip diff --git a/.github/workflows/master_artifact_publish.yml b/.github/workflows/master_artifact_publish.yml deleted file mode 100644 index a480de519..000000000 --- a/.github/workflows/master_artifact_publish.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Release Artifacts - -on: - push: - branches: develop - -jobs: - windows: - name: Windows - runs-on: windows-latest - strategy: - matrix: - configuration: [Release] - steps: - - uses: actions/checkout@master - - name: Generate cmake files - run: | - git submodule update --init --recursive --force - mkdir build && cd build - cmake .. -G "Visual Studio 16 2019" -A Win32 - - name: Build - run: cmake --build build/ --config ${{ matrix.configuration }} - - name: Organize artifact files - shell: bash - run: | - mkdir dist - cp {COPYING,README.md} dist/ - cd build/bin/${{ matrix.configuration }} - [ "${{ matrix.configuration }}" = "Debug" ] && sdl="SDL2d.dll" || sdl=SDL2.dll; cp {Cxbx.exe,glew32.dll,subhook.dll,$sdl} ../../../dist/ - cp {cxbxr-debugger.exe,capstone.dll,cs_x86.dll} ../../../dist/ - - uses: actions/upload-artifact@master - with: - name: CXBX-R-${{ matrix.configuration }}-${{ github.sha }} - path: dist/ diff --git a/.github/workflows/pr_verify_build.yml b/.github/workflows/pr_verify_build.yml deleted file mode 100644 index d810f4255..000000000 --- a/.github/workflows/pr_verify_build.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Verify PR Builds - -on: pull_request - -jobs: - windows: - name: Windows - runs-on: windows-latest - strategy: - matrix: - configuration: [Debug, Release] - steps: - - uses: actions/checkout@master - - name: Generate cmake files - run: | - git submodule update --init --recursive --force - mkdir build && cd build - cmake .. -G "Visual Studio 16 2019" -A Win32 - - name: Build - run: cmake --build build/ --config ${{ matrix.configuration }} - diff --git a/README.md b/README.md index c3437f411..7d5f9be16 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Cxbx-Reloaded - Original Xbox Emulator [![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://img.shields.io/badge/License-GPL%20v2-blue.svg) +[![GitHub Actions](https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/workflows/CI/badge.svg)](https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/actions) [![AppVeyor](https://ci.appveyor.com/api/projects/status/iao43irxl3umbp33?svg=true)](https://ci.appveyor.com/project/SoullessSentinel/cxbx-reloaded) [![Azure](https://Cxbx-Reloaded.visualstudio.com/Cxbx-Reloaded/_apis/build/status/Cxbx-Reloaded.Cxbx-Reloaded?branchName=develop)](https://Cxbx-Reloaded.visualstudio.com/Cxbx-Reloaded/_build/latest?definitionId=7&branchName=develop) [![Travis](https://travis-ci.org/Cxbx-Reloaded/Cxbx-Reloaded.svg?branch=develop)](https://travis-ci.org/Cxbx-Reloaded/Cxbx-Reloaded) From e84fa750e537542ead0436938e1b436f5c680ede Mon Sep 17 00:00:00 2001 From: Margen67 Date: Tue, 7 Apr 2020 08:01:10 -0700 Subject: [PATCH 4/4] Multi-line if --- .github/workflows/CI.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e744db045..ac7d109a9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -64,28 +64,32 @@ jobs: name: CxbxReloaded-${{ matrix.configuration }}-${{ matrix.vsver }} path: artifacts - release: # TODO: Remove develop once rebased - if: github.event.action != 'pull_request' && github.ref == 'refs/heads/develop' || 'refs/heads/master' && github.repository == 'Cxbx-Reloaded/Cxbx-Reloaded' + release: + if: | # TODO: Remove develop once rebased + github.event.action != 'pull_request' && + (github.ref == 'refs/heads/develop' || + github.ref == 'refs/heads/master') && + github.repository == 'Cxbx-Reloaded/Cxbx-Reloaded' needs: build-windows env: - artifact-1: CxbxReloaded-Release-VS2019 - artifact-2: CxbxReloaded-Release-VS2017 + artifact_1: CxbxReloaded-Release-VS2019 + artifact_2: CxbxReloaded-Release-VS2017 runs-on: windows-latest steps: - uses: actions/checkout@v2 - name: Download artifacts (1) uses: actions/download-artifact@v1 with: - name: ${{ env.artifact-1 }} + name: ${{ env.artifact_1 }} - name: Download artifacts (2) uses: actions/download-artifact@v1 with: - name: ${{ env.artifact-2 }} + name: ${{ env.artifact_2 }} - name: Prepare artifacts for release run: | # download-artifact doesn't download a zip, so rezip it - 7z a -mx1 $env:artifact-1.zip .\$env:artifact-1\* - 7z a -mx1 $env:artifact-2.zip .\$env:artifact-2\* echo "::set-env name=short_commit_sha::$(git rev-parse --short HEAD)" + 7z a -mx1 "$env:artifact_1.zip" ".\$env:artifact_1\*" + 7z a -mx1 "$env:artifact_2.zip" ".\$env:artifact_2\*" - name: Create Release id: create_release uses: actions/create-release@v1 @@ -101,8 +105,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ env.artifact-1 }}.zip - asset_name: ${{ env.artifact-1 }}.zip + asset_path: ${{ env.artifact_1 }}.zip + asset_name: ${{ env.artifact_1 }}.zip asset_content_type: application/zip - name: Upload Release Asset (2) uses: actions/upload-release-asset@v1 @@ -110,6 +114,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ env.artifact-2 }}.zip - asset_name: ${{ env.artifact-2 }}.zip + asset_path: ${{ env.artifact_2 }}.zip + asset_name: ${{ env.artifact_2 }}.zip asset_content_type: application/zip