Skip to content

Update build-and-publish.yml (#468) #310

Update build-and-publish.yml (#468)

Update build-and-publish.yml (#468) #310

name: Build and Release
on:
push:
tags:
- 'v*'
env:
DOTNET_VERSION: 8.0.x
jobs:
build:
runs-on: windows-latest
outputs:
version: ${{ steps.set-version-to-output.outputs.version }}
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- name: Install MAUI
run: dotnet workload install maui
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
- name: Update version number
shell: pwsh
run: |
$doc = [XML](Get-Content 'Source\Directory.Build.props')
$doc.Project.PropertyGroup.Version = '${{github.ref}}'.Split('/')[2].Substring(1)
$doc.Save('Source\Directory.Build.props')
- name: Set version to outputs
id: set-version-to-output
shell: pwsh
run: |
$doc = [XML](Get-Content 'Source\Directory.Build.props')
echo "version=$($doc.Project.PropertyGroup.Version)" >> $GITHUB_OUTPUT
- name: Install dependencies
run: dotnet restore ReactiveProperty.sln
- name: Build
run: dotnet build ReactiveProperty.sln -c Release --no-restore /p:ContinuousIntegrationBuild=True /p:EmbedUntrackedSources=True
- name: Test
run: dotnet test ReactiveProperty.sln --no-restore --verbosity normal
- name: Copy package files
run: |
mkdir dist
Copy-Item (Get-ChildItem -Path "Source/**/*.nupkg" -Recurse) -Destination dist
Copy-Item (Get-ChildItem -Path "Source/**/*.snupkg" -Recurse) -Destination dist
shell: pwsh
- name: Archive NuGet packages
uses: actions/upload-artifact@v1
with:
name: dist
path: dist
release-to-nuget:
runs-on: windows-latest
needs: build
steps:
- name: Download archives
uses: actions/download-artifact@v2
with:
name: dist
- name: Publish packages
run: dotnet nuget push **/*.nupkg --skip-duplicate -k ${{ secrets.NUGET_APIKEY }} -s https://api.nuget.org/v3/index.json
create-release:
runs-on: windows-latest
needs: build
steps:
- name: Download archives
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ needs.build.outputs.version }}
prerelease: ${{ contains(needs.build.outputs.version, '-pre') }}
title: Release ${{ needs.build.outputs.version }}
files: |
dist/*.nupkg