Merge pull request #141 from CardanoSharp/Fixed-the-workflow-file-to-… #77
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: publish to nuget | |
on: | |
push: | |
branches: | |
- main # Default release branch | |
jobs: | |
publish: | |
name: build, pack & publish | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 7.x | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore | |
- name: Test | |
run: dotnet test --no-build --verbosity normal | |
- name: Package | |
run: dotnet pack -c Release -o . CardanoSharp.Wallet/CardanoSharp.Wallet.csproj | |
- name: Publish to Nuget | |
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate | |
- name: Extract NuGet Package Version | |
id: extract-version | |
run: | | |
NUPKG_FILE=$(find . -type f -name '*.nupkg' | head -n 1) | |
VERSION=$(echo $NUPKG_FILE | sed -n 's/.*\.\([0-9]*\.[0-9]*\.[0-9]*\)\.nupkg/\1/p') | |
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Create GitHub Tag | |
run: | | |
TAG_NAME=${{ env.PACKAGE_VERSION }} | |
if ! git rev-parse $TAG_NAME >/dev/null 2>&1; then | |
git tag $TAG_NAME | |
git push origin $TAG_NAME | |
fi |