-
Notifications
You must be signed in to change notification settings - Fork 29
76 lines (76 loc) · 3 KB
/
lib-ci.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
name: Lib - Build, Bump and Push (GitHub Registry)
on:
workflow_call:
secrets:
github-token:
description: 'The GitHub PAT token to perform checkout and publish.'
required: true
inputs:
project-name:
description: 'The name of the project to build. Must match the directory name.'
required: true
type: string
base-path:
description: 'The working directory base path with a trailing forward-slash'
required: false
default: '/home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/'
type: string
source-path:
description: >
The source path relative to the base path with a trailing forward-slash.
For example, if the project folder is in a subfolder called src, then this value needs to be set to src/
If there is no subfolder, just leave it empty.
required: false
default: ''
type: string
prerelease-versions-kept:
description: 'The number of pre-release versions kept in the GitHub registry.'
required: false
type: number
default: 10
version-bump-level:
description: 'The version component to bump after publishing.'
required: false
default: ${{ contains(github.event.head_commit.message, '[PATCH]') && 'patch' || contains(github.event.head_commit.message, '[MINOR]') && 'minor' || contains(github.event.head_commit.message, '[MAJOR]') && 'major' || 'prerelease' }}
type: string
jobs:
lib-ci:
runs-on: ubuntu-latest
steps:
- name: 🥓 Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
5.0.x
6.0.x
7.0.x
8.0.x
- name: 🧑💻 Checkout codebase
uses: actions/checkout@v4
with:
token: ${{ secrets.github-token }}
ref: ${{ github.ref_name }}
- name: 🐝 Bump version
uses: unosquare/bump-nuget-version@master
with:
level: ${{ inputs.version-bump-level }}
csproj: '${{ inputs.base-path }}${{ inputs.source-path }}${{ inputs.project-name }}/${{ inputs.project-name }}.csproj'
- name: 🏗 Build and pack nuget
run: |
dotnet pack '${{ inputs.base-path }}${{ inputs.source-path }}${{ inputs.project-name }}/${{ inputs.project-name }}.csproj' --configuration Release
- name: 📌 Commit
uses: EndBug/add-and-commit@v9
with:
message: '[skip ci]'
- name: 🍱 Publish nuget
uses: unosquare/publish-nuget-package@master
with:
access-token: ${{ secrets.github-token }}
path: '${{ inputs.base-path }}${{ inputs.source-path }}${{ inputs.project-name }}/bin/Release'
- name: 🌿 Clean up stale packages
uses: actions/delete-package-versions@v5
with:
package-name: ${{ inputs.project-name }}
package-type: 'nuget'
min-versions-to-keep: ${{ inputs.prerelease-versions-kept }}
delete-only-pre-release-versions: true