From d733dba221423c48059f6efd2d29b1c30166aa46 Mon Sep 17 00:00:00 2001 From: Jixun Date: Sat, 26 Nov 2022 23:52:48 +0000 Subject: [PATCH] ci: upload to gitea packages instead of s3 --- .drone.yml | 28 +++++++++------------------- scripts/upload-packages.sh | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 scripts/upload-packages.sh diff --git a/.drone.yml b/.drone.yml index cb444be..4e84fe6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,23 +15,13 @@ steps: - ./scripts/build-and-package.sh legacy - ./scripts/build-and-package.sh extension - ./scripts/build-and-package.sh modern - - sha256sum *.zip > sha256sum.txt - - mkdir -p upload - - mv *.zip sha256sum.txt upload/ - - name: upload - image: "plugins/s3" - settings: - path_style: true - endpoint: - from_secret: S3_ENDPOINT - access_key: - from_secret: S3_ACCESS_KEY - secret_key: - from_secret: S3_SECRET_KEY - bucket: - from_secret: S3_BUCKET - region: "auto" - source: "upload/*" - strip_prefix: "upload/" - target: "${DRONE_REPO}/${DRONE_BUILD_NUMBER}/" + - name: upload artifact + image: busybox:1.34-glibc + environment: + DRONE_GITEA_SERVER: https://git.unlock-music.dev + GITEA_API_KEY: + from_secret: GITEA_API_KEY + commands: + - apt-get update && apt-get install -y curl + - ./scripts/upload-packages.sh diff --git a/scripts/upload-packages.sh b/scripts/upload-packages.sh new file mode 100644 index 0000000..d2ef758 --- /dev/null +++ b/scripts/upload-packages.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -ex + +cd "$(git rev-parse --show-toplevel)" + +URL_BASE="$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build" + +for ZIP_NAME in *.zip; do + UPLOAD_URL="${URL_BASE}/${DRONE_BUILD_NUMBER}/${ZIP_NAME}" + sha256sum "${ZIP_NAME}" + curl -sLifu "um-release-bot:$GITEA_API_KEY" -T "${ZIP_NAME}" "${UPLOAD_URL}" + echo "Uploaded to: ${UPLOAD_URL}" +done