Merge pull request #6 from xztaityozx/upgrade/dotnet-sdk-7.0.x #15
Workflow file for this run
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: .NET Core CI/CD | |
on: [push] | |
jobs: | |
test: | |
name: Unit test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
dotnet-version: [7.0.x] | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
NUGET_XMLDOC_MODE: skip | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v1 | |
with: | |
path: ${{ github.workspace }}/.nuget/packages | |
key: nuget-${{ matrix.os }}-${{ matrix.dotnet-version }} | |
restore-keys: | | |
nuget-${{ matrix.os }}- | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: ${{ matrix.dotnet-version }} | |
- name: Test | |
working-directory: ./noc/Test | |
run: dotnet test --verbosity normal -c Debug | |
dotnet-publish: | |
if: contains(github.ref, 'tags/v') | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macOS-latest] | |
dotnet-version: [7.0.x] | |
runs-on: ${{ matrix.os }} | |
env: | |
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
NUGET_XMLDOC_MODE: skip | |
steps: | |
- name: vars | |
id: vars | |
shell: bash | |
run: | | |
echo ::set-output name=version::${TAG_REF_NAME##*/v} | |
echo ::set-output name=runtime_id::"$(echo ${{ matrix.os }} | sed 's/windows/win/;s/ubuntu/linux/;s/macOS/osx/;s/latest/x64/')" | |
env: | |
TAG_REF_NAME: ${{ github.ref }} | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v2 | |
with: | |
path: ${{ github.workspace }}/.nuget/packages | |
key: nuget-${{ matrix.os }}-${{ matrix.dotnet-version }} | |
restore-keys: | | |
nuget-${{ matrix.os }}- | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: ${{ matrix.dotnet-version }} | |
- name: dotnet publish | |
working-directory: ./noc/noc | |
run: | | |
dotnet publish -c Release -r ${{ steps.vars.outputs.runtime_id }} --self-contained true -p:Version=${{ steps.vars.outputs.version }} -o ${{ steps.vars.outputs.runtime_id }} | |
- name: Upload build result | |
uses: actions/upload-artifact@v1 | |
with: | |
name: ${{ steps.vars.outputs.runtime_id }} | |
path: noc/noc/${{ steps.vars.outputs.runtime_id }} | |
create-releases: | |
name: Create GitHub Release | |
if: contains(github.ref, 'tags/v') | |
needs: [test, dotnet-publish] | |
runs-on: ubuntu-latest | |
steps: | |
- name: vars | |
id: vars | |
shell: bash | |
run: | | |
echo ::set-output name=version::${TAG_REF_NAME##*/} | |
env: | |
TAG_REF_NAME: ${{ github.ref }} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1.0.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.vars.outputs.version }} | |
release_name: Release ${{ steps.vars.outputs.version }} | |
draft: false | |
prerelease: false | |
- name: Output Release URL File | |
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt | |
- name: Save Release URL File for publish | |
uses: actions/upload-artifact@v1 | |
with: | |
name: release_url | |
path: release_url.txt | |
upload-release: | |
name: Upload artifacts to GitHub Release | |
if: contains(github.ref, 'tags/v') | |
strategy: | |
matrix: | |
runtime_id: [win-x64, linux-x64, osx-x64] | |
runs-on: ubuntu-latest | |
needs: [dotnet-publish, create-releases, test] | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: ${{ matrix.runtime_id }} | |
path: ${{ matrix.runtime_id }} | |
- uses: actions/download-artifact@v2 | |
with: | |
name: release_url | |
- name: Get Release Info | |
id: get_release_info | |
shell: bash | |
run: | | |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v} | |
echo ::set-output name=upload_url::"$(cat release_url.txt)" | |
echo ::set-output name=version::${TAG_REF_NAME##*/v} | |
env: | |
TAG_REF_NAME: ${{ github.ref }} | |
REPOSITORY_NAME: ${{ github.repository }} | |
- name: zip | |
run: | | |
zip -r ${{ matrix.runtime_id }} ${{ matrix.runtime_id }} | |
- name: Upload assets to GitHub Release | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1.0.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.get_release_info.outputs.upload_url }} | |
asset_path: ./${{ matrix.runtime_id }}.zip | |
asset_name: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.runtime_id }}.zip | |
asset_content_type: application/zip |