|
1 | | -name: Publish NuGet |
| 1 | +name: Publish to NuGet |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
5 | 5 | inputs: |
6 | | - version_suffix: |
7 | | - description: 'Optional version suffix (e.g. preview.1)' |
| 6 | + version: |
| 7 | + description: 'Package version (e.g., 1.0.0)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + prerelease: |
| 11 | + description: 'Is this a prerelease? (adds -preview suffix)' |
8 | 12 | required: false |
9 | | - default: '' |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + |
| 16 | +env: |
| 17 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 18 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
10 | 19 |
|
11 | 20 | jobs: |
12 | 21 | publish: |
| 22 | + name: Build & Publish |
| 23 | + if: github.repository_owner == 'atakanatali' |
13 | 24 | runs-on: ubuntu-latest |
| 25 | + environment: nuget-prod |
14 | 26 |
|
15 | 27 | steps: |
16 | 28 | - name: Checkout |
17 | 29 | uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
18 | 32 |
|
19 | | - - name: Setup .NET |
| 33 | + - name: 🔧 Setup .NET |
20 | 34 | uses: actions/setup-dotnet@v4 |
21 | 35 | with: |
22 | 36 | dotnet-version: 9.0.x |
23 | 37 |
|
| 38 | + - name: Set Version |
| 39 | + id: version |
| 40 | + run: | |
| 41 | + VERSION="${{ github.event.inputs.version }}" |
| 42 | + if [ "${{ github.event.inputs.prerelease }}" == "true" ]; then |
| 43 | + VERSION="${VERSION}-preview" |
| 44 | + fi |
| 45 | + echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_OUTPUT |
| 46 | + echo "Package version: ${VERSION}" |
| 47 | +
|
24 | 48 | - name: Restore |
25 | 49 | run: dotnet restore |
26 | 50 |
|
27 | | - - name: Build |
28 | | - run: dotnet build --configuration Release --no-restore |
| 51 | + - name: 🔨 Build |
| 52 | + run: | |
| 53 | + dotnet build -c Release --no-restore \ |
| 54 | + /p:Version=${{ steps.version.outputs.PACKAGE_VERSION }} \ |
| 55 | + /p:PackageVersion=${{ steps.version.outputs.PACKAGE_VERSION }} |
| 56 | +
|
| 57 | + - name: Test |
| 58 | + run: dotnet test -c Release --no-build --verbosity normal |
29 | 59 |
|
30 | 60 | - name: Pack |
31 | 61 | run: | |
32 | | - VERSION_SUFFIX_ARG="" |
33 | | - if [ -n "${{ github.event.inputs.version_suffix }}" ]; then |
34 | | - VERSION_SUFFIX_ARG="--version-suffix ${{ github.event.inputs.version_suffix }}" |
35 | | - fi |
36 | | - dotnet pack src/Notify.Abstractions/Notify.Abstractions.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG |
37 | | - dotnet pack src/Notify.Broker.Abstractions/Notify.Broker.Abstractions.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG |
38 | | - dotnet pack src/Notify.Broker.RabbitMQ/Notify.Broker.RabbitMQ.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG |
39 | | - dotnet pack src/Notify.Core/Notify.Core.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG |
40 | | - dotnet pack src/Notify.Hosting/Notify.Hosting.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG |
| 62 | + dotnet pack -c Release --no-build \ |
| 63 | + /p:Version=${{ steps.version.outputs.PACKAGE_VERSION }} \ |
| 64 | + /p:PackageVersion=${{ steps.version.outputs.PACKAGE_VERSION }} \ |
| 65 | + -o ./nupkgs |
| 66 | +
|
| 67 | + - name: 📋 List Packages |
| 68 | + run: ls -la ./nupkgs |
| 69 | + |
| 70 | + - name: Push to NuGet |
| 71 | + run: | |
| 72 | + for package in ./nupkgs/*.nupkg; do |
| 73 | + echo "Publishing: $package" |
| 74 | + dotnet nuget push "$package" \ |
| 75 | + --api-key "${{ secrets.NUGET_API_KEY }}" \ |
| 76 | + --source https://api.nuget.org/v3/index.json \ |
| 77 | + --skip-duplicate |
| 78 | + done |
41 | 79 |
|
42 | | - - name: Publish |
| 80 | + - name: Create Git Tag |
| 81 | + run: | |
| 82 | + git config user.name "github-actions[bot]" |
| 83 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 84 | + git tag -a "v${{ steps.version.outputs.PACKAGE_VERSION }}" -m "Release v${{ steps.version.outputs.PACKAGE_VERSION }}" |
| 85 | + git push origin "v${{ steps.version.outputs.PACKAGE_VERSION }}" |
| 86 | +
|
| 87 | + - name: Create Release |
| 88 | + uses: softprops/action-gh-release@v1 |
| 89 | + with: |
| 90 | + tag_name: v${{ steps.version.outputs.PACKAGE_VERSION }} |
| 91 | + name: Notify v${{ steps.version.outputs.PACKAGE_VERSION }} |
| 92 | + body: | |
| 93 | + ## Notify v${{ steps.version.outputs.PACKAGE_VERSION }} |
| 94 | + |
| 95 | + ### Packages Published |
| 96 | + - `Notify.Abstractions` - Shared contracts and interfaces |
| 97 | + - `Notify.Core` - Producer-side publishing, serialization, and compression |
| 98 | + - `Notify.Hosting` - Worker-side consumption and provider dispatching |
| 99 | + - `Notify.Broker.Abstractions` - Broker-agnostic abstractions |
| 100 | + - `Notify.Broker.RabbitMQ` - RabbitMQ broker implementation |
| 101 | + |
| 102 | + ### Installation |
| 103 | + ```bash |
| 104 | + dotnet add package Notify.Core --version ${{ steps.version.outputs.PACKAGE_VERSION }} |
| 105 | + ``` |
| 106 | + |
| 107 | + See [CHANGELOG.md](https://github.com/atakanatali/notify/blob/main/CHANGELOG.md) for details. |
| 108 | + draft: false |
| 109 | + prerelease: ${{ github.event.inputs.prerelease }} |
| 110 | + files: | |
| 111 | + ./nupkgs/*.nupkg |
| 112 | + ./nupkgs/*.snupkg |
43 | 113 | env: |
44 | | - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
45 | | - run: dotnet nuget push "artifacts/*.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate |
| 114 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments