From ab83202358fabb033918efde5ede24ccd896fc50 Mon Sep 17 00:00:00 2001 From: JuanLeon Lahoz Date: Tue, 20 Sep 2022 18:27:37 +0200 Subject: [PATCH] Add ARM based binaries and debian packages to releases --- .github/workflows/release.yml | 126 +++++++++++++++++++++++++++++++--- CHANGELOG.md | 7 ++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 11 ++- 5 files changed, 136 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd88e71..993e1eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: push: # The idea here is to trigger a release upon receiving a release-like tag tags: - - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+' env: CICD_INTERMEDIATES_DIR: "_cicd-intermediates" @@ -19,20 +19,31 @@ jobs: fail-fast: false matrix: job: - - { os: ubuntu-18.04, target: x86_64-unknown-linux-gnu } - - { os: ubuntu-18.04, target: i686-unknown-linux-gnu, use-cross: true } - - { os: ubuntu-18.04, target: i686-unknown-linux-musl, use-cross: true } - - { os: ubuntu-18.04, target: x86_64-unknown-linux-musl, use-cross: true } - - { os: macos-10.15 , target: x86_64-apple-darwin } + - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu } + - { os: ubuntu-22.04, target: arm-unknown-linux-gnueabihf, use-cross: true } + - { os: ubuntu-22.04, target: arm-unknown-linux-musleabihf, use-cross: true } + - { os: ubuntu-22.04, target: i686-unknown-linux-gnu, use-cross: true } + - { os: ubuntu-22.04, target: i686-unknown-linux-musl, use-cross: true } + - { os: ubuntu-22.04, target: x86_64-unknown-linux-musl, use-cross: true } + - { os: macos-11, target: x86_64-apple-darwin } steps: - name: Checkout source code uses: actions/checkout@v2 + - name: Install prerequisites + shell: bash + run: | + case ${{ matrix.job.target }} in + arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; + esac + - name: Extract crate information shell: bash run: | echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV - echo "PROJECT_VERSION=v$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV + echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV + echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV + echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -63,22 +74,37 @@ jobs: id: strip shell: bash run: | + STRIP="strip" + case ${{ matrix.job.target }} in + arm-unknown-*) STRIP="arm-linux-gnueabihf-strip" ;; + esac; + BIN_DIR="${{ env.CICD_INTERMEDIATES_DIR }}/stripped-release-bin" mkdir -p "${BIN_DIR}" BIN_NAME="${{ env.PROJECT_NAME }}" BIN_PATH="${BIN_DIR}/${BIN_NAME}" # Copy the release build binary to the result location cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "${BIN_DIR}" - strip "${BIN_PATH}" + "${STRIP}" "${BIN_PATH}" # Let subsequent steps know where to find the (stripped) bin echo ::set-output name=BIN_PATH::${BIN_PATH} + echo ::set-output name=BIN_NAME::${BIN_NAME} + + - name: Set testing options + id: test-options + shell: bash + run: | + # test only library unit tests and binary for arm-type targets + unset CARGO_TEST_OPTIONS + case ${{ matrix.job.target }} in arm-*-*) CARGO_TEST_OPTIONS="--lib --bin ${PROJECT_NAME}" ;; esac; + echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS} - name: Run tests uses: actions-rs/cargo@v1 with: use-cross: ${{ matrix.job.use-cross }} command: test - args: --target=${{ matrix.job.target }} -- --test-threads 1 + args: --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}} -- --test-threads 1 - name: Create tarball id: package @@ -97,6 +123,80 @@ jobs: # Let subsequent steps know where to find the compressed package echo ::set-output name=PKG_PATH::"${PKG_STAGING}/${PKG_NAME}" + - name: Create Debian package + id: debian-package + shell: bash + if: contains(matrix.job.target, 'musl') + run: | + DPKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/debian-package" + DPKG_DIR="${DPKG_STAGING}/dpkg" + mkdir -p "${DPKG_DIR}" + DPKG_BASENAME=${PROJECT_NAME} + DPKG_VERSION=${PROJECT_VERSION} + unset DPKG_ARCH + case ${{ matrix.job.target }} in + arm-*-linux-*hf) DPKG_ARCH=armhf ;; + i686-*-linux-*) DPKG_ARCH=i686 ;; + x86_64-*-linux-*) DPKG_ARCH=amd64 ;; + *) DPKG_ARCH=notset ;; + esac; + DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" + echo ::set-output name=DPKG_NAME::${DPKG_NAME} + # Binary + install -Dm755 "${{ steps.strip.outputs.BIN_PATH }}" "${DPKG_DIR}/usr/bin/${{ steps.strip.outputs.BIN_NAME }}" + # LICENSE + install -Dm644 LICENSE "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE" + install -Dm644 CHANGELOG.md "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog" + gzip -n --best "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog" + cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" < "${DPKG_DIR}/DEBIAN/control" <"] edition = "2018" description = "Tool to draw low-resolution graphs in terminal" diff --git a/README.md b/README.md index d5b22b3..50d8cf4 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,16 @@ $ cargo install --path . #### Via AUR -Arch-Linux users can install the [lowcharts](https://aur.archlinux.org/packages/lowcharts), [lowcharts-bin](https://aur.archlinux.org/packages/lowcharts-bin) or [lowcharts-git](https://aur.archlinux.org/packages/lowcharts-git) AUR package. +Arch-Linux users can install the +[lowcharts](https://aur.archlinux.org/packages/lowcharts), +[lowcharts-bin](https://aur.archlinux.org/packages/lowcharts-bin) or +[lowcharts-git](https://aur.archlinux.org/packages/lowcharts-git) AUR package. + +#### Via debian package + +If you are using a debian based Linux distribution, you may download a debian +file from https://github.com/juan-leon/lowcharts/releases/ for your +architecture. Then you can install it via `dpkg -i`. ### Using it as a library