feat: updating to new release management system #193
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
# 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 | |
- 'testing-semantic-release' | |
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 | |
jobs: | |
create_nuget: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 0 # Get all history to allow automatic versioning using MinVer | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: ./src/global.json | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' # Specify your Node.js version here | |
# - uses: dotnet/nbgv@master | |
# id: nbgv | |
# - run: echo 'SimpleVersion=${{ steps.nbgv.outputs.SimpleVersion }}' | |
- name: Copy package meta info to root | |
run: cp .node/package* . | |
- name: npm install | |
run: npm install --no-progress --prefer-offline --no-audit | |
# - name: Install semantic-release | |
# run: npm install -g semantic-release @semantic-release/exec | |
- name: Get release version | |
id: get_version | |
run: echo "RELEASE_VERSION=$(npx --no-install semantic-release --branches testing-semantic-release --dry-run | grep -oP '(?:The next release version is )([0-9]+\.[0-9]+\.[0-9]+)' | grep -oP '[0-9]+\.[0-9]+\.[0-9]+')" >> $GITHUB_ENV | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get release version | |
id: get_version2 | |
run: npx --no-install semantic-release --branches testing-semantic-release --dry-run | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Display release version | |
run: echo "Release version is ${{ env.RELEASE_VERSION }}" | |
- name: Pack NuGet packages | |
run: dotnet pack ${{ env.SolutionPath }} --configuration ${{ env.BuildConfigutation }} --output ${{ env.NuGetDirectory }} --property:Version=${{ env.RELEASE_VERSION }} --include-symbols | |
working-directory: src | |
- name: Upload NuGet packages | |
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: | |
- name: Checkout code | |
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 | |
working-directory: src | |
- 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: | |
- name: Download package | |
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 |