Tag [v0.1.0] -> Create Package #1
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: Tag -> Create Package | |
run-name: Tag [${{ github.ref_name }}] -> Create Package | |
on: | |
push: | |
tags: v** | |
env: | |
PROJECT_FILE_PATH: TJC.StringExtensions/TJC.StringExtensions.csproj | |
PROJECT_DIR_PATH: TJC.StringExtensions | |
jobs: | |
package: | |
name: Create Package [${{ github.ref_name }}] | |
runs-on: windows-2022 | |
permissions: write-all | |
steps: | |
- name: Checkout [${{ github.ref_name }}] | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.TJC_TOKEN || secrets.GITHUB_TOKEN }} | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Add GitHub NuGet Source | |
run: dotnet nuget add source --username "${{ github.repository_owner }}" --password ${{ secrets.TJC_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | |
- name: Setup .NET 8.0 | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.*' | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@v2 | |
- name: Setup NuGet | |
uses: NuGet/[email protected] | |
- name: Restore NuGet | |
run: nuget restore ${{ env.PROJECT_FILE_PATH }} | |
- name: Get Version without Prefix/Suffix | |
id: getVer | |
uses: actions/[email protected] | |
with: | |
result-encoding: string | |
script: | | |
var tag = '${{ github.ref_name }}' | |
var simple = tag.replace('v','') | |
simple = simple.split('-')[0] | |
console.log('Version:', simple) | |
return simple | |
- name: Build DLL | |
run: msbuild ${{ env.PROJECT_FILE_PATH }} /p:Configuration=Release | |
- name: Pack NuGet Package [${{ steps.getVer.outputs.result }}] | |
run: dotnet pack ${{ env.PROJECT_FILE_PATH }} -p:Version='${{ steps.getVer.outputs.result }}' -c Release | |
- name: List | |
run: ls ${{ env.PROJECT_DIR_PATH }}/bin/Release | |
- name: Push Package to NuGet & GitHub Packages | |
shell: powershell | |
run: | | |
$files = gci -File "${{ env.PROJECT_DIR_PATH }}/bin/Release/*.nupkg" | |
foreach ($file in $files) | |
{ | |
echo "Pushing NuGet Package: $file" | |
dotnet nuget push "$file" --api-key ${{ secrets.TJC_NUGET_PUBLISH }} --source https://api.nuget.org/v3/index.json | |
dotnet nuget push "$file" --api-key ${{ secrets.TJC_TOKEN }} --source github | |
} | |
- name: ${{ format('Published NuGet Package [{0}]', steps.getVer.outputs.result) }} | |
if: success() | |
uses: ./.github/actions/tools/annotation/notice | |
with: | |
message: ${{ format('Published NuGet Package [{0}]', steps.getVer.outputs.result) }} | |
- name: Error - Failed to Publish NuGet Package | |
if: failure() | |
uses: ./.github/actions/tools/annotation/error | |
with: | |
message: '[Error] Failed to Publish NuGet Package' |