-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (75 loc) · 2.51 KB
/
build.yml
File metadata and controls
90 lines (75 loc) · 2.51 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
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
runtime: win-x64
- os: ubuntu-latest
runtime: linux-x64
- os: macos-15
runtime: osx-x64
- os: macos-latest
runtime: osx-arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v4.1.0
with:
dotnet-version: "9.0.x"
- name: Build
run: dotnet build MdTerm.csproj -c Release -r ${{ matrix.runtime }}
- name: Test
run: dotnet test -c Release --no-build
tag:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Determine next version
id: version
run: |
LATEST_TAG=$(git tag --list 'v*' --sort=-v:refname | head -n 1)
if [ -z "$LATEST_TAG" ]; then
NEXT="v0.1.0"
else
COMMITS=$(git log "${LATEST_TAG}..HEAD" --pretty=format:"%s%n%b")
BUMP="patch"
if echo "$COMMITS" | grep -qiE 'BREAKING CHANGE:|^[a-z]+(\(.+\))?!:'; then
BUMP="major"
elif echo "$COMMITS" | grep -qE '^feat(\(.+\))?:'; then
BUMP="minor"
fi
VERSION=${LATEST_TAG#v}
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
case "$BUMP" in
major) NEXT="v$((MAJOR + 1)).0.0" ;;
minor) NEXT="v${MAJOR}.$((MINOR + 1)).0" ;;
patch) NEXT="v${MAJOR}.${MINOR}.$((PATCH + 1))" ;;
esac
fi
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
echo "bump=$BUMP" >> "$GITHUB_OUTPUT"
- name: Create and push tag
run: |
echo "Creating ${{ steps.version.outputs.next }} (${{ steps.version.outputs.bump }} bump)"
git tag "${{ steps.version.outputs.next }}"
git push origin "${{ steps.version.outputs.next }}"