Repository navigation
115 lines (115 loc) · 3.96 KB
/
Copy pathcd.yml
File metadata and controls
115 lines (115 loc) · 3.96 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
name: Release
on:
push:
branches: [main]
paths:
- 'src/**'
- '!src/*Tests/**'
- '.github/workflows/cd.yml'
- '.github/scripts/check-package.py'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release-${{ github.repository }}
cancel-in-progress: false
jobs:
version:
if: github.ref == 'refs/heads/main'
runs-on: blacksmith-2vcpu-ubuntu-2404
timeout-minutes: 5
outputs:
current: ${{ steps.semver.outputs.current }}
next: ${{ steps.semver.outputs.next }}
version: ${{ steps.semver.outputs.nextStrict }}
steps:
- name: Calculate next version
id: semver
uses: ietf-tools/semver-action@v1.11.0
with:
token: ${{ github.token }}
branch: ${{ github.sha }}
minorList: feat
patchList: fix,perf
noNewCommitBehavior: silent
noVersionBumpBehavior: silent
release:
needs: version
if: needs.version.outputs.version != ''
runs-on: blacksmith-2vcpu-ubuntu-2404
timeout-minutes: 20
permissions:
contents: write
packages: write
id-token: write
env:
VERSION: ${{ needs.version.outputs.version }}
REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }}
steps:
- uses: actions/checkout@v7.0.1
with:
ref: ${{ github.sha }}
- uses: actions/setup-dotnet@v6.0.0
with:
global-json-file: global.json
- name: Restore
run: dotnet restore src/DimensionalQuantities.slnx
- name: Build
run: >-
dotnet build src/DimensionalQuantities.slnx -c Release --no-restore
-p:Version="$VERSION" -p:ContinuousIntegrationBuild=true -p:RepositoryUrl="$REPOSITORY_URL"
- name: Test
run: dotnet test --solution src/DimensionalQuantities.slnx -c Release --no-build --no-restore --report-trx --results-directory artifacts/test-results
- name: Pack
run: >-
dotnet pack src/DimensionalQuantities.slnx
-c Release --no-build --no-restore -o artifacts/packages
-p:Version="$VERSION" -p:ContinuousIntegrationBuild=true -p:RepositoryUrl="$REPOSITORY_URL"
- name: Check NuGet packages
run: python3 .github/scripts/check-package.py "$VERSION"
- name: Generate release notes
id: notes
uses: requarks/changelog-action@v1.10.3
with:
token: ${{ github.token }}
fromTag: ${{ github.sha }}
toTag: ${{ needs.version.outputs.current }}
writeToFile: false
useGitmojis: false
includeRefIssues: false
excludeTypes: ''
- name: NuGet trusted publishing login
uses: NuGet/login@v1
id: nuget-login
with:
user: ${{ vars.NUGET_USER }}
- name: Publish to nuget.org
env:
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: >-
dotnet nuget push 'artifacts/packages/*.nupkg'
--source https://api.nuget.org/v3/index.json
--api-key "$NUGET_API_KEY" --skip-duplicate
- name: Publish to GitHub Packages
env:
GITHUB_TOKEN: ${{ github.token }}
PACKAGE_SOURCE: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
run: >-
dotnet nuget push 'artifacts/packages/*.nupkg'
--source "$PACKAGE_SOURCE"
--api-key "$GITHUB_TOKEN" --skip-duplicate --no-symbols
- name: Create GitHub release
uses: ncipollo/release-action@v1.21.0
with:
token: ${{ github.token }}
tag: ${{ needs.version.outputs.next }}
commit: ${{ github.sha }}
body: ${{ steps.notes.outputs.changes }}
artifacts: artifacts/packages/*.nupkg,artifacts/packages/*.snupkg
artifactErrorsFailBuild: true
makeLatest: true
- uses: actions/upload-artifact@v7.0.2
if: always()
with:
name: release-results
path: artifacts/