|
1 | | -name: Build and Cache .NET Project |
| 1 | +name: Build and Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' # Triggers when you push a tag starting with 'v' |
5 | 7 |
|
6 | 8 | jobs: |
7 | 9 | build: |
8 | 10 | runs-on: ${{ matrix.os }} |
| 11 | + |
9 | 12 | strategy: |
10 | 13 | matrix: |
11 | | - os: [ubuntu-latest, windows-latest, macos-latest] |
12 | | - include: |
13 | | - - os: ubuntu-latest |
14 | | - publish_runtime: linux-x64 |
15 | | - - os: windows-latest |
16 | | - publish_runtime: win-x64 |
17 | | - - os: macos-latest |
18 | | - publish_runtime: osx-x64 |
| 14 | + os: [ubuntu-latest, windows-latest] # Build for Linux and Windows |
| 15 | + dotnet-version: ['9.0.x'] # Specify your target .NET version |
19 | 16 |
|
20 | 17 | steps: |
21 | | - - name: Checkout code |
22 | | - uses: actions/checkout@v3 |
23 | | - |
24 | | - - name: Setup .NET |
25 | | - uses: actions/setup-dotnet@v3 |
26 | | - with: |
27 | | - dotnet-version: '9.0.x' |
28 | | - |
29 | | - - name: Restore cached published artifacts |
30 | | - id: cache-restore |
31 | | - uses: actions/cache/restore@v4 |
32 | | - with: |
33 | | - path: ./publish |
34 | | - key: ${{ runner.os }}-publish-${{ github.sha }} |
35 | | - |
36 | | - - name: Restore dependencies |
37 | | - if: steps.cache-restore.outputs.cache-hit != 'true' |
38 | | - run: dotnet restore |
39 | | - |
40 | | - - name: Build |
41 | | - if: steps.cache-restore.outputs.cache-hit != 'true' |
42 | | - run: dotnet publish -c Release -r ${{ matrix.publish_runtime }} --self-contained true -p:PublishSingleFile=true -o ./publish |
43 | | - |
44 | | - - name: Cache published artifacts |
45 | | - id: cache-save |
46 | | - uses: actions/cache/save@v4 |
47 | | - with: |
48 | | - path: ./publish |
49 | | - key: ${{ steps.cache-restore.outputs.cache-primary-key }} |
50 | | - |
51 | | - - name: Upload artifact |
52 | | - uses: actions/upload-artifact@v3 |
53 | | - with: |
54 | | - name: ${{ runner.os }}-artifact |
55 | | - path: ./publish/* |
| 18 | + - name: Checkout Code |
| 19 | + uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Setup .NET |
| 22 | + uses: actions/setup-dotnet@v3 |
| 23 | + with: |
| 24 | + dotnet-version: ${{ matrix.dotnet-version }} |
| 25 | + |
| 26 | + - name: Restore Dependencies |
| 27 | + run: dotnet restore |
| 28 | + |
| 29 | + - name: Build Solution |
| 30 | + run: dotnet build --configuration Release |
| 31 | + |
| 32 | + - name: Publish Binaries |
| 33 | + run: dotnet publish --configuration Release --runtime ${{ matrix.os == 'ubuntu-latest' && 'linux-x64' || 'win-x64' }} --self-contained -p:PublishSingleFile=true |
| 34 | + env: |
| 35 | + DOTNET_ROOT: ${{ env.DOTNET_ROOT }} |
| 36 | + |
| 37 | + - name: Upload Artifact |
| 38 | + uses: actions/upload-artifact@v3 |
| 39 | + with: |
| 40 | + name: Sidecar-v3-${{ matrix.os }} |
| 41 | + path: | |
| 42 | + **/bin/Release/net*/publish/ |
| 43 | + !**/*.pdb |
0 commit comments