forked from andrewdavey/postal
-
Notifications
You must be signed in to change notification settings - Fork 9
137 lines (130 loc) · 4.7 KB
/
release-please.yml
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
126
127
128
129
130
131
132
133
134
135
136
137
name: release-please
on:
push:
branches:
- main
permissions:
contents: write
issues: read
checks: write
pull-requests: write
packages: write
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ["7","8"]
steps:
- uses: actions/checkout@v4
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Display dotnet version
run: dotnet --version
- uses: actions/cache@v3
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release Postal.sln
- name: Test
run: dotnet test -c Release --logger "trx;LogFileName=TestResults-${{ matrix.dotnet-version }}.trx"
- name: Upload dotnet test results
uses: actions/upload-artifact@v3
if: always()
with:
name: dotnet-results-${{ matrix.dotnet-version }}
path: "./**/TestResults/TestResults-${{ matrix.dotnet-version }}.trx"
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: "./**/TestResults/TestResults-${{ matrix.dotnet-version }}.trx"
test-pack:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7
8
- name: Display dotnet version
run: dotnet --version
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Add SHORT_SHA env property with commit short sha
run: |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
echo "GITHUB_RELEASE=true" >> $GITHUB_ENV
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release Postal.sln
- name: Create the package
run: dotnet pack src/Postal.AspNetCore/Postal.AspNetCore.csproj -c Release
- name: List src/Postal.AspNetCore/bin/Release/
run: ls -la src/Postal.AspNetCore/bin/Release/
release-please:
runs-on: ubuntu-latest
needs: [test, test-pack]
outputs:
release_created: ${{steps.release.outputs.release_created}}
steps:
- uses: google-github-actions/release-please-action@v4
id: release
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
deploy:
runs-on: ubuntu-latest
needs: [test, test-pack, release-please]
if: ${{ needs.release-please.outputs.release_created }}
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7
8
- name: Display dotnet version
run: dotnet --version
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Add SHORT_SHA env property with commit short sha
run: |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
echo "GITHUB_RELEASE=true" >> $GITHUB_ENV
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release Postal.sln
- name: Create the package
run: dotnet pack src/Postal.AspNetCore/Postal.AspNetCore.csproj -c Release
- name: Publish the package to myget
run: dotnet nuget push src/Postal.AspNetCore/bin/Release/*.nupkg --source https://www.myget.org/F/herman-github/api/v2/package --api-key ${{ secrets.MYGET_API_KEY }} --skip-duplicate
- name: Publish the package to Github
run: dotnet nuget push src/Postal.AspNetCore/bin/Release/*.nupkg --source https://nuget.pkg.github.com/hermanho/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate