Bump softprops/action-gh-release from 2.3.2 to 2.3.3 #6
Workflow file for this run
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: Publish NuGet Package | |
| on: | |
| pull_request: | |
| types: [closed] | |
| jobs: | |
| versioning: | |
| name: Fetch and increment version | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new_version: ${{ steps.set_version.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| ################################################# | |
| # Fetch latest NuGet package version from GitHub Packages | |
| ################################################# | |
| - name: Fetch latest NuGet version from GitHub Packages | |
| id: latest_nuget_version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| OWNER: ${{ github.repository_owner }} | |
| NUGET_PACKAGE: "DotnetViewComponents" | |
| run: | | |
| echo "Fetching latest NuGet version for package '$NUGET_PACKAGE' in owner '$OWNER'" | |
| API_URL="https://api.github.com/users/$OWNER/packages/nuget/$NUGET_PACKAGE/versions" | |
| ### fetch GitHub Packages | |
| VERSIONS_JSON=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| "$API_URL") | |
| ### extract latest nuget pkg version | |
| LATEST_VERSION=$(echo "$VERSIONS_JSON" | jq -r '.[0].name // "0.0.0"') | |
| echo "Latest NuGet package version found: $LATEST_VERSION" | |
| echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| - name: Echo latest NuGet version | |
| run: echo "Current version:${{ steps.latest_nuget_version.outputs.version }}" | |
| ################################################# | |
| # Decide increment type: patch, minor, major | |
| ################################################# | |
| - name: Set increment type based on branch and labels | |
| id: increment_type | |
| run: | | |
| BRANCH_REF="${{ github.head_ref }}" | |
| MERGE_MESSAGE="${{ github.event.pull_request.title }} ${{ github.event.pull_request.body }}" | |
| LABELS="${{ join(github.event.pull_request.labels.*.name, ',') }}" | |
| TYPE="patch" | |
| echo "Branch: $BRANCH_REF" | |
| echo "Merge message: $MERGE_MESSAGE" | |
| echo "Labels: $LABELS" | |
| if [[ "$BRANCH_REF" == major/* ]] || [[ "$LABELS" == *"Major"* ]] || [[ "$MERGE_MESSAGE" =~ (?i)MAJOR[[:space:]]CHANGE ]] || [[ "$MERGE_MESSAGE" =~ (?i)BREAKING[[:space:]]CHANGE ]]; then | |
| TYPE="major" | |
| elif [[ "$BRANCH_REF" == feature/* ]]; then | |
| TYPE="minor" | |
| elif [[ "$BRANCH_REF" == fix/* ]]; then | |
| TYPE="patch" | |
| fi | |
| # Major version bump triggered by new major tag is skipped here | |
| # because version baseline is fetched from Packages. | |
| echo "Will increment: $TYPE" | |
| echo "TYPE=$TYPE" >> $GITHUB_OUTPUT | |
| ################################################# | |
| # Increment semantic version | |
| ################################################# | |
| - name: Increment package version | |
| id: bump_version | |
| uses: christian-draeger/[email protected] | |
| with: | |
| current-version: ${{ steps.latest_nuget_version.outputs.version }} | |
| version-fragment: ${{ steps.increment_type.outputs.TYPE }} | |
| - name: Echo new version | |
| run: echo "Next version:${{ steps.bump_version.outputs.next-version }}" | |
| ################################################# | |
| # Set new version as job output for downstream jobs | |
| ################################################# | |
| - name: Set version output for job | |
| id: set_version | |
| run: echo "version=${{ steps.bump_version.outputs.next-version }}" >> $GITHUB_OUTPUT | |
| nuget_publish: | |
| name: Build, Pack, and Publish NuGet Package | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| needs: versioning | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| BUILD_CONFIG: "Release" | |
| PROJECT_PATH: "DotnetViewComponents/DotnetViewComponents.csproj" | |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: '8.0.x' # Specify your target .NET version | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/[email protected] | |
| with: | |
| versionSpec: '6.3.0' | |
| - name: Determine Version | |
| id: gitversion | |
| uses: gittools/actions/gitversion/[email protected] | |
| - name: Display versioning outputs | |
| run: | | |
| echo "NuGet Version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}" | |
| echo "SemVer: ${{ steps.gitversion.outputs.semVer }}" | |
| echo "Outputs: ${{ toJson(steps.gitversion.outputs) }}" | |
| - name: Use version in another step | |
| run: | | |
| VERSION="${{ steps.gitversion.outputs.major }}.${{ steps.gitversion.outputs.minor }}.${{ steps.gitversion.outputs.patch }}" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Set version env | |
| run: | | |
| echo "Using version from versioning job: ${{ needs.versioning.outputs.new_version }}" | |
| echo "NEXT_VERSION=${{ needs.versioning.outputs.new_version }}" >> $GITHUB_ENV | |
| - name: Restore NuGet packages | |
| run: dotnet restore $PROJECT_PATH | |
| - name: Build project | |
| run: dotnet build $PROJECT_PATH --configuration $BUILD_CONFIG --no-restore | |
| - name: Pack NuGet package | |
| run: dotnet pack $PROJECT_PATH --configuration $BUILD_CONFIG --no-build -o out /p:PackageVersion=$NEXT_VERSION | |
| - name: Add GitHub NuGet source | |
| run: dotnet nuget add source --username ${{ github.actor }} --password $GITHUB_TOKEN --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | |
| - name: Publish NuGet package to GitHub Packages | |
| run: dotnet nuget push out/*.nupkg --api-key $GITHUB_TOKEN --source "github" --skip-duplicate | |
| ################################################# | |
| # Publish release | |
| ################################################# | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/[email protected] | |
| with: | |
| tag_name: v${{ needs.versioning.outputs.new_version }} | |
| release_name: Release v${{ needs.versioning.outputs.new_version }} | |
| files: ./package/*.nupkg | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |