Manual Workflow - Publish Package #38
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: Manual Workflow - Publish Package | |
on: workflow_dispatch | |
jobs: | |
publish_nuget_package: | |
name: Publish | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get version | |
run: | | |
tag_name=$(grep '<Version>' < ./ComtradeHandler.Core/ComtradeHandler.Core.csproj | sed 's/.*<Version>\(.*\)<\/Version>/\1/') | |
echo "TAG_NAME=$tag_name" >> "$GITHUB_ENV" | |
echo "echo_TAG_NAME = $tag_name" | |
id: version | |
- name: Create Tag | |
uses: rickstaa/[email protected] | |
with: | |
tag: v${{ env.TAG_NAME }} | |
- name: Setup .NET Core SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Build dotnet Project | |
run: | | |
dotnet build ./ComtradeHandler.Core -c Release | |
- name: Pack dotnet Project | |
run: | | |
dotnet pack ./ComtradeHandler.Core -c Release --no-build | |
- name: Publish Package to Nuget | |
env: | |
NUGET_API_KEY: ${{secrets.NUGET_API_KEY}} | |
run: | | |
dotnet nuget push ./ComtradeHandler.Core/**/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json | |
- name: Publish Package to Github | |
run: | | |
dotnet nuget add source --username gabrieldelaparra --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/gabrieldelaparra/index.json" | |
dotnet nuget push ./ComtradeHandler.Core/**/*.nupkg --source "github" | |
- name: Publish artifact for Release | |
shell: bash | |
run: | | |
tag=v$TAG_NAME | |
echo "echo_TAG = $tag" | |
release_name="ComtradeHandler-$tag" | |
echo "echo_RELEASE_NAME = $release_name" | |
echo "RELEASE_NAME=$release_name" >> "$GITHUB_ENV" | |
artifact_name=${release_name}.zip | |
echo "echo_Artifact_Name = $artifact_name" | |
echo "ARTIFACT_NAME=$artifact_name" >> "$GITHUB_ENV" | |
dotnet publish ./ComtradeHandler.Core/ComtradeHandler.Core.csproj -c Release -o "$release_name" | |
7z a -tzip "$artifact_name" "./$release_name/*" | |
- name: Upload artifact to Github Release | |
uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: "v${{ env.TAG_NAME }}" | |
prerelease: false | |
files: ${{ env.ARTIFACT_NAME }} |