Merge pull request #52 from purview-dev:activities-state #206
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: publish | |
on: | |
workflow_dispatch: # Allow running the workflow manually from the GitHub UI | |
push: | |
branches: | |
- 'main' # Run the workflow when pushing to the main branch | |
pull_request: | |
branches: | |
- '*' # Run the workflow for all pull requests | |
release: | |
types: | |
- published # Run the workflow when a new GitHub release is published | |
env: | |
POWERSHELL_TELEMETRY_OPTOUT: 1 | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_NOLOGO: true | |
SolutionPath: ./Purview.Telemetry.SourceGenerator.sln | |
BuildConfigutation: Release | |
NuGetDirectory: ${{ github.workspace }}/nuget | |
defaults: | |
run: | |
shell: pwsh | |
working-directory: src | |
jobs: | |
create_nuget: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer | |
- uses: actions/setup-dotnet@v4 | |
name: Setup .NET | |
with: | |
global-json-file: ./src/global.json | |
- uses: dotnet/nbgv@master | |
id: nbgv | |
- run: echo 'SimpleVersion=${{ steps.nbgv.outputs.SimpleVersion }}' | |
- name: Pack NuGet packages | |
run: dotnet pack ${{ env.SolutionPath }} --configuration ${{ env.BuildConfigutation }} --output ${{ env.NuGetDirectory }} --property:Version=${{ steps.nbgv.outputs.SimpleVersion }} --include-symbols | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: nuget | |
if-no-files-found: error | |
retention-days: 7 | |
path: ${{ env.NuGetDirectory }}/*.nupkg | |
run_test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: ./src/global.json | |
- name: Run tests | |
run: dotnet test ${{ env.SolutionPath }} --configuration ${{ env.BuildConfigutation }} --logger "trx;LogFileName=test-results.trx" --results-directory ./test-results | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: .NET Tests | |
path: ./src/test-results/*.trx | |
reporter: dotnet-trx | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results | |
path: ./src/test-results | |
deploy: | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
needs: [ run_test ] | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: nuget | |
path: ${{ env.NuGetDirectory }} | |
- name: Upload release | |
uses: fnkr/github-action-ghr@v1 | |
env: | |
GHR_COMPRESS: xz | |
GHR_PATH: ${{ env.NuGetDirectory }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Setup .NET | |
# uses: actions/setup-dotnet@v4 | |
# with: | |
# global-json-file: ./src/global.json | |
# source-url: https://api.nuget.org/v3/index.json | |
# env: | |
# NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
# run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg |