Skip to content

Commit e75ef6a

Browse files
committed
Add workflow for release
1 parent 394e66f commit e75ef6a

6 files changed

Lines changed: 297 additions & 0 deletions

File tree

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[*]
2+
charset = utf-8
3+
end_of_line = crlf
4+
insert_final_newline = true
5+
indent_style = tab
6+
indent_size = 4
7+
root = true
8+
9+
[{*.yml}]
10+
end_of_line = lf
11+
indent_style = space
12+
indent_size = 2

.github/lib-versions.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OPENSSL_BRANCH=OpenSSL_1_1_1-stable
2+
LIBSSH2_VERSION=1.9.0
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Build and Release EasySFTP
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # v1.2.3.4 のようなタグが push されたら発火
7+
workflow_dispatch:
8+
9+
jobs:
10+
check-cache:
11+
runs-on: windows-latest
12+
outputs:
13+
cache-hit: ${{ steps.cache-deps.outputs.cache-hit }}
14+
steps:
15+
- name: Checkout source code
16+
uses: actions/checkout@v4
17+
18+
- name: Restore OpenSSL/libssh2 cache
19+
id: cache-deps
20+
uses: actions/cache@v4
21+
with:
22+
path: deps
23+
key: easysftp-libs-${{ runner.os }}-${{ hashFiles('.github/lib-versions.env') }}
24+
25+
build-libs:
26+
needs: check-cache
27+
if: needs.check-cache.outputs.cache-hit != 'true'
28+
uses: ./.github/workflows/build-libs.yml
29+
30+
build:
31+
needs: [check-cache, build-libs]
32+
if: always() && !cancelled()
33+
runs-on: windows-latest
34+
35+
steps:
36+
- name: Checkout source code
37+
uses: actions/checkout@v4
38+
39+
- name: Restore OpenSSL/libssh2 cache
40+
id: cache-deps
41+
uses: actions/cache@v4
42+
with:
43+
path: deps
44+
key: easysftp-libs-${{ runner.os }}-${{ hashFiles('.github/lib-versions.env') }}
45+
46+
- name: Fail if deps cache not found
47+
if: steps.cache-deps.outputs.cache-hit != 'true'
48+
run: |
49+
echo "❌ Required deps cache was not found. Aborting."
50+
exit 1
51+
52+
# --- Common.user.props の生成 ---
53+
- name: Generate Common.user.props
54+
shell: pwsh
55+
run: |
56+
$content = Get-Content Common.user.sample.props -Raw
57+
58+
$content = $content `
59+
-replace '<OpenSSLRoot>.*?</OpenSSLRoot>',
60+
'<OpenSSLRoot>$(MSBuildThisFileDirectory)deps\openssl\</OpenSSLRoot>' `
61+
-replace '<LibSSH2Root>.*?</LibSSH2Root>',
62+
'<LibSSH2Root>$(MSBuildThisFileDirectory)deps\libssh2\</LibSSH2Root>'
63+
64+
$content | Set-Content Common.user.props -Encoding UTF8
65+
66+
- name: Setup MSBuild
67+
uses: microsoft/setup-msbuild@v2
68+
with:
69+
vs-version: 'latest'
70+
71+
- name: Build Win32
72+
run: |
73+
msbuild EasySFTP.sln /p:Configuration=Release /p:Platform=Win32
74+
75+
- name: Build x64
76+
run: |
77+
msbuild EasySFTP.sln /p:Configuration=Release /p:Platform=x64
78+
79+
- name: Prepare artifacts directory
80+
run: |
81+
mkdir dist
82+
mkdir dist\x64
83+
84+
copy bin\Win32\Release\*.exe dist\
85+
copy bin\Win32\Release\*.dll dist\
86+
copy EasySFTP.txt dist\
87+
copy license.txt dist\
88+
copy README.md dist\
89+
copy CHANGELOG.md dist\
90+
91+
copy bin\x64\Release\*.exe dist\x64\
92+
copy bin\x64\Release\*.dll dist\x64\
93+
94+
- name: Upload artifacts
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: easysftp-build
98+
path: dist/
99+
100+
- name: Create zip archive
101+
if: github.event_name != 'workflow_dispatch'
102+
shell: pwsh
103+
run: |
104+
$tag = "${{ github.ref_name }}" # 例: v1.2.3.4
105+
$version = $tag.TrimStart("v") # 先頭のvを取る
106+
Compress-Archive -Path dist\* -DestinationPath "EasySFTP-$version.zip"
107+
108+
- name: Extract release notes from CHANGELOG.md
109+
if: github.event_name != 'workflow_dispatch'
110+
id: changelog
111+
shell: pwsh
112+
run: |
113+
$tag = "${{ github.ref_name }}" # 例: v1.2.3.4
114+
echo "TAG_NAME=$tag" >> $env:GITHUB_ENV
115+
116+
$lines = Get-Content CHANGELOG.md
117+
$start = $lines.IndexOf("## $tag")
118+
if ($start -ge 0) {
119+
$rest = $lines[($start + 1)..($lines.Count - 1)]
120+
$bodyLines = @()
121+
foreach ($line in $rest) {
122+
if ($line -match "^## ") { break }
123+
$bodyLines += $line
124+
}
125+
126+
$body = $bodyLines -join "`n"
127+
"RELEASE_BODY<<EOF" >> $env:GITHUB_ENV
128+
$body >> $env:GITHUB_ENV
129+
"EOF" >> $env:GITHUB_ENV
130+
}
131+
132+
- name: Upload release asset
133+
if: github.event_name != 'workflow_dispatch'
134+
uses: softprops/action-gh-release@v2
135+
with:
136+
tag_name: ${{ env.TAG_NAME }}
137+
name: ${{ env.TAG_NAME }}
138+
body: ${{ env.RELEASE_BODY }}
139+
files: EasySFTP-*.zip

.github/workflows/build-libs.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Build OpenSSL and libssh2 (Static)
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
env:
8+
OPENSSL_REPO: https://github.com/openssl/openssl.git
9+
LIBSSH2_REPO: https://github.com/libssh2/libssh2.git
10+
11+
jobs:
12+
build-libs:
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Load library versions
20+
run: |
21+
Get-Content .github/lib-versions.env | ForEach-Object {
22+
if ($_ -match "^\s*([^#][^=]+)=(.+)$") {
23+
"$($matches[1])=$($matches[2])" >> $env:GITHUB_ENV
24+
}
25+
}
26+
27+
- name: Install Perl
28+
uses: shogo82148/actions-setup-perl@v1
29+
with:
30+
perl-version: '5.32'
31+
32+
- name: Install NASM
33+
uses: ilammy/setup-nasm@v1
34+
35+
- name: Setup MSBuild
36+
uses: microsoft/setup-msbuild@v2
37+
with:
38+
vs-version: 'latest'
39+
40+
- name: Build OpenSSL and libssh2
41+
shell: pwsh
42+
run: |
43+
$ErrorActionPreference = "Stop"
44+
Set-StrictMode -Version Latest
45+
$PSNativeCommandUseErrorActionPreference = $true
46+
Set-PSDebug -Trace 1
47+
48+
$vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
49+
-latest -products * `
50+
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
51+
-property installationPath
52+
53+
if (-not $vsPath) {
54+
throw "Visual Studio not found"
55+
}
56+
57+
$vcvars = Join-Path $vsPath "VC\Auxiliary\Build\vcvarsall.bat"
58+
59+
$arches = @(
60+
@{ Name = "x86"; VC = "x86"; OpenSSL = "VC-WIN32"; LibSSH2 = "Win32" },
61+
@{ Name = "x64"; VC = "x64"; OpenSSL = "VC-WIN64A"; LibSSH2 = "x64" }
62+
)
63+
64+
foreach ($a in $arches) {
65+
$arch = $a.Name
66+
$vc = $a.VC
67+
$targetOpenSSL = $a.OpenSSL
68+
$targetLibSSH2 = $a.LibSSH2
69+
70+
$logDir = "$env:GITHUB_WORKSPACE\logs"
71+
New-Item -ItemType Directory -Force -Path $logDir | Out-Null
72+
73+
# --- OpenSSL ---
74+
git clone --depth=1 --branch $env:OPENSSL_BRANCH $env:OPENSSL_REPO "openssl-$arch"
75+
76+
$opensslPrefix = "$env:GITHUB_WORKSPACE\deps\openssl\$arch"
77+
78+
cmd /c "`"$vcvars`" $vc && cd openssl-$arch && perl Configure $targetOpenSSL no-shared no-tests --prefix=$opensslPrefix && nmake && nmake install" `
79+
2>&1 | Tee-Object "logs\openssl-$arch.log"
80+
81+
# --- libssh2 ---
82+
git clone --depth=1 --branch "libssh2-$($env:LIBSSH2_VERSION)" $env:LIBSSH2_REPO "libssh2-$arch"
83+
Push-Location "libssh2-$arch"
84+
85+
$libssh2Prefix = "$env:GITHUB_WORKSPACE\deps\libssh2\$arch"
86+
cmake -S . -B build `
87+
-DBUILD_SHARED_LIBS=OFF `
88+
-DCRYPTO_BACKEND=OpenSSL `
89+
-DOPENSSL_ROOT_DIR="$opensslPrefix" `
90+
-DOPENSSL_INCLUDE_DIR="$opensslPrefix\include" `
91+
-DOPENSSL_LIBRARIES="$opensslPrefix\lib" `
92+
-DOPENSSL_CRYPTO_LIBRARY="$opensslPrefix\lib\libcrypto.lib" `
93+
-DOPENSSL_SSL_LIBRARY="$opensslPrefix\lib\libssl.lib" `
94+
-DOPENSSL_USE_STATIC_LIBS=ON `
95+
-DCMAKE_INSTALL_PREFIX="$libssh2Prefix" `
96+
-DCMAKE_GENERATOR="Visual Studio 17 2022" `
97+
-D CMAKE_C_FLAGS_DEBUG="/MTd" `
98+
-D CMAKE_C_FLAGS_RELEASE="/MT" `
99+
-D BUILD_EXAMPLES=OFF `
100+
-D BUILD_TESTING=OFF `
101+
-A $targetLibSSH2 `
102+
2>&1 | Tee-Object "$logDir\libssh2-config-$arch.log"
103+
104+
cmake --build build --config Release --target install 2>&1 | Tee-Object "$logDir\libssh2-build-$arch.log"
105+
Pop-Location
106+
107+
# 不要ファイル削除
108+
Remove-Item "$opensslPrefix\bin","$opensslPrefix\html","$opensslPrefix\share","$opensslPrefix\lib\pkgconfig","$opensslPrefix\lib\engines*" -Recurse -Force -ErrorAction SilentlyContinue
109+
Remove-Item "$libssh2Prefix\bin","$libssh2Prefix\share","$libssh2Prefix\lib\pkgconfig" -Recurse -Force -ErrorAction SilentlyContinue
110+
}
111+
112+
# --- キャッシュ保存 ---
113+
- name: Cache deps
114+
uses: actions/cache@v4
115+
with:
116+
path: deps
117+
key: easysftp-libs-${{ runner.os }}-${{ hashFiles('.github/lib-versions.env') }}
118+
119+
- name: Upload build artifacts
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: openssl-libssh2-build-artifacts
123+
path: |
124+
logs/
125+
deps/

