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

@ -1,6 +1,31 @@
#!/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
tar -zcvf SourceGit.linux-x64.tar.gz --exclude="*/*.dbg" SourceGit
rm -rf SourceGit
mv SourceGit/SourceGit SourceGit/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