• R/O
  • HTTP
  • SSH
  • HTTPS

open-tween: Commit

開発に使用するリポジトリ


Commit MetaInfo

Revision55081d1f83daea1799f9e1aacecae3c1cb4578bf (tree)
Time2021-03-06 20:39:00
Authorupsilon <kim.upsilon@bucy...>
CommiterGitHub

Log Message

Merge pull request #86 from upsilon/reproducible-build

Reproducible Build に対応

Change Summary

Incremental Difference

--- a/OpenTween/MyCommon.cs
+++ b/OpenTween/MyCommon.cs
@@ -227,9 +227,8 @@ namespace OpenTween
227227 var assembly = Assembly.GetExecutingAssembly();
228228 MyCommon.EntryAssembly = assembly;
229229
230- var fileVersionAttribute = (AssemblyFileVersionAttribute)assembly
231- .GetCustomAttributes(typeof(AssemblyFileVersionAttribute)).First();
232- MyCommon.FileVersion = fileVersionAttribute.Version;
230+ var assemblyVersion = assembly.GetName().Version;
231+ MyCommon.FileVersion = assemblyVersion.ToString();
233232 }
234233
235234 public static string GetErrorLogPath()
--- a/OpenTween/OpenTween.csproj
+++ b/OpenTween/OpenTween.csproj
@@ -11,6 +11,8 @@
1111 <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1212 <LangVersion>8.0</LangVersion>
1313 <FileAlignment>512</FileAlignment>
14+ <Deterministic>true</Deterministic>
15+ <PathMap>$(MSBuildProjectDirectory)=.</PathMap>
1416 </PropertyGroup>
1517 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1618 <DebugSymbols>true</DebugSymbols>
--- a/OpenTween/Properties/AssemblyInfo.cs
+++ b/OpenTween/Properties/AssemblyInfo.cs
@@ -22,18 +22,7 @@ using System.Runtime.InteropServices;
2222 // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
2323 [assembly: Guid("2d0ae0ba-adac-49a2-9b10-26fd69e695bf")]
2424
25-// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26-//
27-// Major Version
28-// Minor Version
29-// Build Number
30-// Revision
31-//
32-// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
33-// 既定値にすることができます:
34-// [assembly: AssemblyVersion("1.0.*")]
35-[assembly: AssemblyVersion("0.1.0.0")]
36-[assembly: AssemblyFileVersion("2.4.3.1")]
25+[assembly: AssemblyVersion("2.4.3.1")]
3726
3827 [assembly: InternalsVisibleTo("OpenTween.Tests")]
3928 [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // for Moq
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -2,10 +2,43 @@ version: 2.4.3.{build}
22
33 os: Visual Studio 2019
44
5-assembly_info:
6- patch: true
7- file: OpenTween\Properties\AssemblyInfo.cs
8- assembly_file_version: '{version}'
5+environment:
6+ matrix:
7+ - RELEASE_TAG: 'false'
8+ - RELEASE_TAG: 'true'
9+
10+configuration:
11+ - Debug
12+ - Release
13+
14+matrix:
15+ exclude:
16+ - RELEASE_TAG: 'false'
17+ configuration: Release
18+ - RELEASE_TAG: 'true'
19+ configuration: Debug
20+
21+for:
22+ - # for dev build
23+ matrix:
24+ only:
25+ - RELEASE_TAG: 'false'
26+ skip_tags: true
27+ assembly_info:
28+ patch: true
29+ file: OpenTween\Properties\AssemblyInfo.cs
30+ assembly_version: '{version}'
31+ artifacts:
32+ - name: OpenTween.zip
33+ path: OpenTween_dev-$(APPVEYOR_BUILD_NUMBER).zip
34+ - # for release build
35+ matrix:
36+ only:
37+ - RELEASE_TAG: 'true'
38+ skip_non_tags: true
39+ artifacts:
40+ - name: OpenTween.zip
41+ path: $(APPVEYOR_REPO_TAG_NAME).zip
942
1043 build:
1144 project: OpenTween.sln
@@ -22,17 +55,22 @@ before_build:
2255 - choco install opencover.portable
2356
2457 test_script:
25- - OpenCover.Console.exe -register -target:"%xunit20%\xunit.console.exe" -targetargs:".\OpenTween.Tests\bin\Debug\net472\OpenTween.Tests.dll -noshadow -appveyor" -filter:"+[OpenTween*]* -[OpenTween.Tests]*" -excludebyfile:"*.Designer.cs" -skipautoprops -hideskipped:All -returntargetcode -output:coverage.xml
58+ - OpenCover.Console.exe -register -target:"%xunit20%\xunit.console.exe" -targetargs:".\OpenTween.Tests\bin\%CONFIGURATION%\net472\OpenTween.Tests.dll -noshadow -appveyor" -filter:"+[OpenTween*]* -[OpenTween.Tests]*" -excludebyfile:"*.Designer.cs" -skipautoprops -hideskipped:All -returntargetcode -output:coverage.xml
2659
2760 after_test:
2861 - npm install codecov --save
2962 - ./node_modules/.bin/codecov -f coverage.xml
3063
31- - del %APPVEYOR_BUILD_FOLDER%\OpenTween\bin\Debug\OpenTween.pdb
32- - 7z a OpenTween_dev-%APPVEYOR_BUILD_NUMBER%.zip %APPVEYOR_BUILD_FOLDER%\OpenTween\bin\Debug\*
33-
34-artifacts:
35- - name: OpenTween.zip
36- path: OpenTween_dev-$(APPVEYOR_BUILD_NUMBER).zip
64+ - ps: |
65+ $env:PATH = $env:PATH + ';C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\'
66+ $binDir = '.\OpenTween\bin\' + $env:CONFIGURATION + '\'
67+ $objDir = '.\OpenTween\obj\' + $env:CONFIGURATION + '\'
68+ $assemblyInfo = '.\OpenTween\Properties\AssemblyInfo.cs'
69+ if ($env:RELEASE_TAG -eq 'true') {
70+ $destPath = $env:APPVEYOR_REPO_TAG_NAME + '.zip'
71+ } else {
72+ $destPath = 'OpenTween_dev-' + $env:APPVEYOR_BUILD_NUMBER + '.zip'
73+ }
74+ .\tools\build-zip-archive.ps1 -BinDir $binDir -ObjDir $objDir -AssemblyInfo $assemblyInfo -DestPath $destPath
3775
3876 # vim: et fenc=utf-8 sts=2 sw=2 ts=2
--- /dev/null
+++ b/tools/build-satelite-assembly.ps1
@@ -0,0 +1,60 @@
1+# OpenTween - Client of Twitter
2+# Copyright (c) 2021 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
3+# All rights reserved.
4+#
5+# This file is part of OpenTween.
6+#
7+# This program is free software; you can redistribute it and/or modify it
8+# under the terms of the GNU General Public License as published by the Free
9+# Software Foundation; either version 3 of the License, or (at your option)
10+# any later version.
11+#
12+# This program is distributed in the hope that it will be useful, but
13+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+# for more details.
16+#
17+# You should have received a copy of the GNU General Public License along
18+# with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19+# the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20+# Boston, MA 02110-1301, USA.
21+
22+#
23+# Reproducible Build に対応したサテライトアセンブリのビルド
24+#
25+# 使い方:
26+# .\tools\build-satelite-assembly.ps1 -ObjDir .\OpenTween\obj\Debug\ -Culture en -AssemblyInfo .\OpenTween\Properties\AssemblyInfo.cs -DestPath .\OpenTween\bin\Debug\en\OpenTween.resources.dll
27+#
28+
29+Param(
30+ [Parameter(Mandatory = $true)][String] $ObjDir,
31+ [Parameter(Mandatory = $true)][String] $Culture,
32+ [Parameter(Mandatory = $true)][String] $AssemblyInfo,
33+ [Parameter(Mandatory = $true)][String] $DestPath
34+)
35+
36+Set-StrictMode -Version 3.0
37+$ErrorActionPreference = 'Stop'
38+
39+. .\tools\functions.ps1
40+
41+Function Generate-AssemblyInfo() {
42+ $tmpFile = New-TemporaryFile
43+ $content = (Get-Content $AssemblyInfo) -replace "^\[assembly: AssemblyCulture.+$", "[assembly: AssemblyCulture(`"${Culture}`")]"
44+ $content > $tmpFile.FullName
45+ return $tmpFile.FullName
46+}
47+
48+Function Build-SateliteAssembly() {
49+ $tmpAssemblyInfoPath = Generate-AssemblyInfo
50+ try {
51+ $resourcePaths = Get-ChildItem -Path $ObjDir -File -Filter "*.${Culture}.resources"
52+ $cscOpts = "-utf8output -nologo -deterministic -target:library -debug- -optimize+ -out:${DestPath}"
53+ $cscOpts += " " + ($resourcePaths | % { "-resource:$($_.FullName)" }) -join ' '
54+ Invoke-NativeCommand "csc $cscOpts $tmpAssemblyInfoPath"
55+ } finally {
56+ Remove-Item -Path $tmpAssemblyInfoPath
57+ }
58+}
59+
60+Build-SateliteAssembly
--- /dev/null
+++ b/tools/build-zip-archive.ps1
@@ -0,0 +1,98 @@
1+# OpenTween - Client of Twitter
2+# Copyright (c) 2021 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
3+# All rights reserved.
4+#
5+# This file is part of OpenTween.
6+#
7+# This program is free software; you can redistribute it and/or modify it
8+# under the terms of the GNU General Public License as published by the Free
9+# Software Foundation; either version 3 of the License, or (at your option)
10+# any later version.
11+#
12+# This program is distributed in the hope that it will be useful, but
13+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+# for more details.
16+#
17+# You should have received a copy of the GNU General Public License along
18+# with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19+# the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20+# Boston, MA 02110-1301, USA.
21+
22+#
23+# Reproducible Build に対応した ZIP アーカイブのビルドを行うスクリプト
24+#
25+# 使い方:
26+# .\tools\build-zip-archive.ps1 -BinDir .\OpenTween\bin\Debug\ -ObjDir .\OpenTween\obj\Debug\ -AssemblyInfo .\OpenTween\Properties\AssemblyInfo.cs -DestPath OpenTween.zip
27+#
28+
29+Param(
30+ [Parameter(Mandatory = $true)][String] $BinDir,
31+ [Parameter(Mandatory = $true)][String] $ObjDir,
32+ [Parameter(Mandatory = $true)][String] $AssemblyInfo,
33+ [Parameter(Mandatory = $true)][String] $DestPath
34+)
35+
36+Set-StrictMode -Version 3.0
37+$ErrorActionPreference = 'Stop'
38+
39+$assemblyName = "OpenTween"
40+
41+$exePath = Join-Path $BinDir "${assemblyName}.exe"
42+$sgenOpts = "/type:${assemblyName}.SettingAtIdList /type:${assemblyName}.SettingCommon /type:${assemblyName}.SettingLocal /type:${assemblyName}.SettingTabs"
43+$includeFiles = @(
44+ "en\",
45+ "Icons\",
46+ "LICENSE",
47+ "LICENSE.GPL-3",
48+ "LICENSE.ja",
49+ "LICENSE.LGPL-3",
50+ "${assemblyName}.exe",
51+ "${assemblyName}.exe.config",
52+ "${assemblyName}.XmlSerializers.dll"
53+)
54+
55+. .\tools\functions.ps1
56+
57+Function Generate-Serializer() {
58+ # OpenTween.XmlSerializers.dll の生成
59+ .\tools\generate-serializer.ps1 -ExePath $exePath -SgenOpts $sgenOpts
60+}
61+
62+Function Build-SateliteAssembly([String] $Culture) {
63+ # OpenTween.resources.dll の生成(カルチャ別)
64+ $sateliteAssemblyPath = Join-Path $BinDir "${Culture}\${assemblyName}.resources.dll"
65+ .\tools\build-satelite-assembly.ps1 -ObjDir $ObjDir -Culture $Culture -DestPath $sateliteAssemblyPath -AssemblyInfo $AssemblyInfo
66+}
67+
68+Function Get-SourceDateEpoch() {
69+ # 本来 $unixEpoch は UTC で表さなければならないが、ZIP アーカイブには
70+ # ローカルのタイムゾーンの日時でタイムスタンプが記録されるため、わざとタイムゾーンを指定していない。
71+ # これにより、生成される ZIP アーカイブには UTC での $sourceDateEpoch に相当する日時が記録されるようになる
72+ $unixEpoch = Get-Date "1970/01/01 00:00:00"
73+ $sourceDateUnixtime = [int](Invoke-NativeCommand "git log -1 --pretty=%ct")
74+ $sourceDateEpoch = $unixEpoch.AddSeconds($sourceDateUnixtime)
75+ return $sourceDateEpoch
76+}
77+
78+Function Reset-Timestamps([String[]] $Path, [DateTime] $Timestamp) {
79+ # ZIP アーカイブに含めるファイルのタイムスタンプを揃える
80+ Get-ChildItem $Path -Recurse | Set-ItemProperty -Name "LastWriteTime" -Value $Timestamp
81+}
82+
83+Function Build-Package([String[]] $Path, [String] $DestPath) {
84+ Compress-Archive -Force -Path $Path -DestinationPath $DestPath
85+}
86+
87+Generate-Serializer
88+Build-SateliteAssembly -Culture en
89+
90+$includePaths = $includeFiles | % { Join-Path $BinDir $_ }
91+$timestamp = Get-SourceDateEpoch
92+
93+Reset-Timestamps -Path $includePaths -Timestamp $timestamp
94+Build-Package -Path $includePaths -DestPath $DestPath
95+
96+Write-Host
97+Write-Host "Build success!"
98+Get-FileHash -Algorithm SHA256 $destPath | Format-List
--- /dev/null
+++ b/tools/functions.ps1
@@ -0,0 +1,30 @@
1+# OpenTween - Client of Twitter
2+# Copyright (c) 2021 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
3+# All rights reserved.
4+#
5+# This file is part of OpenTween.
6+#
7+# This program is free software; you can redistribute it and/or modify it
8+# under the terms of the GNU General Public License as published by the Free
9+# Software Foundation; either version 3 of the License, or (at your option)
10+# any later version.
11+#
12+# This program is distributed in the hope that it will be useful, but
13+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+# for more details.
16+#
17+# You should have received a copy of the GNU General Public License along
18+# with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19+# the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20+# Boston, MA 02110-1301, USA.
21+
22+Set-StrictMode -Version 3.0
23+$ErrorActionPreference = 'Stop'
24+
25+Function Invoke-NativeCommand([String] $Command) {
26+ Invoke-Expression -Command $Command
27+ if ($LASTEXITCODE -ne 0) {
28+ throw "Child process died with exit code: $LASTEXITCODE"
29+ }
30+}
--- /dev/null
+++ b/tools/generate-serializer.ps1
@@ -0,0 +1,65 @@
1+# OpenTween - Client of Twitter
2+# Copyright (c) 2021 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
3+# All rights reserved.
4+#
5+# This file is part of OpenTween.
6+#
7+# This program is free software; you can redistribute it and/or modify it
8+# under the terms of the GNU General Public License as published by the Free
9+# Software Foundation; either version 3 of the License, or (at your option)
10+# any later version.
11+#
12+# This program is distributed in the hope that it will be useful, but
13+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+# for more details.
16+#
17+# You should have received a copy of the GNU General Public License along
18+# with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19+# the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20+# Boston, MA 02110-1301, USA.
21+
22+#
23+# Reproducible Build に対応した OpenTween.XmlSerializers.dll の生成を行うスクリプト
24+#
25+# 使い方:
26+# .\tools\generate-serializer.ps1 -ExePath ".\OpenTween\bin\Debug\OpenTween.exe" -SgenOpts "/type:OpenTween.SettingCommon"
27+#
28+
29+Param(
30+ [Parameter(Mandatory = $true)][String] $ExePath,
31+ [String] $SgenOpts = ""
32+)
33+
34+Set-StrictMode -Version 3.0
35+$ErrorActionPreference = 'Stop'
36+
37+$binDir = Split-Path -Parent $ExePath
38+$exeName = Split-Path -Leaf $ExePath
39+
40+$dllName = $exeName -replace "\.exe$", ".XmlSerializers.dll"
41+$dllPath = Join-Path $binDir $dllName
42+
43+. .\tools\functions.ps1
44+
45+Function Generate-Serializer() {
46+ $tempDirName = "temp"
47+ $tempDir = Join-Path $binDir $tempDirName
48+ $tempExePath = Join-Path $tempDir $exeName
49+
50+ # sgen は *.exe と同じディレクトリにソースコードを書き出すため、作業用のディレクトリを用意してビルドを実行する
51+ Remove-Item -Recurse $tempDir -ErrorAction Ignore
52+ New-Item -ItemType "directory" -Path $binDir -Name $tempDirName | Out-Null
53+ Copy-Item $ExePath -Destination $tempDir
54+
55+ # sgen が実行する C# コンパイラは Roslyn ではないため /deterministic オプションに対応していない。
56+ # sgen の /keep オプションによってソースコードと csc に渡すコマンドラインオプションが書き出されるため、これを使用して改めて Roslyn でコンパイルし直す
57+ Invoke-NativeCommand "sgen /nologo /silent /keep $SgenOpts $tempExePath"
58+ $cmdlinePath = Join-Path $tempDir "*.cmdline"
59+ Invoke-NativeCommand "csc -nologo -warn:1 -deterministic $(Get-Content $cmdlinePath)"
60+
61+ Copy-Item $(Join-Path $tempDir $dllName) -Destination $binDir
62+ Remove-Item -Recurse $tempDir
63+}
64+
65+Generate-Serializer
Show on old repository browser