Skip to content

Commit

Permalink
Config proj
Browse files Browse the repository at this point in the history
  • Loading branch information
arslanaybars committed Jan 25, 2025
1 parent a98c7cd commit f4db8f7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 47 deletions.
76 changes: 30 additions & 46 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,38 @@
name: Auto-version and Publish
name: Publish to NuGet

on:
push:
branches:
- main
tags:
- 'v*'

jobs:
version-and-publish:
build:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Update Version and Create Tag
run: |
CSPROJ_FILE="$(find . -name "*.csproj" | head -n 1)"
CURRENT_VERSION=$(grep -oP '(?<=<Version>)[^<]+' "$CSPROJ_FILE")
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$((VERSION_PARTS[2] + 1))"
sed -i "s|<Version>$CURRENT_VERSION</Version>|<Version>$NEW_VERSION</Version>|" "$CSPROJ_FILE"
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add "$CSPROJ_FILE"
git commit -m "bump version to $NEW_VERSION"
git tag "v$NEW_VERSION"
git push && git push --tags
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Build and Test
run: |
dotnet restore
dotnet build --configuration Release
dotnet test --no-restore
- name: Pack
run: dotnet pack --configuration Release --no-build --output nupkgs

- name: Push to NuGet
run: |
cd nupkgs
for f in *.nupkg
do
dotnet nuget push $f --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate
done
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --no-restore --verbosity normal

- name: Pack
run: dotnet pack --configuration Release --no-build --output nupkgs

- name: Push to NuGet
run: |
cd nupkgs
for f in *.nupkg
do
dotnet nuget push $f --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate
done
2 changes: 1 addition & 1 deletion src/EtherScan.Dotnet.Client/EtherScan.Dotnet.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<!-- Package Info -->
<PackageId>etherscan.dotnet.client</PackageId>
<Version>1.0.2</Version>
<Version>1.0.4</Version>
<Authors>Aybars</Authors>
<Company>AybSoft</Company>
<Product>Etherscan .NET Client</Product>
Expand Down

0 comments on commit f4db8f7

Please sign in to comment.