Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
WIP: Updated builders to use GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Aug 7, 2024
1 parent 668dae2 commit 7979bd2
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 195 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Build
on: pull_request # TODO: Only run on workflow_dispatch
jobs:
build:
strategy:
matrix:
os: [windows-latest] # TODO: Run all [macos-12, ubuntu-latest, windows-latest] COMPLETED: [ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Check out SimpleFC repository (Windows)
if: matrix.os == 'windows-latest'
uses: actions/checkout@v4
with:
repository: mazinsw/SimpleFC
- name: Build SimpleFC NSIS Plugin (Windows)
if: matrix.os == 'windows-latest'
run: |
copy "bin\x86-unicode\SimpleFC.dll" "C:\Program Files (x86)\NSIS\Plugins\x86-unicode\SimpleFC.dll"
- name: Check out nsProcess repository (Windows)
if: matrix.os == 'windows-latest'
uses: actions/checkout@v4
with:
repository: simdsoft/nsProcess
submodules: 'true'
- name: Add msbuild to PATH (Windows)
if: matrix.os == 'windows-latest'
uses: microsoft/setup-msbuild@v2
- name: Build nsProcess NSIS Plugin (Windows)
if: matrix.os == 'windows-latest'
run: |
cd nsProcess
msbuild nsProcess.vcxproj /p:PlatformToolset=v143 /p:Configuration="Release UNICODE"
copy "Release UNICODE\nsProcess.dll" "C:\Program Files (x86)\NSIS\Plugins\x86-unicode\nsProcess.dll"
cd ../Include
copy nsProcess.nsh "C:\Program Files (x86)\NSIS\Include\nsProcess.nsh"
- name: Check-out repository
uses: actions/checkout@v4
with:
submodules: 'true'
fetch-tags: 'true'
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
**/requirements-build.txt
- name: Install Dependencies
run: |
pip install --upgrade -r requirements-build.txt
- name: Setup npm
uses: actions/setup-node@v4
- name: Build npm
run: |
cd src/tribler/ui/
npm install
npm run build
- name: Determine tag
run: |
git fetch --tags
git for-each-ref --count=1 --sort=-creatordate --format '%(refname)' refs/tags > raw_tag.txt
echo "GITHUB_TAG=$(git name-rev --tags --name-only $(cat raw_tag.txt))" >> $GITHUB_ENV
- name: Prepare version
shell: python
env:
GITHUB_REF: ${{ vars.GITHUB_SHA }}
GITHUB_TAG: ${{ env.GITHUB_TAG }}
run: |
# TODO: The environment variables should be used instead of version.py, this "Prepare version" step can be deleted then.
from os import getenv
from time import ctime
print(f'Writing version ({getenv("GITHUB_SHA")}, {getenv("GITHUB_TAG")})')
with open("src/tribler/core/version.py", "w") as version_py:
version_py.write(f'version_id = "{getenv("GITHUB_TAG")}"\n')
version_py.write(f'build_date = "{ctime()}"\n')
version_py.write(f'commit_id = "{getenv("GITHUB_SHA")}"\n')
- name: Build Executables (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y --allow-downgrades alien cpio=2.13+dfsg-7 devscripts fakeroot gir1.2-gtk-4.0 rpm
./build/debian/makedist_debian.sh
- name: Build Executables (MacOS-12)
if: matrix.os == 'macos-12'
run: |
./build/mac/makedist_macos.sh
- uses: actions/cache/restore@v4
if: matrix.os == 'windows-latest'
id: restore_cache
with:
path: src/libsodium.dll
key: cache_libsodium_dll
- name: Build Executables (Windows)
if: matrix.os == 'windows-latest'
run: |
./build/win/makedist_win.bat
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }} Build
path: |
build/*
dist/*
#build/debian/*.deb
28 changes: 4 additions & 24 deletions build/debian/makedist_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,15 @@
set -x # print all commands
set -e # exit when any command fails

LOG_LEVEL=${LOG_LEVEL:-"DEBUG"}

if [[ ! -d build/debian ]]; then
echo "Please run this script from project root as:\n./build/debian/makedist_debian.sh"
fi

rm -rf build/tribler
rm -rf dist/tribler
rm -rf build/debian/tribler/usr/share/tribler

if [ ! -z "$VENV" ]; then
echo "Setting venv to $VENV"
source $VENV/bin/activate
else
echo "Creating a new venv"
python3 -m venv build-env
. ./build-env/bin/activate
fi

# ----- Install dependencies before the build
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade -r requirements-build.txt
python3 -m pip install --upgrade PyGObject

# ----- Update version
python3 ./build/update_version.py -r .
python3 ./build/debian/update_metainfo.py -r .
python3 ./build/debian/update_metainfo.py

# ----- Build UI
pushd .
Expand All @@ -37,18 +20,15 @@ npm run build
popd

# ----- Build binaries
echo Building Tribler using Cx_Freeze
python3 setup.py build

# ----- Build dpkg
cp -r ./dist/tribler ./build/debian/tribler/usr/share/tribler

TRIBLER_VERSION=$(head -n 1 .TriblerVersion) # read the first line only

# Compose the changelog
cd ./build/debian/tribler

dch -v $TRIBLER_VERSION "New release"
dch -v $TRIBLER_VERSION "See https://github.com/Tribler/tribler/releases/tag/$TRIBLER_VERSION for more info"
dch -v $GITHUB_TAG "New release"
dch -v $GITHUB_TAG "See https://github.com/Tribler/tribler/releases/tag/$GITHUB_TAG for more info"

dpkg-buildpackage -b -rfakeroot -us -uc
49 changes: 12 additions & 37 deletions build/debian/update_metainfo.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
import logging
import time
import xml.etree.ElementTree as xml
from argparse import ArgumentParser
from pathlib import Path

import defusedxml.ElementTree as defxml

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)


def parse_arguments():
parser = ArgumentParser(description='Update Tribler metainfo.xml')
parser.add_argument('-r', '--repo', type=str, help='path to a repository folder', default='.')
return parser.parse_args()


if __name__ == '__main__':
arguments = parse_arguments()

version = Path('.TriblerVersion').read_text().lstrip('v').rstrip('\n')

release_info = {
'version': version,
'date': time.strftime("%Y-%m-%d", time.localtime())
}

logger.info(f'Release info: {release_info}')
metainfo_xml = Path(arguments.repo) / 'build/debian/tribler/usr/share/metainfo/org.tribler.Tribler.metainfo.xml'

xml_dom = defxml.parse(metainfo_xml)
releases = xml_dom.getroot().find('releases')
release = xml.SubElement(releases, 'release', release_info)

xml_dom.write(metainfo_xml, encoding='utf-8', xml_declaration=True)
logger.info(f'Content of metainfo.xml: {metainfo_xml.read_text()}')
from os import getenv
from time import localtime, strftime
from xml.etree.ElementTree import SubElement, parse

if __name__ == "__main__":
metainfo_xml = "build/debian/tribler/usr/share/metainfo/org.tribler.Tribler.metainfo.xml"
tree = parse(metainfo_xml)
root = tree.getroot()
releases_tag = root.find("releases")
releases_tag.append(SubElement(releases_tag, "release", {"version": getenv("GITHUB_TAG"),
"date": strftime("%Y-%m-%d", localtime())}))
tree.write(metainfo_xml, encoding="utf-8", xml_declaration=True)
47 changes: 0 additions & 47 deletions build/update_version.py

This file was deleted.

1 change: 0 additions & 1 deletion build/win/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def get_freeze_build_options():
included_files = [
("src/tribler/ui/public", "lib/tribler/ui/public"),
("src/tribler/ui/dist", "lib/tribler/ui/dist"),

("src/tribler/core", "tribler_source/tribler/core"),
("src/tribler/ui/public", "tribler_source/tribler/ui/public"),
("src/tribler/ui/dist", "tribler_source/tribler/ui/dist"),
Expand Down
2 changes: 0 additions & 2 deletions build/win/clean.bat

This file was deleted.

22 changes: 2 additions & 20 deletions build/win/makedist_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ REM ----- Clean up

call build\win\clean.bat

REM ----- Prepare venv & install dependencies before the build
if defined VENV (
call "%VENV%\Scripts\activate.bat"
) else (
echo VENV environment variable is not set. Skipping.
)

call python3 -m pip install --upgrade pip
call python3 -m pip install --upgrade -r requirements-build.txt

Expand All @@ -45,12 +38,6 @@ popd

REM ----- Build

REM Arno: When adding files here, make sure tribler.nsi actually
REM packs them in the installer .EXE

ECHO Install pip dependencies for correct py-installer's work
call python3 -m pip install --upgrade -r build\win\requirements.txt

REM Sandip 2024-03-22: Deprecated, we are not using PyInstaller anymore because of issue with False Malware detections.
REM %PYTHONHOME%\Scripts\pyinstaller.exe tribler.spec --log-level=%LOG_LEVEL% || exit /b
ECHO Building Tribler using Cx_Freeze
Expand All @@ -64,15 +51,10 @@ REM copy Tribler\Main\Build\Win\tribler.exe.manifest dist\tribler
mkdir dist\tribler\tools
copy build\win\tools\reset*.bat dist\tribler\tools

REM Laurens, 2016-04-20: Copy the redistributables of 2008, 2012 and 2015 to the install dir
REM Sandip, 2019-10-24: redistributables 2008, 2012 are not necessary anymore
REM copy C:\build\vc_redist_110.exe dist\tribler
copy C:\build\vc_redist_140.exe dist\tribler

REM Copy various libraries required on runtime (libsodium and openssl)
copy C:\build\libsodium.dll dist\tribler\lib
move src\libsodium.dll dist\tribler\lib
REM Sandip, 2024-03-26: Some openssl dlls are missing so need to be copied manually.
copy C:\build\openssl\*.dll dist\tribler\lib
copy C:\Program Files\OpenSSL\*.dll dist\tribler\lib


@echo Running NSIS
Expand Down
32 changes: 0 additions & 32 deletions build/win/replace_nsi.py

This file was deleted.

4 changes: 0 additions & 4 deletions build/win/requirements.txt

This file was deleted.

17 changes: 7 additions & 10 deletions build/win/resources/tribler.nsi
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
!define PRODUCT "Tribler"
; Laurens, 2016-03-14: The __GIT__ string will be replaced by update_version_from_git.py
; with the current version of the build.
!define VERSION "__GIT__"
; Laurens, 2016-03-14: The _x86 will be replaced by _x64 if needed in update_version_from_git.py
!define VERSION $%GITHUB_TAG%
!define BITVERSION "x86"

!include "MUI2.nsh"
Expand Down Expand Up @@ -122,14 +119,16 @@ Section "!Main EXE" SecMain
; ExecWait "$INSTDIR\vc_redist_110.exe /q /norestart"

; Libraries dependant on 2015 are: Python, Qt5
File vc_redist_140.exe
ExecWait "$INSTDIR\vc_redist_140.exe /q /norestart"
File "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\v143\vc_redist.x64.exe"
ExecWait "$INSTDIR\vc_redist.x64.exe /q /norestart"

FileOpen $9 "$INSTDIR\tribler.exe.log" w
FileWrite $9 ""
FileClose $9
AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(BU)" "FullAccess"
AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(S-1-5-32-545)" "FullAccess"
Exec 'icacls "$INSTDIR\tribler.exe.log" /grant *BU:F'
#AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(BU)" "FullAccess"
Exec 'icacls "$INSTDIR\tribler.exe.log" /grant *S-1-5-32-545:F'
#AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(S-1-5-32-545)" "FullAccess"

; End
SetOutPath "$INSTDIR"
Expand Down Expand Up @@ -199,9 +198,7 @@ SectionEnd
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesk} $(DESC_SecDesk)
!insertmacro MUI_DESCRIPTION_TEXT ${SecStart} $(DESC_SecStart)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultTorrent} $(DESC_SecDefaultTorrent)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultTStream} $(DESC_SecDefaultTStream)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultMagnet} $(DESC_SecDefaultMagnet)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultPpsp} $(DESC_SecDefaultPpsp)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------
Expand Down
Loading

0 comments on commit 7979bd2

Please sign in to comment.