-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
184 additions
and
243 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,157 +1,170 @@ | ||
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/skip-duplicate-actions@v5.3.1 | ||
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="(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?" | ||
if [[ $(grep '<!-- VERSION:' $filename) =~ $regex ]]; then | ||
package_version=${BASH_REMATCH[0]} | ||
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/delete-package-versions@v5.0.0 | ||
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 }} | ||
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/skip-duplicate-actions@v5.3.1 | ||
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 BRANCH_NAME | ||
id: branch-name | ||
shell: bash | ||
run: | | ||
if [ "$RUNNER_OS" == "Linux" ]; then | ||
split=(${GITHUB_REF_NAME//\// }) | ||
elif [ "$RUNNER_OS" == "Windows" ]; then | ||
split=(${GITHUB_REF_NAME////// }) | ||
else | ||
echo "$RUNNER_OS not supported" | ||
exit 1 | ||
fi | ||
index=$((${#split[@]}-1)) | ||
branch_name=${split[$index]} | ||
echo "$branch_name" | ||
echo "BRANCH_NAME=$branch_name" >> $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$//' ) | ||
echo "$desc" | ||
echo "README_DESC=$desc" >> $GITHUB_ENV | ||
regex="(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?" | ||
if [[ $(grep '<!-- VERSION:' $filename) =~ $regex ]]; then | ||
package_version=${BASH_REMATCH[0]} | ||
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 'v${{ env.PACKAGE_VERSION }}'" | ||
gh release delete "v${{ env.PACKAGE_VERSION }}" --cleanup-tag | ||
- name: Create Release | ||
shell: bash | ||
run: | | ||
draft=false | ||
prerelease=false | ||
body="${{ env.README_DESC }}" | ||
if [ "$draft" = "true" ]; then | ||
d='-d ' | ||
fi | ||
if [ "$prerelease" = "true" ]; then | ||
p='-p ' | ||
fi | ||
echo "gh release create \"v${{ env.PACKAGE_VERSION }}\" --target ${{ env.BRANCH_NAME }} ${p}${d}--generate-notes --title \"${{ env.PROJECT_NAME }}\" -n \"$body\"" | ||
gh release create "v${{ env.PACKAGE_VERSION }}" --target ${{ env.BRANCH_NAME }} ${p}${d}--generate-notes --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/delete-package-versions@v5.0.0 | ||
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 }} |
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
Oops, something went wrong.