-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (114 loc) · 3.64 KB
/
release.yml
File metadata and controls
129 lines (114 loc) · 3.64 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
name: Release
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type"
required: false
default: "patch"
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
env:
DOTNET_VERSION: "10.0.x"
SOLUTION_DIR: "Source/LocalNetAppChat"
CLI_PROJECT: "LocalNetAppChat.Cli/LocalNetAppChat.Cli.csproj"
jobs:
prepare:
name: Determine version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Calculate next version
id: version
run: |
BUMP="${{ github.event.inputs.bump || 'patch' }}"
LATEST=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | head -n1)
if [ -z "$LATEST" ]; then
CURRENT="1.0.0"
else
CURRENT=$(echo "$LATEST" | sed 's/^v//')
fi
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
MINOR=$(echo "$CURRENT" | cut -d. -f2)
PATCH=$(echo "$CURRENT" | cut -d. -f3)
case "$BUMP" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac
VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"
echo "Next version: $VERSION (bump: $BUMP)"
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- run: dotnet restore
working-directory: ${{ env.SOLUTION_DIR }}
- run: dotnet build --configuration Release --no-restore
working-directory: ${{ env.SOLUTION_DIR }}
- run: dotnet test --configuration Release --no-build --verbosity normal
working-directory: ${{ env.SOLUTION_DIR }}
release:
name: Build & Release (${{ matrix.rid }})
needs: [prepare, test]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rid: linux-x64
artifact: lnac-linux-x64
- os: windows-latest
rid: win-x64
artifact: lnac-win-x64
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore
run: dotnet restore
working-directory: ${{ env.SOLUTION_DIR }}
- name: Publish
run: >-
dotnet publish ${{ env.CLI_PROJECT }}
-c Release
-o ${{ matrix.artifact }}
-r ${{ matrix.rid }}
-p:PublishReadyToRun=true
-p:PublishSingleFile=true
-p:IncludeNativeLibrariesForSelfExtract=true
-p:UseAppHost=true
-p:Version=${{ needs.prepare.outputs.version }}
--self-contained true
working-directory: ${{ env.SOLUTION_DIR }}
- name: Create archive
uses: vimtor/action-zip@v1
with:
files: ${{ env.SOLUTION_DIR }}/${{ matrix.artifact }}/
dest: ${{ matrix.artifact }}.zip
- name: Upload to release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.prepare.outputs.tag }}
name: "LNAC ${{ needs.prepare.outputs.tag }}"
generate_release_notes: true
files: ${{ matrix.artifact }}.zip