-
Notifications
You must be signed in to change notification settings - Fork 6
149 lines (126 loc) · 4.78 KB
/
build-and-release.yml
File metadata and controls
149 lines (126 loc) · 4.78 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
name: Build and Release EasySFTP
on:
push:
branches:
- '**'
tags:
- 'v*'
workflow_dispatch:
jobs:
check-cache:
runs-on: windows-latest
outputs:
cache-hit: ${{ steps.cache-deps.outputs.cache-hit }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Restore OpenSSL/libssh2 cache
id: cache-deps
uses: actions/cache@v4
with:
path: deps
key: easysftp-libs-${{ runner.os }}-${{ hashFiles('.github/lib-versions.env') }}
build-libs:
needs: check-cache
if: needs.check-cache.outputs.cache-hit != 'true'
uses: ./.github/workflows/build-libs.yml
build:
needs: [check-cache, build-libs]
if: always() && !cancelled()
runs-on: windows-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Restore OpenSSL/libssh2 cache
id: cache-deps
uses: actions/cache@v4
with:
path: deps
key: easysftp-libs-${{ runner.os }}-${{ hashFiles('.github/lib-versions.env') }}
- name: Fail if deps cache not found
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
echo "❌ Required deps cache was not found. Aborting."
exit 1
- name: Generate Common.user.props
shell: pwsh
run: |
$content = Get-Content Common.user.sample.props -Raw
$content = $content `
-replace '<OpenSSLRoot>.*?</OpenSSLRoot>',
'<OpenSSLRoot>$(MSBuildThisFileDirectory)deps\openssl\</OpenSSLRoot>' `
-replace '<LibSSH2Root>.*?</LibSSH2Root>',
'<LibSSH2Root>$(MSBuildThisFileDirectory)deps\libssh2\</LibSSH2Root>'
$content | Set-Content Common.user.props -Encoding UTF8
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
with:
vs-version: 'latest'
- name: Build Win32
run: |
msbuild EasySFTP.sln /p:Configuration=Release /p:Platform=Win32
- name: Build x64
run: |
msbuild EasySFTP.sln /p:Configuration=Release /p:Platform=x64
- name: Prepare artifacts directory
shell: pwsh
run: |
mkdir dist
mkdir dist\x64
$PSNativeCommandUseErrorActionPreference = $true
copy bin\Win32\Release\*.exe dist\
copy bin\Win32\Release\*.dll dist\
$PSNativeCommandUseErrorActionPreference = $false
robocopy bin\Win32\Release dist /S /E /IF *.mui
if ($global:LASTEXITCODE -le 7) { $global:LASTEXITCODE = 0 } else { throw "Robocopy error: $global:LASTEXITCODE" }
$PSNativeCommandUseErrorActionPreference = $true
copy EasySFTP.txt dist\
copy license.txt dist\
copy README.md dist\
copy CHANGELOG.md dist\
copy bin\x64\Release\*.exe dist\x64\
copy bin\x64\Release\*.dll dist\x64\
$PSNativeCommandUseErrorActionPreference = $false
robocopy bin\x64\Release dist\x64 /S /E /IF *.mui
if ($global:LASTEXITCODE -le 7) { $global:LASTEXITCODE = 0 } else { throw "Robocopy error: $global:LASTEXITCODE" }
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: easysftp-build
path: dist/
- name: Create zip archive
if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'workflow_dispatch'
shell: pwsh
run: |
$tag = "${{ github.ref_name }}" # 例: v1.2.3.4
$version = $tag.TrimStart("v") # 先頭のvを取る
Compress-Archive -Path dist\* -DestinationPath "EasySFTP-$version.zip"
- name: Extract release notes from CHANGELOG.md
if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'workflow_dispatch'
id: changelog
shell: pwsh
run: |
$tag = "${{ github.ref_name }}" # 例: v1.2.3.4
echo "TAG_NAME=$tag" >> $env:GITHUB_ENV
$lines = Get-Content CHANGELOG.md
$start = $lines.IndexOf("## $tag")
if ($start -ge 0) {
$rest = $lines[($start + 1)..($lines.Count - 1)]
$bodyLines = @()
foreach ($line in $rest) {
if ($line -match "^## ") { break }
$bodyLines += $line
}
$body = $bodyLines -join "`n"
"RELEASE_BODY<<EOF" >> $env:GITHUB_ENV
$body >> $env:GITHUB_ENV
"EOF" >> $env:GITHUB_ENV
}
- name: Upload release asset
if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'workflow_dispatch'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG_NAME }}
name: ${{ env.TAG_NAME }}
body: ${{ env.RELEASE_BODY }}
files: EasySFTP-*.zip