From 77e05b0c9518d7537e0937a0d01ae90c245e8afb Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Sun, 20 Mar 2022 13:16:04 +0100 Subject: [PATCH] prepare for releases --- .github/FUNDING.yml | 3 +- .github/workflows/build-deb-package.yml | 50 ------------------- .../{fastfetch-check.yml => push.yml} | 17 ++++++- CMakeLists.txt | 25 ++-------- README.md | 2 +- packaging/deb/control-template | 2 +- packaging/deb/create-deb-pkg.sh | 27 ---------- packaging/deb/create.sh | 28 +++++++++++ src/fastfetch.c | 2 +- 9 files changed, 52 insertions(+), 104 deletions(-) delete mode 100644 .github/workflows/build-deb-package.yml rename .github/workflows/{fastfetch-check.yml => push.yml} (77%) delete mode 100755 packaging/deb/create-deb-pkg.sh create mode 100755 packaging/deb/create.sh diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index cfd560d2f..b2a9ae331 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1 @@ -custom: - - paypal.me/linusdierheimer +custom: paypal.me/linusdierheimer diff --git a/.github/workflows/build-deb-package.yml b/.github/workflows/build-deb-package.yml deleted file mode 100644 index cfe7d9485..000000000 --- a/.github/workflows/build-deb-package.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: CMake - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - -on: - workflow_dispatch: - -jobs: - build: - # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. - # You can convert this to a matrix build if you need cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - # Install dependencies, so that CMake enables all modules - - name: install packages - run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libxfconf-0-dev librpm-dev libzstd-dev - - # Kick off the debian packaging - - name: Create deb package - working-directory: ${{github.workspace}}/packaging/deb - run: sh ./create-deb-pkg.sh - - - # Create a release draft with the fastfetch.deb file - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Debian package for ${{ github.sha }} - draft: true - prerelease: false - - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{github.workspace}}/packaging/deb/fastfetch.deb - asset_name: fastfetch.deb - asset_content_type: application/vnd.debian.binary-package diff --git a/.github/workflows/fastfetch-check.yml b/.github/workflows/push.yml similarity index 77% rename from .github/workflows/fastfetch-check.yml rename to .github/workflows/push.yml index 305e7ce15..b11a49930 100644 --- a/.github/workflows/fastfetch-check.yml +++ b/.github/workflows/push.yml @@ -10,7 +10,7 @@ env: BUILD_TYPE: Release jobs: - default: + check: name: Build, Run and Analyze fastfetch runs-on: ubuntu-latest permissions: @@ -50,3 +50,18 @@ jobs: - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 + + - name: Build deb package + run: sh packaging/deb/create.sh . + + - name: Upload binary + uses: actions/upload-artifact@v2 + with: + name: fastfetch + path: ./fastfetch + + - name: Upload deb package + uses: actions/upload-artifact@v2 + with: + name: fastfetch.deb + path: ./packaging/deb/fastfetch.deb diff --git a/CMakeLists.txt b/CMakeLists.txt index d7f434648..01a36899c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.1.0) # Threads::Threads -project(fastfetch LANGUAGES C) +project(fastfetch + VERSION 0.1.0 + LANGUAGES C +) include(GNUInstallDirs) @@ -25,26 +28,6 @@ endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-O3") -set(PROJECT_VERSION "r0.0" CACHE STRING "Full version") -set(PROJECT_VERSION_MAJOR "0" CACHE STRING "Major version") -if (EXISTS "${CMAKE_SOURCE_DIR}/.git") - execute_process( - COMMAND git rev-list --count HEAD - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - OUTPUT_VARIABLE GIT_REV_LIST - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - execute_process( - COMMAND git rev-parse --short HEAD - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - OUTPUT_VARIABLE GIT_REV_PARSE - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - set(PROJECT_VERSION "r${GIT_REV_LIST}.${GIT_REV_PARSE}") - set(PROJECT_VERSION_MAJOR "${GIT_REV_LIST}") -endif() - function(fastfetch_load_text FILENAME OUTVAR) file(READ "${FILENAME}" TEMP) string(REPLACE "\n" "\\n" TEMP "${TEMP}") diff --git a/README.md b/README.md index 52bc00828..7b2867bf4 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ If pkg-config fails to find the headers for a library listed in [dependencies](# * [AUR](https://aur.archlinux.org/packages/fastfetch-git/): Packaged by me. Will install the fastfetch binary, bash completion and the presets. Git version * [Manjaro Repositories](https://gitlab.manjaro.org/packages/community/fastfetch): Packaged by a manjaro maintainer. Usually a bit outdated. * [Gentoo (Guru)](https://github.com/gentoo/guru/tree/master/app-misc/fastfetch): Packed by some other guy. May be out of date some times. -* DEB: You need to build deb packages yourself. Run [`packaging/deb/create-deb-pkg.sh`](packaging/deb/create-deb-pkg.sh) for that. +* DEB: Run [`packaging/deb/create.sh`](packaging/deb/create.sh) from the root directory. You can give a custom build directory as an argument. * Manually: * Build: Follow the [build instructions](#building). * Install: `sudo cmake --install build --prefix /usr/local` diff --git a/packaging/deb/control-template b/packaging/deb/control-template index c0a92a103..a87431715 100644 --- a/packaging/deb/control-template +++ b/packaging/deb/control-template @@ -3,7 +3,7 @@ Version: Section: utils Priority: extra Architecture: amd64 -Maintainer: peter@bohner.me +Maintainer: Linus@Dierheimer.de Homepage: https://github.com/LinusDierheimer/fastfetch Installed-Size: 410K Description: A fast alternative to neofetch diff --git a/packaging/deb/create-deb-pkg.sh b/packaging/deb/create-deb-pkg.sh deleted file mode 100755 index 1f7eb87c0..000000000 --- a/packaging/deb/create-deb-pkg.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -cd "$(dirname "$0")" || exit -echo "cleanup" -rm -rf ./build ./fastfetch fastfetch.deb - -echo "building fastfetch" -mkdir build -cd build || exit 1 -cmake ../../.. || exit 1 -cmake --build . --target fastfetch "-j$(nproc)" || exit 1 - -echo "generating package contents" -# deb versions must start with a number, hence the 1 added before the rXXX -version="0:1$(./fastfetch --version | cut -d ' ' -f2)-0" -echo "Using package version: $version" -cd .. - -cmake --install build --prefix fastfetch/usr || exit 1 -mkdir -p fastfetch/DEBIAN -sed "s//$version/g" control-template > fastfetch/DEBIAN/control - -echo "building package" -dpkg-deb --build fastfetch || exit 1 -echo "package built." -echo "cleaning up" -rm -rf build fastfetch diff --git a/packaging/deb/create.sh b/packaging/deb/create.sh new file mode 100755 index 000000000..2314ca808 --- /dev/null +++ b/packaging/deb/create.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# This script is intended to be run from the root of the repository. +# If you don't want to use build/ as build directoy, or already build the elsewere, you can give the build directoy as argument. + +BUILD_DIR="${1:-build}" +ROOT_DIR="${2:-.}" +PACKAGE_DIR="${BUILD_DIR}/packaging/deb/fastfetch" + +# Create missing files +mkdir -p "${BUILD_DIR}" || exit 1 + +if [ ! -f "${BUILD_DIR}/cmake_install.cmake" ]; then + cmake -S "${ROOT_DIR}" -B "${BUILD_DIR}" || exit 2 + rm -f "${BUILD_DIR}/fastfetch" || exit 3 # Always rebuild the project if we reconfigured it +fi + +if [ ! -f "${BUILD_DIR}/fastfetch" ]; then + cmake --build "${BUILD_DIR}" || exit 4 +fi + +# Populate the files +cmake --install "${BUILD_DIR}" --prefix "${PACKAGE_DIR}/usr" || exit 5 +mkdir -p "${PACKAGE_DIR}/DEBIAN" || exit 6 +sed "s//$("${BUILD_DIR}/fastfetch" --version)/g" "${ROOT_DIR}/packaging/deb/control-template" > "${PACKAGE_DIR}/DEBIAN/control" || exit 7 + +# Create the package +dpkg-deb --build "${PACKAGE_DIR}" || exit 8 diff --git a/src/fastfetch.c b/src/fastfetch.c index 96f5a4bd4..78a3db22a 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -613,7 +613,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con } else if(strcasecmp(key, "-v") == 0 || strcasecmp(key, "--version") == 0) { - puts(FASTFETCH_PROJECT_NAME" "FASTFETCH_PROJECT_VERSION); + puts(FASTFETCH_PROJECT_VERSION); exit(0); } else if(strcasecmp(key, "--list-logos") == 0)