Skip to content

Commit

Permalink
Update Release.yml workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Latency committed Sep 18, 2024
1 parent 0ba5dd3 commit 4d31e02
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 243 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest, self-hosted]
os: [self-hosted]

steps:

Expand Down Expand Up @@ -45,7 +45,13 @@ jobs:
branch_name=${split[$index]}
echo "$branch_name"
echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
- name: Print Workflow Dispatch Inputs and Env Vars
uses: shayki5/print-workflow-dispatch-inputs@v1
with:
print_env_vars: 'true' # Set to 'true' to print environment variables
add_to_summary: 'true' # Set to 'true' to add inputs to GitHub Summary

- name: Get Build Artifacts
if: false
shell: bash
Expand Down
327 changes: 170 additions & 157 deletions .github/workflows/release.yml
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 }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AssemblyLoader
### Assembly Information & Loader via Reflection
Assembly Information & Loader via Reflection


---
Expand All @@ -16,7 +16,7 @@
</tr>
<tr>
<td>UPDATED:</td>
<td>9/16/2024</td>
<td>9/17/2024</td>
</tr>
<tr>
<td>FRAMEWORK:</td>
Expand Down Expand Up @@ -44,7 +44,7 @@
</tr>
<tr>
<td>STATUS:</td>
<td><a href="https://github.com/Latency/AssemblyLoader/actions/workflows/dotnet.yml"><img src="https://github.com/Latency/AssemblyLoader/actions/workflows/dotnet.yml/badge.svg"></a></td>
<td><a href="https://github.com/Latency/AssemblyLoader/actions/workflows/dotnet.yml"><img src="https://github.com/Latency/AssemblyLoader/actions/workflows/dotnet.yml/badge.svg"></a></td>
</tr>
<tr>
<td>LICENSE:</td>
Expand Down
Loading

0 comments on commit 4d31e02

Please sign in to comment.