Skip to content

documentation: replace redirect to package with the specific download… #33

documentation: replace redirect to package with the specific download…

documentation: replace redirect to package with the specific download… #33

Workflow file for this run

name: "Library"
on:
push:
branches:
- "main"
paths:
- "source/**"
- "test/**"
- ".editorconfig"
- "*.props"
- "global.json"
- "nuget.config"
- "*.sln"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
paths:
- "source/**"
- "test/**"
- ".editorconfig"
- "*.props"
- "global.json"
- "nuget.config"
- "*.sln"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
RELEASE_NAME: "${{ github.ref_name }}"
NUGET_OUTPUT_DIRECTORY: "artifacts/package/release"
jobs:
builder:
name: "Builder"
runs-on: "${{ vars.DEFAULT_UBUNTU }}"
env:
IS_PUSH_EVENT_TO_MAIN_BRANCH: "${{ github.event_name == 'push' && contains(github.ref, 'refs/heads/main') }}"
IS_PULL_REQUEST_EVENT: "${{ github.event_name == 'pull_request' }}"
IS_RELEASE: "${{ startsWith(github.ref, 'refs/tags/v') && github.actor == github.repository_owner }}"
BUILD_CONFIGURATION: "Release"
steps:
- name: "Set up repository with the latest commit"
if: "${{ github.event_name == 'push' }}"
uses: "actions/checkout@v4.1.1"
- name: "Set up repository with all history"
if: "${{ env.IS_PULL_REQUEST_EVENT == vars.POSITIVE }}"
uses: "actions/checkout@v4.1.1"
with:
fetch-depth: 0
- name: "Set up .NET SDK"
uses: "actions/setup-dotnet@v4.0.0"
- name: "Restore dependencies"
run: "dotnet restore"
- name: "Get all changed files"
id: "all-changed-files"
if: "${{ env.IS_PULL_REQUEST_EVENT == vars.POSITIVE }}"
uses: "tj-actions/changed-files@v40.2.1"
with:
files: "**.cs"
- name: "Run formatter"
if: "${{ env.IS_PULL_REQUEST_EVENT == vars.POSITIVE && steps.all-changed-files.outputs.any_changed == vars.POSITIVE }}"
run: |
dotnet format \
--include ${{ steps.all-changed-files.outputs.all_changed_files }} \
--no-restore \
--verify-no-changes
- name: "Build assemblies"
run: |
dotnet build \
--no-restore \
--configuration '${{ env.BUILD_CONFIGURATION }}'
- name: "Run tests"
run: |
dotnet test \
--no-build \
--configuration '${{ env.BUILD_CONFIGURATION }}' \
-property:'CollectCoverage=${{ env.IS_PUSH_EVENT_TO_MAIN_BRANCH }}'
- name: "Upload coverage results"
if: "${{ env.IS_PUSH_EVENT_TO_MAIN_BRANCH == vars.POSITIVE }}"
uses: "codecov/codecov-action@v3.1.4"
with:
directory: "artifacts/coverage"
file: "*.xml"
fail_ci_if_error: true
token: "${{ secrets.CODECOV_TOKEN }}"
- name: "Build package"
if: "${{ env.IS_RELEASE == vars.POSITIVE }}"
run: |
dotnet pack \
--no-build \
--configuration '${{ env.BUILD_CONFIGURATION }}' \
-property:"PackageVersion=${GITHUB_REF_NAME#v}" \
-property:'PackageReleaseNotes=See ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }} .'
- name: "Upload release artifacts"
uses: "actions/upload-artifact@v3.1.3"
if: "${{ env.IS_RELEASE == vars.POSITIVE }}"
with:
name: "${{ env.RELEASE_NAME }}"
path: |
${{ env.NUGET_OUTPUT_DIRECTORY }}
global.json
nuget.config
publisher:
name: "Publisher"
needs: "builder"
if: "${{ startsWith(github.ref, 'refs/tags/v') && github.actor == github.repository_owner }}"
runs-on: "${{ vars.DEFAULT_UBUNTU }}"
env:
NUGET_SEARCH_PATTERN: "*.nupkg"
steps:
- name: "Download release artifacts"
uses: "actions/download-artifact@v3.0.2"
with:
name: "${{ env.RELEASE_NAME }}"
- name: "Set up .NET SDK"
uses: "actions/setup-dotnet@v4.0.0"
- name: "Publish package"
run: |
dotnet nuget push '${{ env.NUGET_OUTPUT_DIRECTORY }}/${{ env.NUGET_SEARCH_PATTERN }}' \
--source 'nuget' \
--api-key '${{ secrets.NUGET_TOKEN }}' \
--skip-duplicate
dotnet nuget push '${{ env.NUGET_OUTPUT_DIRECTORY }}/${{ env.NUGET_SEARCH_PATTERN }}' \
--source 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' \
--api-key '${{ secrets.GITHUB_TOKEN }}' \
--skip-duplicate
- name: "Publish release"
uses: "softprops/action-gh-release@v0.1.15"
with:
generate_release_notes: true
files: "${{ env.NUGET_OUTPUT_DIRECTORY }}/*"