-
Notifications
You must be signed in to change notification settings - Fork 1
180 lines (152 loc) · 4.96 KB
/
release.yml
File metadata and controls
180 lines (152 loc) · 4.96 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Release
on:
push:
branches: [main]
workflow_dispatch:
inputs:
bump:
description: "Version bump type"
required: false
default: "patch"
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
env:
DOTNET_VERSION: "9.x.x"
SOLUTION_DIR: "VisualPairCoding"
PROJECT: "./VisualPairCoding.AvaloniaUI/VisualPairCoding.AvaloniaUI.csproj"
jobs:
prepare:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Calculate next version
id: version
run: |
# Determine bump type
BUMP="${{ github.event.inputs.bump || 'patch' }}"
echo "Bump type: $BUMP"
# Find latest semver tag (supports v1.78 as v1.78.0)
LATEST_TAG=$(git tag --list 'v[0-9]*' --sort=-version:refname | head -n1)
echo "Latest tag: $LATEST_TAG"
if [ -z "$LATEST_TAG" ]; then
MAJOR=1; MINOR=0; PATCH=0
else
# Strip 'v' prefix
VERSION="${LATEST_TAG#v}"
# Handle two-part versions (v1.78 -> 1.78.0)
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
PATCH="${PATCH:-0}"
fi
echo "Current: $MAJOR.$MINOR.$PATCH"
case "$BUMP" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
NEW_TAG="v$NEW_VERSION"
echo "Next version: $NEW_VERSION (tag: $NEW_TAG)"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
build-and-release:
name: Build ${{ matrix.OUTPUTDIR }}
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
include:
- os: windows-latest
RUNTIMEID: win-x64
OUTPUTDIR: VisualPairCoding-win-x64
- os: ubuntu-latest
RUNTIMEID: linux-x64
OUTPUTDIR: VisualPairCoding-linux-x64
- os: macos-latest
RUNTIMEID: osx-x64
OUTPUTDIR: VisualPairCoding-osx-x64
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Install dependencies
run: dotnet restore
working-directory: Source/${{ env.SOLUTION_DIR }}
- name: Set version number
run: ./Set-Version-Number.ps1 "${{ needs.prepare.outputs.tag }}"
working-directory: Scripts
shell: pwsh
- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: Source/${{ env.SOLUTION_DIR }}
- name: Test
run: dotnet test --no-build --configuration Release
working-directory: Source/${{ env.SOLUTION_DIR }}
- name: Publish
run: >
dotnet publish ${{ env.PROJECT }}
-c Release
-o ${{ matrix.OUTPUTDIR }}
-p:PublishReadyToRun=true
--self-contained true
-p:PublishSingleFile=true
-p:IncludeNativeLibrariesForSelfExtract=true
-p:UseAppHost=true
-r ${{ matrix.RUNTIMEID }}
working-directory: Source/${{ env.SOLUTION_DIR }}
- uses: vimtor/action-zip@v1
with:
files: ./Source/${{ env.SOLUTION_DIR }}/${{ matrix.OUTPUTDIR }}/
dest: ${{ matrix.OUTPUTDIR }}.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.OUTPUTDIR }}
path: ${{ matrix.OUTPUTDIR }}.zip
create-release:
name: Create Release
needs: [prepare, build-and-release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create tag and release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ needs.prepare.outputs.tag }}"
VERSION="${{ needs.prepare.outputs.version }}"
# Create tag
git tag "$TAG"
git push origin "$TAG"
# Collect all zip files
find artifacts -name '*.zip' -exec mv {} . \;
# Create release
gh release create "$TAG" \
--title "VisualPairCoding $VERSION" \
--generate-notes \
*.zip