From 573dd1d0ec0c05be88c6457219574896bfdc7d7a Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 4 May 2023 15:49:55 +0200 Subject: [PATCH] Github action for release --- .github/workflows/usbsas_release.yml | 71 ++++++++++++++++++++++++++++ Cargo.lock | 29 ++++++------ client/live-iso/.gitignore | 13 +++++ client/live-iso/Makefile | 31 ++---------- debian/Dockerfile | 26 ++++++++++ debian/Makefile | 52 ++++++++++++++++++++ 6 files changed, 181 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/usbsas_release.yml create mode 100644 client/live-iso/.gitignore create mode 100644 debian/Dockerfile create mode 100644 debian/Makefile diff --git a/.github/workflows/usbsas_release.yml b/.github/workflows/usbsas_release.yml new file mode 100644 index 00000000..6f780621 --- /dev/null +++ b/.github/workflows/usbsas_release.yml @@ -0,0 +1,71 @@ +name: usbsas release + +on: + push: + tags: + - "v*" + +env: + CARGO_TERM_COLOR: always + +jobs: + build-all: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Build packages and live ISO + run: | + cd debian && \ + docker build -t usbsas-builder:debian -f Dockerfile . && \ + docker run -t -u $(id -u):$(id -g) -v $(pwd)/../:/SRC \ + --env CARGO_HOME=/SRC/target/.cargo usbsas-builder:debian \ + make -C debian pkgs && \ + docker run -t --privileged -v $(pwd)/../:/SRC \ + --env CARGO_HOME=/SRC/target/.cargo usbsas-builder:debian \ + make SU= -C debian + - name: Upload deb packages + uses: actions/upload-artifact@v3 + with: + name: usbsas-deb-packages + path: ./target/debian/usbsas-*.deb + - name: Upload live ISO + uses: actions/upload-artifact@v3 + with: + name: usbsas-live-iso + path: ./client/live-iso/usbsas-*.iso + release: + name: Github release draft + needs: [build-all] + runs-on: ubuntu-latest + steps: + - name: Download usbsas deb packages + uses: actions/download-artifact@v3 + with: + name: usbsas-deb-packages + - name: Download usbsas live ISO + uses: actions/download-artifact@v3 + with: + name: usbsas-live-iso + - name: Get artifacts names + id: artifacts_names + run: | + echo "U_PKG_ASRV=$(ls usbsas-analyzer-server*.deb)" >> "$GITHUB_OUTPUT" && \ + echo "U_PKG_SRV=$(ls usbsas-server*.deb)" >> "$GITHUB_OUTPUT" && \ + echo "U_PKG_CORE=$(ls usbsas-core*.deb)" >> "$GITHUB_OUTPUT" && \ + echo "U_PKG_KIOSK=$(ls usbsas-kiosk*.deb)" >> "$GITHUB_OUTPUT" && \ + echo "U_PKG_HID=$(ls usbsas-hid*.deb)" >> "$GITHUB_OUTPUT" && \ + echo "U_ISO=$(ls usbsas-*.hybrid.iso)" >> "$GITHUB_OUTPUT" + - name: Create draft release + uses: softprops/action-gh-release@v1 + with: + draft: true + files: | + ${{ steps.artifacts_names.outputs.U_PKG_ASRV }} + ${{ steps.artifacts_names.outputs.U_PKG_SRV }} + ${{ steps.artifacts_names.outputs.U_PKG_CORE }} + ${{ steps.artifacts_names.outputs.U_PKG_KIOSK }} + ${{ steps.artifacts_names.outputs.U_PKG_HID }} + ${{ steps.artifacts_names.outputs.U_ISO }} diff --git a/Cargo.lock b/Cargo.lock index b9a2bf81..eb3c2205 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -619,7 +619,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" dependencies = [ - "nom 5.1.2", + "nom 5.1.3", ] [[package]] @@ -1519,7 +1519,7 @@ checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix 0.37.14", + "rustix 0.37.15", "windows-sys 0.48.0", ] @@ -1859,9 +1859,9 @@ dependencies = [ [[package]] name = "nom" -version = "5.1.2" +version = "5.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" dependencies = [ "memchr", "version_check", @@ -2385,9 +2385,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.14" +version = "0.37.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" +checksum = "a0661814f891c57c930a610266415528da53c4933e6dea5fb350cbfe048a9ece" dependencies = [ "bitflags 1.3.2", "errno", @@ -2724,7 +2724,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.14", + "rustix 0.37.15", "windows-sys 0.45.0", ] @@ -2825,9 +2825,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f" dependencies = [ "autocfg", "bytes", @@ -2838,7 +2838,7 @@ dependencies = [ "pin-project-lite", "signal-hook-registry", "socket2", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -2853,9 +2853,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -2907,11 +2907,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "cf9cf6a813d3f40c88b0b6b6f29a5c95c6cdbf97c1f9cc53fb820200f5ad814d" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-core", diff --git a/client/live-iso/.gitignore b/client/live-iso/.gitignore new file mode 100644 index 00000000..bfd9f7a4 --- /dev/null +++ b/client/live-iso/.gitignore @@ -0,0 +1,13 @@ +.build +cache +chroot* +config/binary +config/bootstrap +config/common +config/hooks/live/0010* +config/hooks/live/0050* +config/hooks/normal +config/includes.chroot/usbsas-*.deb +config/source + + diff --git a/client/live-iso/Makefile b/client/live-iso/Makefile index 2bc4cd5f..b5738b68 100644 --- a/client/live-iso/Makefile +++ b/client/live-iso/Makefile @@ -4,8 +4,6 @@ DST_PKG_DIR=config/includes.chroot SRC_PKG_DIR=../../target/debian export USBSAS_ISO_VER=$(ISO_VER) -export USBSAS_BIN_PATH=/usr/libexec -export USBSAS_WEBFILES_DIR=/usr/share/usbsas/web CORE_VER := $(shell grep '^version = ' ../../usbsas-usbsas/Cargo.toml | cut -d'"' -f2) SRV_VER := $(shell grep '^version = ' ../../usbsas-server/Cargo.toml | cut -d'"' -f2) @@ -13,6 +11,8 @@ ASRV_VER := $(shell grep '^version = ' ../../usbsas-analyzer-server/Cargo.toml | HID_VER := $(shell grep '^version = ' ../../usbsas-hid/hid-dealer/Cargo.toml | cut -d'"' -f2) KIOSK_VER := $(shell grep 'Version' ../kiosk/usbsas-kiosk/DEBIAN/control | cut -d' ' -f2) +SU=sudo + all: usbsas-$(ISO_VER)-amd64.hybrid.iso pkgs: $(DST_PKG_DIR)/usbsas-kiosk_$(KIOSK_VER)_amd64.deb \ @@ -24,34 +24,13 @@ pkgs: $(DST_PKG_DIR)/usbsas-kiosk_$(KIOSK_VER)_amd64.deb \ $(DST_PKG_DIR)/%.deb: $(SRC_PKG_DIR)/%.deb cp $< $@ -$(SRC_PKG_DIR)/usbsas-kiosk_$(KIOSK_VER)_amd64.deb: - make -C ../kiosk - -$(SRC_PKG_DIR)/usbsas-core_$(CORE_VER)_amd64.deb: - cargo build --release --manifest-path=../../Cargo.toml - cargo-deb --no-build --manifest-path=../../usbsas-usbsas/Cargo.toml - -$(SRC_PKG_DIR)/usbsas-server_$(SRV_VER)_amd64.deb: - cargo-deb --no-build --manifest-path=../../usbsas-server/Cargo.toml - -$(SRC_PKG_DIR)/usbsas-analyzer-server_$(ASRV_VER)_amd64.deb: - cargo build --release --manifest-path=../../usbsas-analyzer-server/Cargo.toml - cargo-deb --no-build --manifest-path=../../usbsas-analyzer-server/Cargo.toml - -$(SRC_PKG_DIR)/usbsas-hid_$(HID_VER)_amd64.deb: - cargo build --release --manifest-path=../../usbsas-hid/hid-user/Cargo.toml - cargo build --release --manifest-path=../../usbsas-hid/hid-dealer/Cargo.toml - cargo-deb --no-build --manifest-path=../../usbsas-hid/hid-dealer/Cargo.toml - usbsas-$(ISO_VER)-amd64.hybrid.iso: pkgs lb config - sudo lb build + $(SU) lb build clean: - sudo lb clean + $(SU) lb clean distclean: clean - sudo rm -rf cache + $(SU) rm -rf cache rm $(DST_PKG_DIR)/*.deb - make -C ../kiosk clean - cargo clean --manifest-path=../../Cargo.toml diff --git a/debian/Dockerfile b/debian/Dockerfile new file mode 100644 index 00000000..24b263c2 --- /dev/null +++ b/debian/Dockerfile @@ -0,0 +1,26 @@ +FROM rust:slim-bullseye + +RUN set -eux; \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + pkgconf \ + clang \ + make \ + cmake \ + curl \ + git \ + protobuf-compiler \ + libfuse3-dev \ + libssl-dev \ + libkrb5-dev \ + libclamav-dev \ + libx11-dev \ + libxtst-dev \ + libdbus-1-dev \ + libudev-dev \ + libseccomp-dev \ + live-build \ + dpkg-dev && \ + cargo install cargo-deb + +WORKDIR /SRC diff --git a/debian/Makefile b/debian/Makefile new file mode 100644 index 00000000..73af70c9 --- /dev/null +++ b/debian/Makefile @@ -0,0 +1,52 @@ +ISO_VER=$(shell grep '^version' ../Cargo.toml | cut -d'"' -f2) + +PKG_DIR=../target/debian + +export USBSAS_ISO_VER=$(ISO_VER) +export USBSAS_BIN_PATH=/usr/libexec +export USBSAS_WEBFILES_DIR=/usr/share/usbsas/web + +CORE_VER := $(shell grep '^version = ' ../usbsas-usbsas/Cargo.toml | cut -d'"' -f2) +SRV_VER := $(shell grep '^version = ' ../usbsas-server/Cargo.toml | cut -d'"' -f2) +ASRV_VER := $(shell grep '^version = ' ../usbsas-analyzer-server/Cargo.toml | cut -d'"' -f2) +HID_VER := $(shell grep '^version = ' ../usbsas-hid/hid-dealer/Cargo.toml | cut -d'"' -f2) +KIOSK_VER := $(shell grep 'Version' ../client/kiosk/usbsas-kiosk/DEBIAN/control | cut -d' ' -f2) + +all: ../client/live-iso/usbsas-$(ISO_VER)-amd64.hybrid.iso + +pkgs: $(PKG_DIR)/usbsas-kiosk_$(KIOSK_VER)_amd64.deb \ + $(PKG_DIR)/usbsas-core_$(CORE_VER)_amd64.deb \ + $(PKG_DIR)/usbsas-server_$(SRV_VER)_amd64.deb \ + $(PKG_DIR)/usbsas-analyzer-server_$(ASRV_VER)_amd64.deb \ + $(PKG_DIR)/usbsas-hid_$(HID_VER)_amd64.deb + +$(PKG_DIR)/usbsas-kiosk_$(KIOSK_VER)_amd64.deb: + make -C ../client/kiosk + +$(PKG_DIR)/usbsas-core_$(CORE_VER)_amd64.deb: + cargo build --release --manifest-path=../Cargo.toml + cargo-deb --no-build --manifest-path=../usbsas-usbsas/Cargo.toml + +$(PKG_DIR)/usbsas-server_$(SRV_VER)_amd64.deb: + cargo-deb --no-build --manifest-path=../usbsas-server/Cargo.toml + +$(PKG_DIR)/usbsas-analyzer-server_$(ASRV_VER)_amd64.deb: + cargo build --release --manifest-path=../usbsas-analyzer-server/Cargo.toml + cargo-deb --no-build --manifest-path=../usbsas-analyzer-server/Cargo.toml + +$(PKG_DIR)/usbsas-hid_$(HID_VER)_amd64.deb: + cargo build --release --manifest-path=../usbsas-hid/hid-user/Cargo.toml + cargo build --release --manifest-path=../usbsas-hid/hid-dealer/Cargo.toml + cargo-deb --no-build --manifest-path=../usbsas-hid/hid-dealer/Cargo.toml + +../client/live-iso/usbsas-$(ISO_VER)-amd64.hybrid.iso: pkgs + make -C ../client/live-iso + +clean: + make -C ../client/live-iso clean + make -C ../client/kiosk clean + +distclean: clean + make -C ../client/live-iso distclean + make -C ../client/kiosk distclean + cargo clean --manifest-path=../Cargo.toml