-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (102 loc) · 4.26 KB
/
preview-release.yml
File metadata and controls
125 lines (102 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Preview Release
on:
pull_request:
types: [opened, synchronize, reopened]
branches: [ main, develop ]
env:
DOTNET_VERSION: '8.0.x'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
preview-release:
name: Build Preview Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Generate version
id: version
run: |
# Base version from Directory.Build.props or default
BASE_VERSION="0.1.0"
# Create preview version: 0.1.0-preview.{PR#}.{run#}
PR_NUMBER=${{ github.event.pull_request.number }}
RUN_NUMBER=${{ github.run_number }}
PREVIEW_VERSION="${BASE_VERSION}-preview.${PR_NUMBER}.${RUN_NUMBER}"
echo "version=${PREVIEW_VERSION}" >> $GITHUB_OUTPUT
echo "Generated preview version: ${PREVIEW_VERSION}"
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release /p:Version=${{ steps.version.outputs.version }}
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
- name: Pack NuGet packages
run: |
dotnet pack src/BenchLibrary.Core/BenchLibrary.Core.csproj \
--no-build \
--configuration Release \
--output ./nupkgs \
/p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BenchLibrary.SixSigma/BenchLibrary.SixSigma.csproj \
--no-build \
--configuration Release \
--output ./nupkgs \
/p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BenchLibrary.Data/BenchLibrary.Data.csproj \
--no-build \
--configuration Release \
--output ./nupkgs \
/p:PackageVersion=${{ steps.version.outputs.version }}
- name: Upload NuGet packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages-preview
path: ./nupkgs/*.nupkg
retention-days: 7
- name: Publish to GitHub Packages
run: |
dotnet nuget push ./nupkgs/*.nupkg \
--source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
--api-key ${{ secrets.GITHUB_TOKEN }} \
--skip-duplicate
continue-on-error: true
- name: Comment on PR with package info
uses: marocchino/sticky-pull-request-comment@v2
with:
header: preview-packages
message: |
## 📦 Preview Packages Published
**Version:** `${{ steps.version.outputs.version }}`
### Packages
| Package | Version |
|---------|---------|
| BenchLibrary.Core | ${{ steps.version.outputs.version }} |
| BenchLibrary.SixSigma | ${{ steps.version.outputs.version }} |
| BenchLibrary.Data | ${{ steps.version.outputs.version }} |
### Installation
```bash
# Add GitHub Packages source (one-time setup)
dotnet nuget add source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
--name "github-${{ github.repository_owner }}" \
--username YOUR_GITHUB_USERNAME \
--password YOUR_GITHUB_TOKEN
# Install preview packages
dotnet add package BenchLibrary.Core --version ${{ steps.version.outputs.version }}
dotnet add package BenchLibrary.SixSigma --version ${{ steps.version.outputs.version }}
dotnet add package BenchLibrary.Data --version ${{ steps.version.outputs.version }}
```
### Download Artifacts
Preview packages are also available as [workflow artifacts](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
---
*Generated by PR #${{ github.event.pull_request.number }} • Run #${{ github.run_number }}*