Update main.yml #14
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: Build and Publish NuGet and Release | |
permissions: | |
contents: read | |
packages: write | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '7.0' | |
- name: Restore client dependencies | |
run: dotnet restore | |
working-directory: ./RDSServiceClient | |
- name: Build client | |
run: dotnet build --configuration Release --no-restore | |
working-directory: ./RDSServiceClient | |
- name: Pack client | |
run: dotnet pack --configuration Release --no-build --output ../nupkgs/RDSServiceClient | |
working-directory: ./RDSServiceClient | |
- name: Push client to GitHub Packages | |
run: dotnet nuget push "*.nupkg" --source "https://nuget.pkg.github.com/kyle079/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate | |
working-directory: ./nupkgs/RDSServiceClient | |
- name: Restore library dependencies | |
run: dotnet restore | |
working-directory: ./RDSServiceLibrary | |
- name: Build library | |
run: dotnet build --configuration Release | |
working-directory: ./RDSServiceLibrary | |
- name: Pack library | |
run: dotnet pack --configuration Release --no-build --output ../nupkgs/RDSServiceLibrary | |
working-directory: ./RDSServiceLibrary | |
- name: Push library to GitHub Packages | |
run: dotnet nuget push "*.nupkg" --source "https://nuget.pkg.github.com/kyle079/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate | |
working-directory: ./nupkgs/RDSServiceLibrary | |
- name: Restore service dependencies | |
run: dotnet restore | |
working-directory: ./RDSService | |
- name: Build service | |
run: dotnet build --configuration Release --no-restore | |
working-directory: ./RDSService | |
- name: Pack service | |
run: dotnet publish --configuration Release --no-build --output ../release | |
working-directory: ./RDSService | |
- name: Zip service | |
run: Compress-Archive -Path ./release/* -DestinationPath ./RDSService.zip | |
working-directory: ./ | |
- name: Extract service Version | |
id: get_version | |
shell: pwsh | |
run: | | |
$version = dotnet msbuild -target:PrintVersion | Out-String | |
$version = $version.Trim() # Trimming to ensure clean output | |
$version = $version -replace 'Version: ', '' # Extracting just the version number | |
echo "version=$version" >> $Env:GITHUB_OUTPUT | |
working-directory: ./RDSService | |
- name: Create service Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.version }} | |
release_name: Release ${{ steps.get_version.outputs.version }} | |
draft: false | |
prerelease: false | |
- name: Upload service Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./RDSService.zip | |
asset_name: RDSService.zip | |
asset_content_type: application/zip | |