-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (121 loc) · 4.55 KB
/
cicd.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: .NET Build and Test
on:
push:
env:
App_Name: WpfReleaseActionDemo
Solution_Path: WpfReleaseActionDemo.sln
App_Project_Path: src/WpfDemo.App/WpfDemo.App.csproj
jobs:
build:
strategy:
matrix:
configuration: [Release] # [Debug, Release]
runs-on: windows-latest
timeout-minutes: 15
steps:
# Dump for debug workflow
- name: Dump Github Context
env:
GitHub_Context: ${{ toJson(github) }}
run: echo "${GitHub_Context}"
# Checks-out repository under $GITHUB_WORKSPACE: https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Install the .NET workload: https://github.com/actions/setup-dotnet
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.3.1
# Restore before build and test
- name: Restore
run: dotnet restore ${{ env.Solution_Path }}
- name: Build with dotnet
run: dotnet build ${{ env.App_Project_Path }} --no-restore
env:
Configuration: ${{ matrix.configuration }}
# Execute all unit tests in the solution
- name: Execute unit tests
run: dotnet test --no-restore
create-release:
runs-on: windows-latest
timeout-minutes: 15
needs: [build]
if: "contains( github.ref , 'tags/v')"
steps:
- name: Get version
shell: bash
run: |
echo "ver=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Set env
shell: bash
run: |
echo "version=${{ env.ver }}" >> $GITHUB_ENV # exeに反映されます
# echo "fileversion=${{ env.ver }}" >> $GITHUB_ENV # 未設定だとVersionに連動します
echo "app_x64_framework_name=${{ env.App_Name }}_win-x64_framework-dependent_ver${{ env.ver }}" >> $GITHUB_ENV
echo "app_x64_self_name=${{ env.App_Name }}_win-x64_self-contained_ver${{ env.ver }}" >> $GITHUB_ENV
# Checks-out repository under $GITHUB_WORKSPACE: https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# don't output pdb -> /p:DebugType=None /p:DebugSymbols=false
- name: dotnet publish x64 Framework-dependent
run: >
dotnet publish ${{ env.App_Project_Path }}
-c Release
-r win-x64
--self-contained false -p:UseAppHost=true
-p:PublishSingleFile=true
-p:PublishReadyToRun=false
-p:PublishTrimmed=false
-p:IncludeNativeLibrariesForSelfExtract=true
-o outputs\${{ env.app_x64_framework_name }}
# don't output pdb -> /p:DebugType=None /p:DebugSymbols=false
- name: dotnet publish x64 Self-contained
run: >
dotnet publish ${{ env.App_Project_Path }}
-c Release
-r win-x64
--self-contained true
-p:PublishSingleFile=true
-p:PublishReadyToRun=false
-p:PublishTrimmed=false
-p:IncludeNativeLibrariesForSelfExtract=true
-o outputs\${{ env.app_x64_self_name }}
# Upload Actions Artifacts: https://github.com/actions/upload-artifact
- name: Archive publish files
uses: actions/upload-artifact@v4
with:
name: ${{ env.App_Name }}
path: outputs
# Create zip
- name: Create zip archive
shell: pwsh
run: |
Compress-Archive -Path outputs\${{ env.app_x64_framework_name }} -DestinationPath ${{ env.app_x64_framework_name }}.zip
Compress-Archive -Path outputs\${{ env.app_x64_self_name }} -DestinationPath ${{ env.app_x64_self_name }}.zip
# Create release page: https://github.com/ncipollo/release-action
- name: Create release
id: create_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ env.ver }}
name: Ver ${{ env.ver }}
body: |
- Change design
- Bug fix
draft: true
prerelease: false
artifacts: "${{ env.app_x64_framework_name }}.zip, ${{ env.app_x64_self_name }}.zip"
# Remove artifacts to save space: https://github.com/c-hive/gha-remove-artifacts
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
age: '1 weeks'
skip-recent: 2