This file contains hidden or 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: Auto Version + Publish | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - 'v*' | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Needed to read tags | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| # ----------------------------- | |
| # 🔢 Calculate next version | |
| # ----------------------------- | |
| - name: Determine version | |
| id: version | |
| run: | | |
| # Get latest tag, ignore errors | |
| TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| if [ -z "$TAG" ]; then | |
| echo "No existing tags, starting at 0.0.1" | |
| VERSION="0.0.1" | |
| else | |
| TAG=${TAG#v} # Remove leading 'v' | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$TAG" | |
| PATCH=$((PATCH + 1)) | |
| VERSION="$MAJOR.$MINOR.$PATCH" | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Using version: $VERSION" | |
| # ----------------------------- | |
| # 🛠️ Build + Pack | |
| # ----------------------------- | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build -c Release --no-restore | |
| - name: Pack | |
| run: dotnet pack ./WorkflowyNetAPI/WorkflowyNetAPI.csproj -c Release --no-build -p:PackageVersion=${{ steps.version.outputs.VERSION }} -o ./output | |
| # ----------------------------- | |
| # 🔵 Publish to NuGet.org | |
| # ----------------------------- | |
| - name: Publish to NuGet.org | |
| run: | | |
| dotnet nuget push "./output/*.nupkg" \ | |
| --source "https://api.nuget.org/v3/index.json" \ | |
| --api-key ${{ secrets.NUGET_API_KEY }} \ | |
| --skip-duplicate |