-
-
Notifications
You must be signed in to change notification settings - Fork 103
Migrate CI from AppVeyor to GitHub Actions #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3aa1f4a
Migrate CI from AppVeyor to GitHub Actions
nefarius 9db6ecb
Fix build workflow: restore SDK-style projects, gate vcpkg cache on PAT
nefarius 003867a
Fix workflow validation error: secrets not usable in if: conditions
nefarius 908150f
Fix build workflow security hardening and NU1012 packing failure
nefarius 174a836
Fix x86 driver link failure on GitHub Actions by pinning MSBuild Plat…
nefarius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| name: 'Build' | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| tags: | ||
| - 'v*' | ||
| paths-ignore: | ||
| - '**/*.md' | ||
| - '**/*.aip' | ||
| - '.vscode/**' | ||
| - '**/*.json' | ||
| - 'setup/**' | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: build-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.ref_type != 'tag' }} | ||
|
|
||
| env: | ||
| # Offset chosen to stay well above the last AppVeyor build counter (3.3.1251.0) at time of migration. | ||
| BUILD_VERSION_OFFSET: 2000 | ||
| DOTNET_CLI_TELEMETRY_OPTOUT: 'true' | ||
| DOTNET_NOLOGO: 'true' | ||
| SCPLIB_ENABLE_TELEMETRY: 'false' | ||
| # Disabled by default; enabled per-job below only when the VCPKG_NUGET_TOKEN secret is present. | ||
| # GITHUB_TOKEN cannot push new packages under a personal-account GitHub Packages namespace, so a | ||
| # PAT with read:packages/write:packages is required. See: | ||
| # https://github.com/microsoft/vcpkg/issues/47470 | ||
| VCPKG_BINARY_SOURCES: 'clear' | ||
|
|
||
| jobs: | ||
| build: | ||
| name: 'Platform: ${{ matrix.platform }}' | ||
| runs-on: windows-2022 | ||
| permissions: | ||
| contents: read | ||
| env: | ||
| # Secrets can't be referenced directly in `if:` conditions, only in `env:`/`with:`, | ||
| # so promote it here and check env.VCPKG_NUGET_TOKEN in the step below instead. | ||
| VCPKG_NUGET_TOKEN: ${{ secrets.VCPKG_NUGET_TOKEN }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| platform: [x64, ARM64, x86] | ||
| outputs: | ||
| build-version: ${{ steps.version.outputs.build-version }} | ||
| steps: | ||
| - name: 'Checkout' | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| lfs: true | ||
| persist-credentials: false | ||
|
|
||
| - name: 'Compute build version' | ||
| id: version | ||
| shell: pwsh | ||
| run: | | ||
| $buildVersion = "3.3.$([int]$env:BUILD_VERSION_OFFSET + ${{ github.run_number }}).0" | ||
| echo "BUILD_VERSION=$buildVersion" >> $env:GITHUB_ENV | ||
| echo "build-version=$buildVersion" >> $env:GITHUB_OUTPUT | ||
| Write-Output "Building version $buildVersion" | ||
|
|
||
| - name: 'Bootstrap vcpkg' | ||
| shell: cmd | ||
| run: .\XInputBridge\vcpkg\bootstrap-vcpkg.bat -disableMetrics | ||
|
|
||
| - name: 'Configure vcpkg NuGet binary cache' | ||
| if: ${{ env.VCPKG_NUGET_TOKEN != '' }} | ||
| shell: pwsh | ||
| run: | | ||
| $nugetExe = & .\XInputBridge\vcpkg\vcpkg.exe fetch nuget | Select-Object -Last 1 | ||
| & $nugetExe sources add ` | ||
| -Source "https://nuget.pkg.github.com/nefarius/index.json" ` | ||
| -StorePasswordInClearText ` | ||
| -Name "GitHubPackages" ` | ||
| -UserName "nefarius" ` | ||
| -Password "$env:VCPKG_NUGET_TOKEN" | ||
| & $nugetExe setapikey "$env:VCPKG_NUGET_TOKEN" ` | ||
| -Source "https://nuget.pkg.github.com/nefarius/index.json" | ||
| echo "VCPKG_BINARY_SOURCES=clear;nuget,https://nuget.pkg.github.com/nefarius/index.json,readwrite" >> $env:GITHUB_ENV | ||
|
|
||
| - name: 'Cache NuGet packages' | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.nuget/packages | ||
| key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'nuget.config') }} | ||
| restore-keys: | | ||
| nuget-${{ runner.os }}- | ||
|
|
||
| - name: 'Install vpatch' | ||
| run: dotnet tool install --global Nefarius.Tools.Vpatch | ||
|
|
||
| - name: 'Stamp version into driver and XInputBridge' | ||
| shell: cmd | ||
| run: | | ||
| vpatch --stamp-version "%BUILD_VERSION%" --target-file ".\driver\dshidmini.vcxproj" --vcxproj.inf-time-stamp | ||
| vpatch --stamp-version "%BUILD_VERSION%" --target-file ".\driver\dshidmini.rc" --resource.file-version --resource.product-version | ||
| vpatch --stamp-version "%BUILD_VERSION%" --target-file ".\XInputBridge\XInputBridge.rc" --resource.file-version --resource.product-version | ||
|
|
||
| - name: 'Restore managed projects' | ||
| # msbuild's /t:Rebuild over the whole solution does not implicitly restore SDK-style | ||
| # projects; these two dotnet restore calls also transitively restore the SDK project | ||
| # referenced by both. Mirrors appveyor.yml's former before_build steps. | ||
| shell: cmd | ||
| run: | | ||
| dotnet restore .\ControlApp\ | ||
| dotnet restore .\ipctest\ | ||
|
|
||
| - name: 'Build' | ||
| shell: cmd | ||
| run: .\build.cmd --target-platform ${{ matrix.platform }} | ||
|
|
||
| - name: 'Publish ControlApp' | ||
| if: matrix.platform == 'x64' | ||
| shell: cmd | ||
| run: .\build.cmd PublishControlApp --skip Compile | ||
|
|
||
| - name: 'Pack driver CAB' | ||
| if: matrix.platform != 'x86' | ||
| shell: cmd | ||
| run: makecab.exe /f .\DsHidMini_${{ matrix.platform }}.ddf | ||
|
|
||
| - name: 'Upload artifacts' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: dshidmini-${{ matrix.platform }} | ||
| if-no-files-found: error | ||
| path: | | ||
| disk1/*.cab | ||
| bin/**/dshidmini/*.inf | ||
| bin/**/dshidmini/*.cat | ||
| bin/**/dshidmini/*.dll | ||
| bin/**/*.pdb | ||
| bin/**/*.dll | ||
| bin/*.exe | ||
|
|
||
| release: | ||
| name: 'Draft release' | ||
| needs: build | ||
| if: github.ref_type == 'tag' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: 'Download artifacts' | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: artifacts | ||
| pattern: dshidmini-* | ||
|
|
||
| - name: 'Create draft release' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| REF_NAME: ${{ github.ref_name }} | ||
| run: | | ||
| gh release create "$REF_NAME" \ | ||
| --repo "${{ github.repository }}" \ | ||
| --title "$REF_NAME (build ${{ needs.build.outputs.build-version }})" \ | ||
| --draft \ | ||
| --generate-notes \ | ||
| artifacts/dshidmini-x64/disk1/*.cab \ | ||
| artifacts/dshidmini-ARM64/disk1/*.cab \ | ||
| artifacts/dshidmini-x64/bin/*.exe | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.