Remove obsolete API methods #27
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: Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
new_package_version: | ||
description: 'New package version' | ||
required: true | ||
should_push_nuget: | ||
description: 'Push to NuGet' | ||
default: 'true' | ||
required: false | ||
should_push_github: | ||
description: 'Push to GitHub package registry' | ||
default: 'true' | ||
required: false | ||
should_commit_new_version: | ||
description: 'Commit and push version increment' | ||
default: 'true' | ||
required: false | ||
should_tag_new_version: | ||
description: 'Tag version release' | ||
default: 'true' | ||
required: false | ||
should_create_github_release: | ||
description: 'Create GitHub Release' | ||
default: 'true' | ||
required: false | ||
jobs: | ||
release: | ||
if: github.actor == 'eduherminio' | ||
runs-on: ubuntu-latest | ||
env: | ||
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | ||
ARTIFACT_DIR: ./artifacts | ||
PROJECT_NAME: AoCHelper | ||
- name: Install hub tool | ||
if: github.event.inputs.should_create_github_release == 'true' | ||
run: | | ||
sudo apt-get update && sudo apt-get install -y hub | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Configure git user | ||
run: | | ||
git config --global user.name 'GitHub Actions' | ||
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
- name: Inject slug/short variables | ||
uses: rlespinasse/[email protected] | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 8.0.x | ||
- name: Set version to ${{ github.event.inputs.new_package_version }} | ||
shell: pwsh | ||
run: | | ||
$input_path = "src/${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj" | ||
$regex = "(?<=<Version>).*(?=</Version>)" | ||
(Get-Content $input_path) -Replace $regex, '${{ github.event.inputs.new_package_version }}' | Out-File $input_path | ||
- name: Build | ||
run: dotnet build -c Release /p:DeterministicBuild=true | ||
- name: Run tests | ||
run: dotnet test -c Release --no-build --collect:"XPlat Code Coverage" | ||
- name: 'Generate test coverage report' | ||
continue-on-error: true | ||
uses: danielpalme/ReportGenerator-GitHub-Action@5 | ||
with: | ||
reports: 'tests/**/*.cobertura.xml' | ||
targetdir: 'coveragereport' | ||
reporttypes: 'HtmlInline_AzurePipelines_Dark' | ||
assemblyfilters: '+*' | ||
classfilters: '+*;-*Exception' | ||
filefilters: '+*' | ||
verbosity: 'Info' | ||
title: '${{ env.PROJECT_NAME }} #${{ github.run_number }} (${{ env.GITHUB_REF_SLUG }})' | ||
tag: '${{ github.run_number }}_${{ github.run_id }}' | ||
customSettings: 'numberOfReportsParsedInParallel=3;numberOfReportsMergedInParallel=3' | ||
- name: 'Upload test coverage report' | ||
continue-on-error: true | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.PROJECT_NAME }}.${{ github.event.inputs.new_package_version }}-coverage-${{ env.GITHUB_REF_SLUG }}-${{ github.run_number }} | ||
path: coveragereport/ | ||
if-no-files-found: error | ||
- name: Pack | ||
run: | | ||
dotnet pack -c Release --no-build src/${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj --include-symbols -o ${{ env.ARTIFACT_DIR }} | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.PROJECT_NAME }}.${{ github.event.inputs.new_package_version }}-${{ env.GITHUB_REF_SLUG }}-${{ github.run_number }} | ||
path: | | ||
${{ env.ARTIFACT_DIR }}/*.nupkg | ||
${{ env.ARTIFACT_DIR }}/*.snupkg | ||
if-no-files-found: error | ||
- name: Push to NuGet | ||
if: github.event.inputs.should_push_nuget == 'true' | ||
run: | | ||
nuget push '${{ env.ARTIFACT_DIR }}/*.nupkg' -ApiKey ${{ secrets.NuGetKey }} -Source https://api.nuget.org/v3/index.json -SkipDuplicate -Verbosity detailed | ||
- name: Push to GitHub packages registry | ||
if: github.event.inputs.should_push_github == 'true' | ||
run: | | ||
nuget push '${{ env.ARTIFACT_DIR }}/*.nupkg' -ApiKey ${{ secrets.GitHubToken }} -Source https://nuget.pkg.github.com/eduherminio/index.json -SkipDuplicate -Verbosity detailed | ||
- name: Commit and push version increment | ||
if: github.event.inputs.should_commit_new_version == 'true' | ||
continue-on-error: true | ||
run: | | ||
git switch ${{ env.GITHUB_REF_SLUG }} | ||
git status | ||
git commit -am "🚀 Release v${{ github.event.inputs.new_package_version }}" | ||
git push | ||
- name: Create git tag | ||
if: github.event.inputs.should_tag_new_version == 'true' | ||
run: | | ||
git switch ${{ env.GITHUB_REF_SLUG }} | ||
git status | ||
git tag -a v${{ github.event.inputs.new_package_version }} -m "v${{ github.event.inputs.new_package_version }}" | ||
git push --tags | ||
- name: Create GitHub release and upload assets | ||
if: github.event.inputs.should_create_github_release == 'true' && github.event.inputs.should_tag_new_version == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GitHubToken }} | ||
run: | | ||
set -x | ||
assets=() | ||
for asset in ${{ env.ARTIFACT_DIR }}/*; do | ||
assets+=("-a" "$asset") | ||
done | ||
tag_name="v${{ github.event.inputs.new_package_version }}" | ||
hub release create "${assets[@]}" --message "$tag_name" "$tag_name" |