.NET Build #36
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 Build | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- './src/**' | |
pull_request: | |
branches: [ main ] | |
paths: | |
- './src/**' | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: "true" | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "true" | |
DOTNET_NOLOGO: "true" | |
jobs: | |
build: | |
strategy: | |
matrix: | |
application: [ Aggregator, Metering.SharedResourceBroker ] | |
outputs: | |
tagVersion: ${{ steps.nbgv.outputs.SemVer2 }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: '8.0' | |
- name: Setup Semantic version | |
id: nbgv | |
uses: dotnet/[email protected] | |
with: | |
setAllVars: true | |
- name: Restore dependencies | |
working-directory: ./src | |
run: dotnet restore | |
- name: Build and Test (on Linux), then build a Windows release | |
working-directory: ./src | |
run: | | |
dotnet build --no-restore | |
dotnet test --no-build --verbosity normal | |
- name: Build and Publish ${{ matrix.application }} for Windows ZIP deployment | |
working-directory: ./src | |
run: | | |
cd ${{ matrix.application }} | |
dotnet publish \ | |
-r win-x64 \ | |
--self-contained true \ | |
--configuration Release \ | |
--output publishFolder | |
cd publishFolder | |
zip -r ../zip-deploy-${{ matrix.application }}-win-x64.zip * | |
- name: Upload ${{ matrix.application }} build artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
path: src/${{ matrix.application }}/zip-deploy-${{ matrix.application }}-win-x64.zip | |
name: ${{ matrix.application }}.${{env.NBGV_SemVer2}} | |
release: | |
name: Release Build | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v3 | |
- name: Display structure of downloaded files | |
run: | | |
find . -type f | |
echo '${{ toJSON(job) }}' | |
echo '${{ toJSON(steps) }}' | |
- name: Archive build | |
id: build_archive | |
run: | | |
archive_path=Aggregator.${{needs.build.outputs.tagVersion}}/zip-deploy-Aggregator-win-x64.zip | |
echo "zip_agg=$archive_path" >> $GITHUB_OUTPUT | |
archive_path=Metering.SharedResourceBroker.${{needs.build.outputs.tagVersion}}/zip-deploy-Metering.SharedResourceBroker-win-x64.zip | |
echo "zip_srb=$archive_path" >> $GITHUB_OUTPUT | |
echo "Created the file $GITHUB_OUTPUT with the following content: " | |
cat $GITHUB_OUTPUT | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: Release-${{needs.build.outputs.tagVersion}} | |
tag_name: ${{needs.build.outputs.tagVersion}} | |
fail_on_unmatched_files: true | |
generate_release_notes: true | |
files: | | |
${{ steps.build_archive.outputs.zip_agg }} | |
${{ steps.build_archive.outputs.zip_srb }} |