-
Notifications
You must be signed in to change notification settings - Fork 3
117 lines (112 loc) · 4.3 KB
/
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
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
name: Continuous Delivery
on:
push:
branches:
- "**"
env:
project_path: Kafka.Protocol
project_name: Kafka.Protocol
jobs:
test:
name: Build & Test
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
- name: Build
run: dotnet build -c Release
- name: Test
run: dotnet test -c Release --no-build --verbosity normal
- name: Ensure Generated Code Committed
shell: bash
run: |
git diff --ignore-space-at-eol --ignore-cr-at-eol --exit-code
release:
name: Create Release
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Fetches entire history, so we can analyze commits since last tag
fetch-depth: 0
- name: Determine Release Versioning
id: versioning
uses: Fresa/trunk-based-release-versioning@v0
- name: Determine Release Version
id: release-tag
run: |
version=${{ steps.versioning.outputs.version }}
if ${{ steps.versioning.outputs.is-prerelease }}; then
version="$version-pre-$(echo ${{ steps.versioning.outputs.release-ref }} | cut -c1-8)"
fi
echo "tag=v$version" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
- name: Convert Commit Logs to JSON
id: convert-commit-logs
uses: mikefarah/yq@v4.30.6
with:
cmd: yq ea -o=json 'select(. != null) | [.]' "$(echo "${{ steps.versioning.outputs.commit-logs-path }}" | sed "s|^${{ github.workspace }}/||")" | tee commit_logs.json
- name: Generate Release Notes
id: release_notes
uses: Fresa/release-notes-generator@v2
with:
version: ${{ steps.release-tag.outputs.tag }}
last_release_ref: ${{ steps.versioning.outputs.last-release-ref }}
release_ref: ${{ steps.versioning.outputs.release-ref }}
path_to_commits: ./commit_logs.json
- name: Write Release Notes to File
run: |
echo "${{ steps.release_notes.outputs.release_notes }}" > release_notes.txt
- name: Pack
run: |
dotnet pack ${{ env.project_path }}/${{ env.project_name }}.csproj \
-c Release \
-o nuget-packages \
-p:PackageVersion=${{ steps.release-tag.outputs.version }} \
-p:InformationalVersion=${{ steps.release-tag.outputs.version }} \
-p:AssemblyVersion=${{ steps.versioning.outputs.major-version }}.0.0.0 \
-p:FileVersion=${{ steps.versioning.outputs.version }}.0 \
-p:ContinuousIntegrationBuild=true
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.release-tag.outputs.tag }}",
sha: "${{ steps.versioning.outputs.release-ref }}"
});
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: release_notes.txt
tag_name: ${{ steps.release-tag.outputs.tag }}
prerelease: ${{ steps.versioning.outputs.is-prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Latest Minor Tag
uses: EndBug/latest-tag@v1
if: steps.versioning.outputs.is-prerelease == 'false'
with:
ref: v${{ steps.versioning.outputs.major-version }}
description: ${{ steps.release-tag.outputs.tag }}
- name: Update Latest Patch Tag
uses: EndBug/latest-tag@v1
if: steps.versioning.outputs.is-prerelease == 'false'
with:
ref: v${{ steps.versioning.outputs.major-version }}.${{ steps.versioning.outputs.minor-version }}
description: ${{ steps.release-tag.outputs.tag }}
- name: Publish to nuget.org
run: |
dotnet nuget push nuget-packages/${{ env.project_name }}.${{ steps.release-tag.outputs.version }}.nupkg \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json