Update to .NET 9.0 Core #5
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
name: .NET Core Desktop Release | |
env: | |
NUGET_SERVER_URL: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | |
GH_TOKEN: ${{ secrets.LATENCY_PAT }} | |
on: | |
push: | |
tags: 'v[0-9]+.[0-9]+.[0-9]+' | |
workflow_dispatch: | |
jobs: | |
pre_job: | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/[email protected] | |
with: | |
skip_after_successful_duplicate: 'true' | |
release: | |
needs: pre_job | |
if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | |
runs-on: ${{ matrix.os }} | |
permissions: | |
packages: write | |
contents: write # write permission is required to create a github release | |
pull-requests: write # write permission is required for autolabeler otherwise, read permission is required at least | |
strategy: | |
matrix: | |
os: [self-hosted] #, ubuntu-latest, windows-latest] | |
BuildConfiguration: [ Release ] | |
max-parallel: 2 | |
steps: | |
- name: Get PROJECT_NAME | |
id: project-name | |
shell: bash | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
split=(${GITHUB_REPOSITORY//\// }) | |
elif [ "$RUNNER_OS" == "Windows" ]; then | |
split=(${GITHUB_REPOSITORY////// }) | |
else | |
echo "$RUNNER_OS not supported" | |
exit 1 | |
fi | |
index=$((${#split[@]}-1)) | |
project_tag=${split[$index]} | |
echo "$project_tag" | |
echo "PROJECT_NAME=$project_tag" >> $GITHUB_ENV | |
- name: Get README.md Description & PACKAGE_VERSION | |
id: readme-desc | |
shell: bash | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
filenames=$(ls ${{ github.workspace }}) | |
elif [ "$RUNNER_OS" == "Windows" ]; then | |
filenames=$(ls ${GITHUB_WORKSPACE//\//\\ }) | |
else | |
echo "$RUNNER_OS not supported" | |
exit 1 | |
fi | |
for filename in ${filenames[@]}; do | |
if [ -f $filename -a "$filename" = "README.md" ]; then | |
desc=$(sed -n '2{P;q;}' $filename | sed 's/\n$//' | sed 's/\r$//' | cut -c 5- ) | |
echo "$desc" | |
echo "README_DESC=$desc" >> $GITHUB_ENV | |
regex='\| VERSION:.*-([0-9]+(\.[0-9]+){2,})[-a-z]*' | |
if [[ $(grep VERSION: $filename) =~ $regex ]]; then | |
package_version=${BASH_REMATCH[1]} | |
echo "$package_version" | |
echo "PACKAGE_VERSION=$package_version" >> $GITHUB_ENV | |
fi | |
break | |
fi | |
done | |
- name: Query Release (if exists) | |
shell: bash | |
run: | | |
version=v${{ env.PACKAGE_VERSION }} | |
cd src | |
array=$(gh release list -O asc | cut -f3) | |
cd .. | |
echo "FIRST_RELEASE=$(echo $array | awk '{print $1}')" >> $GITHUB_ENV | |
if [[ ${array[@]} =~ $version ]]; then | |
echo "Release '$version' was found." | |
echo "RELEASE_FOUND=true" >> $GITHUB_ENV | |
else | |
echo "No release exists with version '$version'." | |
echo "RELEASE_FOUND=false" >> $GITHUB_ENV | |
fi | |
- name: Delete Release | |
if: ${{ env.release_found == 'true' }} | |
shell: bash | |
run: | | |
echo "Deleting current release '$version'" | |
gh release delete $version --cleanup-tag | |
env: | |
release_found: '${{ env.RELEASE_FOUND }}' | |
version: 'v${{ env.PACKAGE_VERSION }}' | |
- name: Create Release | |
shell: bash | |
run: | | |
draft=false | |
prerelease=false | |
body="${{ env.README_DESC }} | |
${{ steps.github_release.outputs.changelog }}" | |
if [ "$draft" = "true" ]; then | |
d='-d ' | |
fi | |
if [ "$prerelease" = "true" ]; then | |
p='-p ' | |
fi | |
echo "gh release create \"v${{ env.PACKAGE_VERSION }}\" ${p}${d}--generate-notes --notes-start-tag \"${{ env.FIRST_RELEASE }}\" --title \"${{ env.PROJECT_NAME }}\" -n \"$body\"" | |
gh release create "v${{ env.PACKAGE_VERSION }}" ${p}${d}--generate-notes --notes-start-tag "${{ env.FIRST_RELEASE }}" --title "${{ env.PROJECT_NAME }}" -n "$body" | |
- name: Check If NuGet Package Exists | |
id: locate-package | |
shell: bash | |
run: | | |
echo "nuget-exists=false" >> $GITHUB_OUTPUT | |
array=$(nuget search "${{ env.PROJECT_NAME }}" -Source "github" | grep "No results found.\|^>") | |
if [ "$array" != "No results found." ]; then | |
ary=($(echo "$array" | grep '^> ' | cut -c 3- | awk '{print $1} {print $3}')) | |
name=${ary[0]} | |
version=${ary[1]} | |
if [ "$name" = "${{ env.PROJECT_NAME }}" -a "$version" = "${{ env.PACKAGE_VERSION }}" ]; then | |
echo "Package '${{ env.PROJECT_NAME }}.${{ env.PACKAGE_VERSION }}.nupkg' was found to exist." | |
echo "nuget-exists=true" >> $GITHUB_OUTPUT | |
fi | |
fi | |
- name: Remove Existing NuGet Package | |
if: ${{ steps.locate-package.outputs.nuget-exists == 'true' }} | |
#run: dotnet nuget delete ${{ env.PROJECT_NAME }} ${{ env.PACKAGE_VERSION }} --api-key ${{ secrets.NUGET_AUTH_TOKEN }} --non-interactive | |
uses: actions/[email protected] | |
with: | |
owner: ${{ github.repository_owner }} | |
package-name: ${{ env.PROJECT_NAME }} | |
package-type: 'nuget' | |
token: ${{ secrets.NUGET_AUTH_TOKEN }} | |
- name: Push package to GitHub packages | |
run: | | |
dotnet nuget push "D:\Source\Packages\${{ env.PROJECT_NAME }}.${{ env.PACKAGE_VERSION }}.nupkg" -n --skip-duplicate -k ${{ secrets.NUGET_AUTH_TOKEN }} |