ci: chain NuGet publish directly after release job #10
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: Create Release | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [master] | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get latest tag | |
| id: latest_tag | |
| run: | | |
| tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| - name: Determine bump type from PR labels | |
| id: bump | |
| run: | | |
| labels='${{ toJson(github.event.pull_request.labels.*.name) }}' | |
| if echo "$labels" | grep -q '"major"'; then | |
| echo "type=major" >> "$GITHUB_OUTPUT" | |
| elif echo "$labels" | grep -q '"patch"'; then | |
| echo "type=patch" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "type=minor" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Calculate new version | |
| id: version | |
| run: | | |
| current="${{ steps.latest_tag.outputs.tag }}" | |
| current="${current#v}" | |
| IFS='.' read -r major minor patch <<< "$current" | |
| case "${{ steps.bump.outputs.type }}" in | |
| major) | |
| major=$((major + 1)) | |
| minor=0 | |
| patch=0 | |
| ;; | |
| minor) | |
| minor=$((minor + 1)) | |
| patch=0 | |
| ;; | |
| patch) | |
| patch=$((patch + 1)) | |
| ;; | |
| esac | |
| new_version="${major}.${minor}.${patch}" | |
| echo "version=$new_version" >> "$GITHUB_OUTPUT" | |
| - name: Create release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "v${{ steps.version.outputs.version }}" \ | |
| --title "v${{ steps.version.outputs.version }}" \ | |
| --generate-notes \ | |
| --target "${{ github.sha }}" | |
| publish: | |
| needs: release | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Install MAUI workloads | |
| run: dotnet workload install maui-android maui-ios | |
| - name: Pack | |
| env: | |
| VERSION: ${{ needs.release.outputs.version }} | |
| run: dotnet pack NiceEntry/NiceEntry.csproj -c Release "/p:Version=$VERSION" | |
| - name: Push to NuGet | |
| run: dotnet nuget push ./nupkgs/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |