try to use invoking .net runtime instead of looking it up from path (… #665
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: Emulator CI/CD | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
# 0.0.0 | |
type: string | |
changelog: | |
type: string | |
push: | |
branches: | |
- main | |
- releases/* | |
# paths-ignore: | |
# - '**.md' | |
pull_request: | |
run-name: ${{ github.event_name == 'workflow_dispatch' && (inputs.version && format('Publish version:{0} sha:{1}', inputs.version, github.sha) || format('Emulator CI/CD sha:{0}', github.sha)) || '' }} | |
jobs: | |
build: | |
strategy: | |
matrix: | |
runtime: | |
- linux-x64 | |
- linux-arm | |
- linux-arm64 | |
- alpine-x64 | |
- alpine-arm | |
- alpine-arm64 | |
- win-x86 | |
- win-x64 | |
- win-arm64 | |
- osx-x64 | |
- osx-arm64 | |
fxdependent: [ true, false ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- run: dotnet msbuild src/dir.proj -t:GenerateConstant -p:RunnerVersion=${{ inputs.version || '3.0.0' }} -p:PackageRuntime=${{ !matrix.fxdependent && matrix.runtime || 'Any' }} | |
- run: dotnet publish src/Runner.Client ${{ matrix.fxdependent && '--no-self-contained -p:RuntimeFrameworkVersion=6.0.0' || '--sc' }} -c Release -p:BUILD_OS=${{ matrix.fxdependent && 'Any' || startsWith(matrix.runtime, 'win-') && 'Windows' || startsWith(matrix.runtime, 'osx-') && 'OSX' || 'Linux' }} -r ${{ matrix.runtime }} -p:Version=${{ inputs.version || '3.0.0' }} -o output | |
- name: Package tar | |
if: ${{ !startsWith(matrix.runtime, 'win-') }} | |
run: | | |
tar czf ../runner.server-${{matrix.runtime}}${{ matrix.fxdependent && '-fxdependent' || '' }}.tar.gz ./* | |
working-directory: output | |
- name: Package zip | |
if: ${{ startsWith(matrix.runtime, 'win-') }} | |
run: | | |
zip -r ../runner.server-${{matrix.runtime}}${{ matrix.fxdependent && '-fxdependent' || '' }}.zip ./* | |
working-directory: output | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: runner.server-${{matrix.runtime}}${{ matrix.fxdependent && '-fxdependent' || '' }} | |
path: 'runner.server-${{matrix.runtime}}*' | |
publish-to-github: | |
if: inputs.version | |
runs-on: ubuntu-latest | |
needs: build | |
continue-on-error: true | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
path: "artifacts" | |
- uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "artifacts/**/*.zip,artifacts/**/*.tar.gz" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: v${{ inputs.version }} | |
commit: ${{ github.sha }} | |
body: | | |
# Changes | |
${{ fromjson(inputs.changelog) }} | |
publish: | |
if: inputs.version | |
needs: publish-to-github | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '6.0.x' | |
- name: GenerateConstant | |
run: dotnet msbuild ./dir.proj -t:GenerateConstant -p:RunnerVersion=${{ inputs.version }} -p:PackageRuntime=any | |
shell: pwsh | |
working-directory: ./src | |
- name: Restore | |
run: dotnet restore -p:RuntimeFrameworkVersion=6.0.0 | |
shell: pwsh | |
working-directory: ./src/Runner.Client | |
- name: Build | |
run: dotnet build --no-restore -c Release -p:BUILD_OS=Any -p:Version=${{ inputs.version }} -p:RuntimeFrameworkVersion=6.0.0 | |
shell: pwsh | |
working-directory: ./src/Runner.Client | |
- name: Pack | |
run: | | |
dotnet pack --no-restore -c Release --no-build -p:Version=${{ inputs.version }} -p:RuntimeFrameworkVersion=6.0.0 -p:CHANGELOG_URL=https://github.com/ChristopherHX/runner.server/releases/tag/v${{ inputs.version }} | |
shell: pwsh | |
working-directory: ./src/Runner.Client | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: nupkg | |
path: src/Runner.Client/nupkg | |
- name: Push to Nuget | |
if: env.GHARUN != '' | |
run: dotnet nuget push ./*.nupkg --api-key $($ENV:GHARUN) --source https://api.nuget.org/v3/index.json | |
shell: pwsh | |
working-directory: ./src/Runner.Client/nupkg | |
env: | |
GHARUN: ${{secrets.GHARUN}} |