Skip to content

Commit

Permalink
Upgrade to kubo. Create source archive code correctly with version. M…
Browse files Browse the repository at this point in the history
…ove to upper case options.
  • Loading branch information
melroy89 committed Feb 19, 2024
1 parent d3fcbdf commit 0d590e5
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 44 deletions.
17 changes: 12 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ variables:
doxygen:
stage: build
script:
- "./scripts/build-docs.sh"
- ./scripts/build-docs.sh
artifacts:
name: Doxygen
paths:
Expand All @@ -24,26 +24,28 @@ doxygen:
linux_build:
stage: build
script:
- "./scripts/build-lnx-prod.sh"
- ./scripts/build-lnx-prod.sh
- ./scripts/create_source_archive.sh
artifacts:
name: Packages
expire_in: 4 weeks
paths:
- build_prod/libreweb-browser-*.deb
- build_prod/libreweb-browser-*.rpm
- build_prod/libreweb-browser-*.tar.gz
- build_prod/libreweb-browser-source-*.tar.gz

static_code_analysis:
stage: build
script: "./scripts/cpp-check.sh"
script: ./scripts/cpp-check.sh

code_style_guidelines:
stage: build
script: "./scripts/check-format.sh"
script: ./scripts/check-format.sh

unit_test:
stage: test
script: "./scripts/build-run-tests.sh"
script: ./scripts/build-run-tests.sh

sast:
stage: test
Expand All @@ -66,6 +68,8 @@ upload_and_release:
${PACKAGE_REGISTRY_URL}/libreweb-browser-v${CI_COMMIT_TAG}.rpm'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file build_prod/libreweb-browser-v${CI_COMMIT_TAG}.tar.gz
${PACKAGE_REGISTRY_URL}/libreweb-browser-v${CI_COMMIT_TAG}.tar.gz'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file build_prod/libreweb-browser-source-v${CI_COMMIT_TAG}.tar.gz
${PACKAGE_REGISTRY_URL}/libreweb-browser-source-v${CI_COMMIT_TAG}.tar.gz'
- 'curl --header "PRIVATE-TOKEN: ${ACCESS_TOKEN}" --header "Content-Type: application/json"
--request POST --data "{\"name\":\"LibreWeb Browser (Compressed binary)\",\"url\":\"${PACKAGE_REGISTRY_URL}/libreweb-browser-v${CI_COMMIT_TAG}.tar.gz\",\"link_type\":\"package\"}"
${RELEASE_LINKS_URL}'
Expand All @@ -75,6 +79,9 @@ upload_and_release:
- 'curl --header "PRIVATE-TOKEN: ${ACCESS_TOKEN}" --header "Content-Type: application/json"
--request POST --data "{\"name\":\"LibreWeb Browser (Debian/Ubuntu/Linux Mint)\",\"url\":\"${PACKAGE_REGISTRY_URL}/libreweb-browser-v${CI_COMMIT_TAG}.deb\",\"link_type\":\"package\"}"
${RELEASE_LINKS_URL}'
- 'curl --header "PRIVATE-TOKEN: ${ACCESS_TOKEN}" --header "Content-Type: application/json"
--request POST --data "{\"name\":\"LibreWeb Browser Source Code Archive (tar.gz)\",\"url\":\"${PACKAGE_REGISTRY_URL}/libreweb-browser-source-v${CI_COMMIT_TAG}.tar.gz\",\"link_type\":\"package\"}"
${RELEASE_LINKS_URL}'
# Create new release
#release:
# stage: release
Expand Down
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.20)

option(DOXYGEN "Build Doxygen documentation" ON)
option(UNITTEST "Build unit tests")
option(PACKAGE "Build packages in release mode" OFF)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS deployment version")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
Expand All @@ -13,8 +14,10 @@ project(libreweb-browser
DESCRIPTION "LibreWeb Browser - Decentralized Web-Browser"
LANGUAGES C CXX)

message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}")
message(STATUS "Project version: ${PROJECT_VERSION}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Create packages: ${PACKAGE}")
message(STATUS "Generate documentation: ${DOXYGEN}")
if(UNITTEST)
message(STATUS "Building the unit tests")
endif()
Expand Down Expand Up @@ -44,7 +47,7 @@ elseif(UNIX)
endif()

# Production build, let's include the CPack settings
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND PACKAGE)
include(Packaging)
endif()

Expand All @@ -54,10 +57,10 @@ endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -pedantic -Werror=incompatible-pointer-types")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${WINDOWS_FLAGS} -O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${WINDOWS_FLAGS} -O2 -DNDEBUG")

