refactor: rewrite all build scripts

* supports generate rpm package on Linux
* use a global VERSION file
This commit is contained in:
leo 2024-04-16 17:29:36 +08:00
parent de5a60c6dd
commit 7f7e5ef5f8
11 changed files with 102 additions and 54 deletions

View file

@ -37,11 +37,11 @@ You can download the latest stable from [Releases](https://github.com/sourcegit-
For **Windows** users: For **Windows** users:
* **MSYS Git is NOT supported**. Please use official [Git for Windows](https://git-scm.com/download/win) instead. * **MSYS Git is NOT supported**. Please use official [Git for Windows](https://git-scm.com/download/win) instead.
* `Source.win-x64.zip` may be reported as virus by Windows Defender. I don't know why. I have manually tested the zip to be uploaded using Windows Defender before uploading and no virus was found. If you have installed .NET 8 SDK locally, I suggest you to compile it yourself. And if you have any idea about how to fix this, please open an issue. * `sourcegit_x.y.win-x64.zip` may be reported as virus by Windows Defender. I don't know why. I have manually tested the zip to be uploaded using Windows Defender before uploading and no virus was found. If you have installed .NET 8 SDK locally, I suggest you to compile it yourself. And if you have any idea about how to fix this, please open an issue.
For **macOS** users: For **macOS** users:
* Download `SourceGit.osx-x64.zip` or `SourceGit.osx-arm64.zip` from Releases. `x64` for Intel and `arm64` for Apple Silicon. * Download `sourcegit_x.y.osx-x64.zip` or `sourcegit_x.y.osx-arm64.zip` from Releases. `x64` for Intel and `arm64` for Apple Silicon.
* Move `SourceGit.app` to `Applications` folder. * Move `SourceGit.app` to `Applications` folder.
* Make sure your mac trusts all software from anywhere. For more information, search `spctl --master-disable`. * Make sure your mac trusts all software from anywhere. For more information, search `spctl --master-disable`.
* Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your mac. * Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your mac.

1
build/VERSION Normal file
View file

@ -0,0 +1 @@
8.8

View file

@ -1,14 +0,0 @@
#!/bin/sh
rm -rf SourceGit resources/deb/opt *.deb
dotnet publish ../src/SourceGit.csproj -c Release -r linux-x64 -o SourceGit -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained
mkdir -p resources/deb/opt/sourcegit
mv SourceGit/SourceGit resources/deb/opt/sourcegit/sourcegit
mv SourceGit/*.so resources/deb/opt/sourcegit/
chmod -R 755 resources/deb
rm -rf SourceGit
sudo dpkg-deb --build resources/deb ./sourcegit_8.8_amd64.deb

View file

@ -1,6 +1,31 @@
#!/bin/sh #!/bin/sh
rm -rf SourceGit SourceGit.linux-x64.tar.gz version=`cat ./VERSION`
# Cleanup
rm -rf SourceGit *.tar.gz resources/deb/opt *.deb *.rpm
# Compile
dotnet publish ../src/SourceGit.csproj -c Release -r linux-x64 -o SourceGit -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained dotnet publish ../src/SourceGit.csproj -c Release -r linux-x64 -o SourceGit -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained
tar -zcvf SourceGit.linux-x64.tar.gz --exclude="*/*.dbg" SourceGit mv SourceGit/SourceGit SourceGit/sourcegit
rm -rf SourceGit rm -f SourceGit/*.dbg
# General Linux archive
tar -zcvf sourcegit_${version}.linux-x64.tar.gz SourceGit
# Debain/Ubuntu package
mkdir -p resources/deb/opt/sourcegit/
mkdir -p resources/deb/usr/bin
mkdir -p resources/deb/usr/share/applications
mkdir -p resources/deb/usr/share/icons
cp -f SourceGit/* resources/deb/opt/sourcegit/
cp -r resources/_common/usr resources/deb/
chmod -R 755 resources/deb
sed -i "2s/.*/Version: ${version}/g" resources/deb/DEBIAN/control
dpkg-deb --build resources/deb ./sourcegit_${version}-1_amd64.deb
# Redhat/CentOS/Fedora package
rpmbuild -bb --target=x86_64 resources/rpm/SPECS/build.spec --define "_topdir `pwd`/resources/rpm" --define "_version ${version}"
mv resources/rpm/RPMS/x86_64/sourcegit-${version}-1.x86_64.rpm .
rm -rf SourceGit

View file

@ -1,17 +1,22 @@
#!/bin/sh #!/bin/sh
rm -rf SourceGit.app version=`cat ./VERSION`
rm -rf SourceGit.app *.zip
mkdir -p SourceGit.app/Contents/Resources mkdir -p SourceGit.app/Contents/Resources
cp resources/App.plist SourceGit.app/Contents/Info.plist cp resources/app/App.plist SourceGit.app/Contents/Info.plist
cp resources/App.icns SourceGit.app/Contents/Resources/App.icns cp resources/app/App.icns SourceGit.app/Contents/Resources/App.icns
sed -i "s/SOURCE_GIT_VERSION/${version}/g" SourceGit.app/Contents/Info.plist
mkdir -p SourceGit.app/Contents/MacOS mkdir -p SourceGit.app/Contents/MacOS
dotnet publish ../src/SourceGit.csproj -c Release -r osx-arm64 -o SourceGit.app/Contents/MacOS -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained dotnet publish ../src/SourceGit.csproj -c Release -r osx-arm64 -o SourceGit.app/Contents/MacOS -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained
zip SourceGit.osx-arm64.zip -r SourceGit.app -x "*/*\.dsym/*" zip sourcegit_${version}.osx-arm64.zip -r SourceGit.app -x "*/*\.dsym/*"
rm -rf SourceGit.app/Contents/MacOS rm -rf SourceGit.app/Contents/MacOS
mkdir -p SourceGit.app/Contents/MacOS mkdir -p SourceGit.app/Contents/MacOS
dotnet publish ../src/SourceGit.csproj -c Release -r osx-x64 -o SourceGit.app/Contents/MacOS -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained dotnet publish ../src/SourceGit.csproj -c Release -r osx-x64 -o SourceGit.app/Contents/MacOS -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained
zip SourceGit.osx-x64.zip -r SourceGit.app -x "*/*\.dsym/*" zip sourcegit_${version}.osx-x64.zip -r SourceGit.app -x "*/*\.dsym/*"
rm -rf SourceGit.app

View file

@ -1,13 +1,13 @@
$version = Get-Content .\VERSION
if (Test-Path SourceGit) { if (Test-Path SourceGit) {
Remove-Item SourceGit -Recurse -Force Remove-Item SourceGit -Recurse -Force
} }
if (Test-Path SourceGit.win-x64.zip) { Remove-Item *.zip -Force
Remove-Item SourceGit.win-x64.zip -Force
}
dotnet publish ..\src\SourceGit.csproj -c Release -r win-x64 -o SourceGit -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained dotnet publish ..\src\SourceGit.csproj -c Release -r win-x64 -o SourceGit -p:PublishAot=true -p:PublishTrimmed=true -p:TrimMode=link --self-contained
Remove-Item SourceGit\*.pdb -Force Remove-Item SourceGit\*.pdb -Force
Compress-Archive -Path SourceGit -DestinationPath SourceGit.win-x64.zip Compress-Archive -Path SourceGit -DestinationPath "sourcegit_$version.win-x64.zip"

View file

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View file

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>App.icns</string> <string>App.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.sourcegit-scm.sourcegit</string> <string>com.sourcegit-scm.sourcegit</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>SourceGit</string> <string>SourceGit</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>8.8.0</string> <string>SOURCE_GIT_VERSION.0</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>10.12</string> <string>10.12</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>SourceGit</string> <string>SourceGit</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>8.8</string> <string>SOURCE_GIT_VERSION</string>
<key>NSHighResolutionCapable</key> <key>NSHighResolutionCapable</key>
<true/> <true/>
</dict> </dict>
</plist> </plist>

View file

@ -0,0 +1,31 @@
Name: sourcegit
Version: %_version
Release: 1
Summary: Open-source & Free Git Gui Client
License: MIT
URL: https://sourcegit-scm.github.io/
Source: https://github.com/sourcegit-scm/sourcegit/archive/refs/tags/v%_version.tar.gz
Requires: libX11.so.6
Requires: libSM.so.6
%define _build_id_links none
%description
Open-source & Free Git Gui Client
%install
mkdir -p $RPM_BUILD_ROOT/opt/sourcegit
mkdir -p $RPM_BUILD_ROOT/usr/bin
mkdir -p $RPM_BUILD_ROOT/usr/share/applications
mkdir -p $RPM_BUILD_ROOT/usr/share/icons
cp -r ../../_common/usr $RPM_BUILD_ROOT/
cp -f ../../../SourceGit/* $RPM_BUILD_ROOT/opt/sourcegit/
chmod 755 -R $RPM_BUILD_ROOT
%files
/opt
/usr/bin
/usr/share
%changelog
# skip