From 51933440e8eeb61f6f71855907207ee8dbd72491 Mon Sep 17 00:00:00 2001 From: Lonnie Date: Thu, 2 Dec 2021 02:47:14 +0100 Subject: [PATCH] Test this woodpecker thingy. --- .woodpecker.yml | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ zig.mod | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .woodpecker.yml diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..e7aca0e --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,56 @@ +platform: linux/amd64 + +pipeline: + build-x86_64: + image: alpine + environment: + - ZIG_BIN=https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.1815+20e19e75f.tar.xz + - ZIGMOD_BIN=https://github.com/nektro/zigmod/releases/download/v85/zigmod-x86_64-linux + commands: + - apk add --no-cache build-base curl-dev curl-static zlib-static + openssl-libs-static nghttp2-static brotli-static xz git unzip + - wget $ZIG_BIN + - wget $ZIGMOD_BIN + - tar xf zig-linux-x86_64-0.9.0-dev.1815+20e19e75f.tar.xz + - zig="$PWD/zig-linux-x86_64-0.9.0-dev.1815+20e19e75f/zig" + - zigmod="$PWD/zigmod-x86_64-linux" + - chmod +x $zigmod + - wget https://www.sqlite.org/2021/sqlite-amalgamation-3370000.zip + - unzip sqlite-amalgamation-3370000.zip + - mv sqlite-amalgamation-3370000 sqlite + - $zigmod ci + - $zig build -Dstatic=true + - mv zig-out/bin/derploader zig-out/bin/derploader-non-stripped + - $zig build -Dstatic=true -Dstrip=true + - strip -s zig-out/bin/derploader + upload: + image: alpine + secrets: [b2auth, b2bucket] + commands: + - apk add curl jq + - PREFIX="artefacts/treehouse/${CI_REPO}/${CI_BUILD_NUMBER}" + - set +x + - echo "$B2AUTH" > auth1 + - set -x + - curl -H @auth1 https://api.backblazeb2.com/b2api/v2/b2_authorize_account > resp1 + - API=$(< resp1 jq -r '.apiUrl') + - 'echo -n "authorization: " > auth2' + - < resp1 jq -r '.authorizationToken' >> auth2 + - "curl -H @auth2 -d '{\"bucketId\": \"'\"$B2BUCKET\"'\"}' + \"$API/b2api/v2/b2_get_upload_url\" > resp2" + - UPURL=$(< resp2 jq -r '.uploadUrl') + - 'echo -n "authorization: " > auth3' + - < resp2 jq -r '.authorizationToken' >> auth3 + - " + for x in zig-out/bin/*; + do + SHA=$(sha1sum $x | awk '{print $1}')\n + curl + -H @auth3 + -H \"X-Bz-File-Name: $PREFIX/$(basename $x)\" + -H \"Content-Type: b2/x-auto\" + -H \"X-Bz-Content-Sha1: $SHA\" + --data-binary \"@$x\" + $UPURL\n + echo \"https://bucket.lonjil.xyz/$PREFIX/$(basename $x)\"\n + done\n" diff --git a/zig.mod b/zig.mod index dbdb260..e1c2de7 100644 --- a/zig.mod +++ b/zig.mod @@ -28,6 +28,6 @@ dev_dependencies: - -DSQLITE_ENABLE_MATH_FUNCTIONS - -DSQLITE_ENABLE_BATCH_ATOMIC_WRITE=1 c_source_files: - - ../../../../../../sqlite/sqlite3.c + - ../../../../../../../../sqlite/sqlite3.c - src: git https://github.com/nektro/zig-json - src: git https://github.com/MasterQ32/zig-uri/