|
1 | | -name: Publish NuGet Package |
| 1 | +name: Publish to NuGet |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | | - - '[0-9]+.[0-9]+.[0-9]+' |
7 | | - - '[0-9]+.[0-9]+.[0-9]+-*' |
| 6 | + - '*' |
| 7 | + workflow_dispatch: |
8 | 8 |
|
9 | 9 | jobs: |
10 | 10 | publish: |
11 | 11 | runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
12 | 14 |
|
13 | 15 | steps: |
14 | 16 | - name: Checkout code |
15 | 17 | uses: actions/checkout@v4 |
16 | 18 |
|
17 | | - - name: Extract version from tag |
18 | | - id: get_version |
19 | | - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
20 | | - |
21 | | - - name: Setup .NET 9.0 |
| 19 | + - name: Setup .NET |
22 | 20 | uses: actions/setup-dotnet@v4 |
23 | 21 | with: |
24 | 22 | dotnet-version: '9.0.x' |
25 | 23 |
|
26 | | - - name: Restore dependencies |
27 | | - run: dotnet restore ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj |
| 24 | + - name: Extract version from tag |
| 25 | + id: get_version |
| 26 | + run: | |
| 27 | + TAG_NAME=${GITHUB_REF#refs/tags/} |
| 28 | + echo "VERSION=$TAG_NAME" >> $GITHUB_OUTPUT |
| 29 | + echo "Building version: $TAG_NAME" |
28 | 30 |
|
29 | | - - name: Build |
30 | | - run: dotnet build ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj --configuration Release --no-restore /p:Version=${{ steps.get_version.outputs.VERSION }} |
| 31 | + - name: Build library with version |
| 32 | + run: dotnet build -c Release /p:Version=${{ steps.get_version.outputs.VERSION }} ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj |
31 | 33 |
|
32 | | - - name: Pack |
33 | | - run: dotnet pack ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj --configuration Release --no-build --output ./artifacts /p:Version=${{ steps.get_version.outputs.VERSION }} |
| 34 | + - name: Pack NuGet package |
| 35 | + run: dotnet pack -c Release --no-build /p:Version=${{ steps.get_version.outputs.VERSION }} ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj -o ./artifacts |
34 | 36 |
|
35 | | - - name: Push to NuGet |
| 37 | + - name: Publish to NuGet |
36 | 38 | run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |
37 | 39 |
|
38 | 40 | - name: Create GitHub Release |
39 | | - uses: softprops/action-gh-release@v1 |
| 41 | + uses: softprops/action-gh-release@v2 |
40 | 42 | with: |
| 43 | + name: Release ${{ steps.get_version.outputs.VERSION }} |
| 44 | + tag_name: ${{ steps.get_version.outputs.VERSION }} |
| 45 | + draft: false |
| 46 | + prerelease: false |
41 | 47 | files: ./artifacts/*.nupkg |
42 | 48 | generate_release_notes: true |
43 | 49 | env: |
|
0 commit comments