# Disable CTest testcases & install in cpp-ipfs-http-client
set (BUILD_TESTING OFF CACHE BOOL "Disable CTest" FORCE)
Expand Down
Binary file added kubo/ipfs
Binary file not shown.
Binary file added kubo/ipfs-darwin
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/build-lnx-prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# First build the application for Linux
rm -rf build_prod
cmake -GNinja -DCMAKE_INSTALL_PREFIX:PATH=/usr -DDOXYGEN:BOOL=FALSE -DCMAKE_BUILD_TYPE=Release -B build_prod
cmake -GNinja -DCMAKE_INSTALL_PREFIX:PATH=/usr -DDOXYGEN:BOOL=FALSE -DPACKAGE=ON -DCMAKE_BUILD_TYPE=Release -B build_prod
cmake --build ./build_prod --config Release
# Build packages
cd build_prod
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-macos-prod.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# By: Melroy van den Berg
# Description: Build macOS 64-bit production release using Drag & Drop installer
cmake -GNinja -DDOXYGEN:BOOL=FALSE -DCMAKE_BUILD_TYPE=Release -B build_prod_macos
cmake -GNinja -DDOXYGEN:BOOL=FALSE -DPACKAGE=ON -DCMAKE_BUILD_TYPE=Release -B build_prod_macos
# TODO:
# cmake -G Xcode -DCODE_SIGN_IDENTITY="codesign ID..." -DDEVELOPMENT_TEAM_ID="team ID..."
# xcodebuild \
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-win-prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# By: Melroy van den Berg
# Description: Build Windows 64-bit production release
rm -rf build_prod_win
x86_64-w64-mingw32.static-cmake -GNinja -DDOXYGEN:BOOL=FALSE -DCMAKE_BUILD_TYPE=Release -B build_prod_win
x86_64-w64-mingw32.static-cmake -GNinja -DDOXYGEN:BOOL=FALSE -DPACKAGE=ON -DCMAKE_BUILD_TYPE=Release -B build_prod_win
x86_64-w64-mingw32.static-cmake --build ./build_prod_win --config Release
# Build packages
cd build_prod_win
Expand Down
13 changes: 13 additions & 0 deletions scripts/create_source_archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# By: Melroy van den Berg
# Description: Create custom source code archive with version.txt
# Depends on one environment variable: $CI_COMMIT_TAG

if [ -z ${CI_COMMIT_TAG} ]; then
echo "ERROR: CI_COMMIT_TAG env. variable is not set! Do not build archive. Exiting..."
exit 0
fi
# Create version.txt
echo -n "${CI_COMMIT_TAG}" > version.txt
# Create source archive (tar.gz)
git archive --format=tar.gz --output=build_prod/libreweb-browser-source-${CI_COMMIT_TAG}.tar.gz --add-file=version.txt HEAD
31 changes: 0 additions & 31 deletions scripts/get-ipfs.sh

This file was deleted.

31 changes: 31 additions & 0 deletions scripts/get-kubo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# By: Melroy van den Berg
# Description: Automatically download and unzip the IPFS CLI (Kubo) binaries for Linux & Windows

## Provide the Kubo version below ##
KUBO_VERSION=0.26.0

##############################
# Leave the code alone below #
##############################
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# Download & untar/zip Kubo
echo "INFO: Start downloading Kubo (v${KUBO_VERSION})..."
wget --quiet "https://dist.ipfs.tech/kubo/v${KUBO_VERSION}/kubo_v${KUBO_VERSION}_darwin-amd64.tar.gz" -O "$CURRENT_DIR/kubo_darwin.tar.gz"
wget --quiet "https://dist.ipfs.tech/kubo/v${KUBO_VERSION}/kubo_v${KUBO_VERSION}_linux-amd64.tar.gz" -O "$CURRENT_DIR/kubo_linux.tar.gz"
wget --quiet "https://dist.ipfs.tech/kubo/v${KUBO_VERSION}/kubo_v${KUBO_VERSION}_windows-amd64.zip" -O "$CURRENT_DIR/kubo_windows.zip"

# Extract on root level of the git repo
echo "INFO: Extracting Kubo..."
tar -xzf "$CURRENT_DIR/kubo_darwin.tar.gz" kubo/ipfs -C "$CURRENT_DIR/../"
# rename darwin binary
mv "$CURRENT_DIR/../kubo/ipfs" "$CURRENT_DIR/../kubo/ipfs-darwin"
tar -xzf "$CURRENT_DIR/kubo_linux.tar.gz" kubo/ipfs -C "$CURRENT_DIR/../"
unzip -q -o "$CURRENT_DIR/kubo_windows.zip" kubo/ipfs.exe -d "$CURRENT_DIR/../"

# Clean-up
echo "INFO: Clean up"
rm -rf "$CURRENT_DIR/kubo_darwin.tar.gz"
rm -rf "$CURRENT_DIR/kubo_linux.tar.gz"
rm -rf "$CURRENT_DIR/kubo_windows.zip"

0 comments on commit 0d590e5

Please sign in to comment.