-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (116 loc) · 4.25 KB
/
writecommit-ci-cd.yml
File metadata and controls
143 lines (116 loc) · 4.25 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
name: WriteCommit CI/CD
on:
push:
branches: [ main, develop ]
paths:
- '**'
- '.github/workflows/writecommit-*.yml'
pull_request:
branches: [ main ]
paths:
- '**'
- '.github/workflows/writecommit-*.yml'
env:
DOTNET_VERSION: '8.0.x'
PROJECT_NAME: 'WriteCommit'
jobs:
test:
name: Test WriteCommit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore ${{ env.PROJECT_NAME }}.csproj
- name: Build
run: dotnet build ${{ env.PROJECT_NAME }}.csproj --no-restore --configuration Release
- name: Test
run: dotnet test ${{ env.PROJECT_NAME }}.csproj --no-build --configuration Release --verbosity normal
build:
name: Build WriteCommit
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore ${{ env.PROJECT_NAME }}.csproj
- name: Build
run: dotnet build ${{ env.PROJECT_NAME }}.csproj --no-restore --configuration Release
- name: Publish
run: dotnet publish ${{ env.PROJECT_NAME }}.csproj --no-build --configuration Release --output ./publish
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: writecommit-build-${{ matrix.os }}
path: ./publish
retention-days: 30
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v1.1.1
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v1.1.1
with:
useConfigFile: true
configFilePath: GitVersion.yml
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Create release archives
run: |
cd artifacts
# Create Windows release
pushd writecommit-build-windows-latest
zip -r ../writecommit-windows-x64-v${{ steps.gitversion.outputs.majorMinorPatch }}.zip .
popd
# Create Linux release
pushd writecommit-build-ubuntu-latest
tar -czf ../writecommit-linux-x64-v${{ steps.gitversion.outputs.majorMinorPatch }}.tar.gz .
popd
# Create macOS release
pushd writecommit-build-macos-latest
tar -czf ../writecommit-macos-x64-v${{ steps.gitversion.outputs.majorMinorPatch }}.tar.gz .
popd
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.gitversion.outputs.majorMinorPatch }}
name: WriteCommit v${{ steps.gitversion.outputs.majorMinorPatch }}
body: |
## WriteCommit v${{ steps.gitversion.outputs.majorMinorPatch }}
### Downloads
- **Windows (x64)**: writecommit-windows-x64-v${{ steps.gitversion.outputs.majorMinorPatch }}.zip
- **Linux (x64)**: writecommit-linux-x64-v${{ steps.gitversion.outputs.majorMinorPatch }}.tar.gz
- **macOS (x64)**: writecommit-macos-x64-v${{ steps.gitversion.outputs.majorMinorPatch }}.tar.gz
### Changes
This release includes builds for Windows, Linux, and macOS platforms.
files: |
artifacts/writecommit-windows-x64-v${{ steps.gitversion.outputs.majorMinorPatch }}.zip
artifacts/writecommit-linux-x64-v${{ steps.gitversion.outputs.majorMinorPatch }}.tar.gz
artifacts/writecommit-macos-x64-v${{ steps.gitversion.outputs.majorMinorPatch }}.tar.gz
draft: false
prerelease: false
generate_release_notes: true