From 5e60b7fcff2ff0bd9e8378ee22f472b37241768d Mon Sep 17 00:00:00 2001 From: Jochen maes Date: Sat, 21 Oct 2023 08:46:51 +0200 Subject: [PATCH 1/7] adds test drone Signed-off-by: Jochen maes --- .drone.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..5cfcd46 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,10 @@ +--- +kind: pipeline +type: docker +name: default + +steps: + - name: test + image: rust:1.73 + commands: + - cargo test From ac366da316f32c84531a0a431275cf2b8afa2de5 Mon Sep 17 00:00:00 2001 From: Jochen maes Date: Sat, 21 Oct 2023 10:09:08 +0200 Subject: [PATCH 2/7] adds platform Signed-off-by: Jochen maes --- .drone.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 5cfcd46..ca87b32 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,10 +1,17 @@ --- kind: pipeline type: docker -name: default +name: mouse-amd64 + +platform: + arch: amd64 steps: - name: test image: rust:1.73 commands: - cargo test + - name: compile + image: rust:1.73 + commands: + - cargo build --target x86_64-unknown-linux-gnu From 067d4200c96565776ea4f4c5b700c08de6ab1972 Mon Sep 17 00:00:00 2001 From: Jochen maes Date: Sat, 21 Oct 2023 10:37:35 +0200 Subject: [PATCH 3/7] adds arm64 Signed-off-by: Jochen maes --- .drone.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.drone.yml b/.drone.yml index ca87b32..651786f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,3 +15,23 @@ steps: image: rust:1.73 commands: - cargo build --target x86_64-unknown-linux-gnu + + +--- +kind: pipeline +type: docker +name: mouse-arm64 + +platform: + arch: arm64 + +steps: + - name: test + image: rust:1.73 + commands: + - cargo test + - name: compile + image: rust:1.73 + commands: + - cargo build --target x86_64-unknown-linux-gnu + From 6114984f1354bf096aabc34839b3bf3ec01afe51 Mon Sep 17 00:00:00 2001 From: Jochen maes Date: Sat, 21 Oct 2023 11:04:39 +0200 Subject: [PATCH 4/7] adds publish Signed-off-by: Jochen maes --- .drone.yml | 8 +++++++- Cargo.toml | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 651786f..95cb04f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,5 +33,11 @@ steps: - name: compile image: rust:1.73 commands: - - cargo build --target x86_64-unknown-linux-gnu + - cargo build --target aarch64-unknown-linux-gnu + - name: + image: rust:1.73 + environment: + TOKEN: + from_secret: gitea_token + - cargo publish --registry gita --token $TOKEN diff --git a/Cargo.toml b/Cargo.toml index 8b1ba31..748ddc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,10 @@ description = "Information gatherer for systems." version = "0.1.0" edition = "2021" +[registries] +gitea = { index = "https://gitea.sejo-it.be/SeJo-IT/_cargo-index" } + + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] From 1e0dab9fd13863897ad47c991f9223a2dd7a6344 Mon Sep 17 00:00:00 2001 From: Jochen maes Date: Sat, 21 Oct 2023 11:06:01 +0200 Subject: [PATCH 5/7] fixes command Signed-off-by: Jochen maes --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 95cb04f..bfb499f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,5 +39,6 @@ steps: environment: TOKEN: from_secret: gitea_token + commands: - cargo publish --registry gita --token $TOKEN From 8aa18b22b55a053f4203c376f2b5ca71f1219b49 Mon Sep 17 00:00:00 2001 From: Jochen maes Date: Sat, 21 Oct 2023 11:06:57 +0200 Subject: [PATCH 6/7] adds step name Signed-off-by: Jochen maes --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index bfb499f..e56c0ad 100644 --- a/.drone.yml +++ b/.drone.yml @@ -34,7 +34,7 @@ steps: image: rust:1.73 commands: - cargo build --target aarch64-unknown-linux-gnu - - name: + - name: publish crate image: rust:1.73 environment: TOKEN: From a29153ab3c6fadfa88699995400cc014a2a604ce Mon Sep 17 00:00:00 2001 From: Jochen maes Date: Sat, 21 Oct 2023 11:21:49 +0200 Subject: [PATCH 7/7] adds cross-compiling Signed-off-by: Jochen maes --- .drone.yml | 146 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 113 insertions(+), 33 deletions(-) diff --git a/.drone.yml b/.drone.yml index e56c0ad..bb31d4d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,44 +1,124 @@ ---- kind: pipeline type: docker -name: mouse-amd64 - +name: 'Rust cross compilation' platform: arch: amd64 +# Shared volume for the Docker in Docker service and build steps. +# Without this, cross won't be able to find a running Docker agent. +volumes: +- name: dockersock + temp: {} + +services: +- image: docker:dind + name: docker + privileged: true # Docker in Docker requires this, sadly. + pull: true + volumes: + - name: dockersock + path: /var/run + +# Ensure Docker agent has started before continuing. steps: - - name: test - image: rust:1.73 - commands: - - cargo test - - name: compile - image: rust:1.73 - commands: - - cargo build --target x86_64-unknown-linux-gnu +- name: Wait for Docker + image: rust-dind-cross:1.73-full + pull: true + commands: + - mkdir artifacts + - while ! docker image ls; do sleep 1; done + - docker info + - docker pull hello-world:latest + volumes: + - name: dockersock + path: /var/run +# Build for aarch64-unknown-linux-gnu (arm64) +- name: Build for arm64-gnu + image: rust-dind-cross:1.73-full + pull: true + environment: + CROSS_REMOTE: true + commands: + - cross build --release --target aarch64-unknown-linux-gnu + - cp target/aarch64-unknown-linux-gnu/release/mouse artifacts/mouse-arm64-gnu + - rm -rf target/aarch64-unknown-linux-gnu/release/* + depends_on: + - Wait for Docker + volumes: + - name: dockersock + path: /var/run ---- -kind: pipeline -type: docker -name: mouse-arm64 +# Build for aarch64-unknown-linux-musl (arm64 with Alpine linux) +- name: Build for arm64-musl + image: rust-dind-cross:1.73-full + pull: true + environment: + CROSS_REMOTE: true + commands: + - cross build --release --target aarch64-unknown-linux-musl + - cp target/aarch64-unknown-linux-musl/release/mouse artifacts/mouse-arm64-musl + - rm -rf target/aarch64-unknown-linux-musl/release/* + depends_on: + - Wait for Docker + volumes: + - name: dockersock + path: /var/run -platform: - arch: arm64 +# Build for x86_64-unknown-linux-gnu (amd64) +- name: Build for amd64-gnu + image: rust-dind-cross:1.73-full + pull: true + environment: + CROSS_REMOTE: true + commands: + - cross build --release --target x86_64-unknown-linux-gnu + - cp target/x86_64-unknown-linux-gnu/release/mouse artifacts/mouse-amd64-gnu + - rm -rf target/x86_64-unknown-linux-gnu/release/* + depends_on: + - Wait for Docker + volumes: + - name: dockersock + path: /var/run -steps: - - name: test - image: rust:1.73 - commands: - - cargo test - - name: compile - image: rust:1.73 - commands: - - cargo build --target aarch64-unknown-linux-gnu - - name: publish crate - image: rust:1.73 - environment: - TOKEN: - from_secret: gitea_token - commands: - - cargo publish --registry gita --token $TOKEN +# Build for x86_64-unknown-linux-musl (amd64 with Alpine linux) +- name: Build for amd64-musl + image: rust-dind-cross:1.73-full + pull: true + environment: + CROSS_REMOTE: true + commands: + - cross build --release --target x86_64-unknown-linux-musl + - cp target/x86_64-unknown-linux-musl/release/mouse artifacts/mouse-amd64-musl + - rm -rf target/x86_64-unknown-linux-musl/release/* + depends_on: + - Wait for Docker + volumes: + - name: dockersock + path: /var/run +# Show all built artifacts +- name: Show built artifacts + image: rust-dind-cross:1.73-full + commands: + - ls -lah artifacts + depends_on: + - Build for arm64-gnu + - Build for arm64-musl + - Build for amd64-gnu + - Build for amd64-musl + +# When a tag is created, this step gets added. +- name: Create release on gitea + image: plugins/gitea-release + settings: + api_key: + from_secret: gitea_token + base_url: https://gitea.sejo-it.be + checksum: sha256 + files: artifacts/* + depends_on: + - Show built artifacts + when: + event: + - tag