-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #15 upload to coding.net artifact
- Loading branch information
Showing
24 changed files
with
104 additions
and
1,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
/dl/ | ||
/docs/index.md | ||
/site/ | ||
/qiniu/ | ||
/tmp/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
# gmirror | ||
# CODING 下载中心 | ||
|
||
gmirror 是一个下载上传工具,指定一些下载链接,通过travis-ci持续集成进行下载,然后上传到指定的地方(比如七牛)。 | ||
为中国开发者提供持续集成中常用的命令行软件下载,解决跨境下载缓慢的问题。 | ||
|
||
## 提交需要的软件 | ||
|
||
修改 `index.md`,加入需要的软件,发起合并请求,待管理员合并,会触发自动下载,并发布到公开制品库: | ||
|
||
https://coding-public.coding.net/public-artifacts/public/downloads/packages | ||
|
||
## 技术细节 | ||
|
||
提交代码会触发「CODING 持续集成(支持海外构建节点)」,自动执行 `coding-generic-sync.sh`: | ||
|
||
- 解析 `index.md` 获取需要下载的软件列表 | ||
- 判断是否已存在于「CODING 制品库」,如不存在,则下载、校验、上传 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
top_dir=$(cd `dirname $0`; pwd) | ||
dl_dir=$top_dir/dl | ||
mkdir -p "$dl_dir" | ||
|
||
index_file="$top_dir/index.md" | ||
thead_line_num=$(grep -n "\-|\-" "$index_file" | awk -F: '{print $1}') | ||
offset=$(($thead_line_num+1)) | ||
tail -n +$offset "$index_file" | while read line; do | ||
i=0 | ||
http_code=200 | ||
sha256="" | ||
while IFS='|' read -ra tmp; do | ||
for part in "${tmp[@]}"; do | ||
part="$(sed -e 's/[[:space:]]*$//' <<<${part})" | ||
if [ $i -eq 0 ]; then | ||
package=$part | ||
printf "\n%s\n" "$package" | ||
file_prefix=$(echo "${part%%.*}") | ||
file_suffix="" | ||
if [[ $part == *"."* ]]; then | ||
file_suffix="."`echo ${part#*.}` | ||
fi | ||
elif [ $i -eq 1 ]; then | ||
version=$part | ||
filename=$file_prefix-$version$file_suffix | ||
elif [ $i -eq 2 ]; then | ||
uri=$part | ||
elif [ $i -eq 3 ]; then | ||
sha256=$part | ||
echo "$sha256 $dl_dir/$filename" > "$dl_dir/$filename.sha256sum" | ||
fi | ||
i=$(($i+1)) | ||
done | ||
done <<< "$line" | ||
|
||
if [ "$CODING_GENERIC_REGISTRY" = "" ]; then | ||
echo "error: env CODING_GENERIC_REGISTRY not set" | ||
exit 1 | ||
fi | ||
mirror_full_url="${CODING_GENERIC_REGISTRY}$package?version=$version" | ||
echo "check $mirror_full_url" | ||
header=$(curl -sI "$mirror_full_url") | ||
http_code=$(echo "$header" | head -n 1 | awk '{print $2}') | ||
if [ "$http_code" -eq 200 ]; then | ||
echo "skip: file exists on mirror" | ||
fi | ||
if [ "$http_code" -ne 200 ]; then | ||
if [ -f "$dl_dir/$filename" ]; then | ||
if sha256sum -c "$dl_dir/$filename.sha256sum"; then | ||
echo "skip: file exists on local" | ||
continue | ||
fi | ||
fi | ||
wget -O "$dl_dir/$filename" "$uri" | ||
sha256sum -c "$dl_dir/$filename.sha256sum" | ||
# coding-generic 自带校验功能,上传成功即可,无需再下载校验。 | ||
coding-generic --username="$CODING_GENERIC_REGISTRY:" --path=./test.txt --registry="$CODING_GENERIC_REGISTRY" | ||
fi | ||
done | ||
echo 'the end' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package | version | uri | sha256 | ||
--------|---------|-----|--------- | ||
go-linux-amd64.tar.gz | 1.16.4 | https://golang.google.cn/dl/go1.16.4.linux-amd64.tar.gz | ae4f6b6e2a1677d31817984655a762074b5356da50fb58722b99104870d43503 | ||
composer.phar | 2.0.14 | https://getcomposer.org/download/2.0.14/composer.phar | 29454b41558968ca634bf5e2d4d07ff2275d91b637a76d7a05e6747d36dd3473 | ||
kubectl-linux-amd64 | v1.18.4 | http://storage-googleapis-com.hnftp.china-speed.org.cn/kubernetes-release/release/v1.18.4/bin/linux/amd64/kubectl | 58785190e2b4fc6891e01108e41f9ba5db26e04cebb7c1ac639919a931ce9233 |
Oops, something went wrong.