EasySFTP/EasySFTP.vcxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@
265265
<ClInclude Include="targetver.h" />
266266
</ItemGroup>
267267
<ItemGroup>
268+
<None Include="..\.editorconfig" />
269+
<None Include="..\.github\lib-versions.env" />
270+
<None Include="..\.github\workflows\build-and-release.yml" />
271+
<None Include="..\.github\workflows\build-libs.yml" />
268272
<None Include="..\CHANGELOG.md" />
269273
<None Include="..\README.md" />
270274
<None Include="AddrBtns.bmp" />
@@ -296,6 +300,7 @@
296300
</ItemGroup>
297301
<ItemGroup>
298302
<Text Include="..\EasySFTP.txt" />
303+
<Text Include="..\license.txt" />
299304
</ItemGroup>
300305
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
301306
<ImportGroup Label="ExtensionTargets">

EasySFTP/EasySFTP.vcxproj.filters

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
1414
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
1515
</Filter>
16+
<Filter Include="GitHub Workflows">
17+
<UniqueIdentifier>{cf47e698-6136-4bfb-b502-bae68e3663d6}</UniqueIdentifier>
18+
</Filter>
1619
</ItemGroup>
1720
<ItemGroup>
1821
<ClCompile Include="AddrCBox.cpp">
@@ -126,6 +129,16 @@
126129
</None>
127130
<None Include="..\README.md" />
128131
<None Include="..\CHANGELOG.md" />
132+
<None Include="..\.github\workflows\build-and-release.yml">
133+
<Filter>GitHub Workflows</Filter>
134+
</None>
135+
<None Include="..\.editorconfig" />
136+
<None Include="..\.github\workflows\build-libs.yml">
137+
<Filter>GitHub Workflows</Filter>
138+
</None>
139+
<None Include="..\.github\lib-versions.env">
140+
<Filter>GitHub Workflows</Filter>
141+
</None>
129142
</ItemGroup>
130143
<ItemGroup>
131144
<ResourceCompile Include="EasySFTP.rc">
@@ -145,5 +158,6 @@
145158
</ItemGroup>
146159
<ItemGroup>
147160
<Text Include="..\EasySFTP.txt" />
161+
<Text Include="..\license.txt" />
148162
</ItemGroup>
149163
</Project>

0 commit comments

Comments
 (0)