-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (116 loc) · 4.13 KB
/
Copy pathci.yml
File metadata and controls
136 lines (116 loc) · 4.13 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
126
127
128
129
130
131
132
133
134
135
136
name: CI (Build, Test and Publish)
on:
pull_request:
branches: ["**"]
push:
branches: ["**"]
tags-ignore: ["v*"]
permissions:
contents: read
packages: write
env:
PACKAGE_PROJECT: src/Abacus.Run/Abacus.Run.csproj
FEED: https://nuget.pkg.github.com/CodeShayk/index.json
jobs:
build-test:
runs-on: ubuntu-latest
env:
working-directory: ${{ github.workspace }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # GitVersion needs full history / tags
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.15
with:
versionSpec: 5.x
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.15
with:
useConfigFile: true
- name: Display Version
run: |
echo "NuGetVersion: ${{ steps.gitversion.outputs.NuGetVersionV2 }}"
echo "PreReleaseTag: ${{ steps.gitversion.outputs.PreReleaseTag }}"
- name: Restore
run: dotnet restore
working-directory: '${{ env.working-directory }}'
- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: '${{ env.working-directory }}'
- name: Test
run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage"
working-directory: '${{ env.working-directory }}'
# Publishes src/Abacus.Run to GitHub Packages as a CI prerelease.
#
# Only master pushes publish. Pull requests and feature branches build and test but never push a
# package, and the repository guard stops forks (whose GITHUB_TOKEN cannot write here anyway) from
# attempting it.
#
# Versions carry a -ci.<run> suffix so a stable version stays the exclusive product of a tagged
# release via release.yml / publish-package.yml. That keeps `1.0.0` meaning "released" and orders
# every CI build below it.
publish:
needs: build-test
if: >-
github.event_name == 'push'
&& github.ref == 'refs/heads/master'
&& github.repository == 'CodeShayk/Abacus-Run'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.15
with:
versionSpec: 5.x
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.15
with:
useConfigFile: true
- name: Compose CI version
id: version
run: |
VERSION="${{ steps.gitversion.outputs.NuGetVersionV2 }}-ci.${{ github.run_number }}"
echo "value=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Publishing Abacus.Run ${VERSION}"
# Packed without --no-build so the assembly and the package carry the same version; the
# library is a single project, so the rebuild is cheap.
- name: Pack
run: >
dotnet pack ${{ env.PACKAGE_PROJECT }}
--configuration Release
-p:Version=${{ steps.version.outputs.value }}
-o artifacts
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: nupkg-${{ steps.version.outputs.value }}
path: artifacts/*
- name: Push to GitHub Packages
run: |
dotnet nuget add source "${FEED}" \
--name github \
--username "${{ github.actor }}" \
--password "${{ secrets.GITHUB_TOKEN }}" \
--store-password-in-clear-text
# --skip-duplicate keeps re-runs idempotent; the feed rejects overwriting a published
# version. --no-symbols because it does not accept .snupkg.
dotnet nuget push "artifacts/*.nupkg" \
--source github \
--api-key "${{ secrets.GITHUB_TOKEN }}" \
--skip-duplicate \
--no-symbols