├── .git-hooks-pre-commit ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── Jenkinsfile ├── LICENSE ├── README.md ├── coding-generic-sync.sh ├── index.md └── lint.sh /.git-hooks-pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git diff --diff-filter=d --name-only HEAD | xargs ./lint.sh 4 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow pull request events but only for the main branch 8 | push: 9 | branches: [ main ] 10 | pull_request: 11 | branches: [ main ] 12 | 13 | # Allows you to run this workflow manually from the Actions tab 14 | workflow_dispatch: 15 | 16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 17 | jobs: 18 | # This workflow contains a single job called "build" 19 | build: 20 | # The type of runner that the job will run on 21 | runs-on: ubuntu-22.04 22 | 23 | # TODO hard code, because GitHub Actions only support secrets but not env 24 | env: 25 | CODING_GENERIC_REGISTRY: https://coding-public-generic.pkg.coding.net/public/downloads/ 26 | 27 | # Steps represent a sequence of tasks that will be executed as part of the job 28 | steps: 29 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 30 | - uses: actions/checkout@v4 31 | 32 | - uses: technote-space/get-diff-action@v5 33 | if: ${{ github.event_name == 'pull_request' }} 34 | 35 | - name: Cache Downloads 36 | id: cache-downloads 37 | uses: actions/cache@v4 38 | with: 39 | path: | 40 | /usr/local/bin/shellcheck 41 | /usr/local/bin/shfmt 42 | key: ${{ runner.os }}-shellcheck-shfmt 43 | 44 | - name: Prepare 45 | if: steps.cache-downloads.outputs.cache-hit != 'true' 46 | run: | 47 | mkdir -p ~/.cache/downloads 48 | wget https://github.com/mvdan/sh/releases/download/v3.3.1/shfmt_v3.3.1_linux_amd64 -O ~/.cache/downloads/shfmt 49 | chmod +x ~/.cache/downloads/shfmt 50 | sudo cp ~/.cache/downloads/shfmt /usr/local/bin/shfmt 51 | wget https://github.com/koalaman/shellcheck/releases/download/v0.7.2/shellcheck-v0.7.2.linux.x86_64.tar.xz -P ~/.cache/downloads/ 52 | tar -C ~/.cache/downloads/ --strip-components=1 -Jxvf ~/.cache/downloads/shellcheck-v0.7.2.linux.x86_64.tar.xz shellcheck-v0.7.2/shellcheck 53 | sudo cp ~/.cache/downloads/shellcheck /usr/local/bin/shellcheck 54 | 55 | - name: Lint 56 | if: env.GIT_DIFF 57 | run: echo ${{ env.GIT_DIFF }} | xargs ./lint.sh 58 | 59 | # Download and check sha256, if file not exist in registry 60 | - name: Download and check 61 | run: ./coding-generic-sync.sh 62 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /dl/ 2 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent any 3 | stages { 4 | stage('检出') { 5 | steps { 6 | checkout([ 7 | $class: 'GitSCM', 8 | branches: [[name: GIT_BUILD_REF]], 9 | userRemoteConfigs: [[ 10 | url: GIT_REPO_URL, 11 | credentialsId: CREDENTIALS_ID 12 | ]]]) 13 | } 14 | } 15 | stage('准备环境') { 16 | steps { 17 | sh 'npm install coding-generic -g' 18 | } 19 | } 20 | stage('下载和上传') { 21 | steps { 22 | withCredentials([ 23 | usernamePassword( 24 | // CODING 持续集成的环境变量中内置了一个用于上传到当前项目制品库的凭证 25 | credentialsId: env.CODING_ARTIFACTS_CREDENTIALS_ID, 26 | usernameVariable: 'CODING_ARTIFACTS_USERNAME', 27 | passwordVariable: 'CODING_ARTIFACTS_PASSWORD' 28 | )]) { 29 | sh './coding-generic-sync.sh' 30 | } 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 CODING.net 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CODING 公共制品库 2 | 3 | [![CI](https://github.com/sinkcup/coding-download-center/actions/workflows/ci.yml/badge.svg)](https://github.com/sinkcup/coding-download-center/actions/workflows/ci.yml) 4 | [![CODING 持续集成](https://coding-public.coding.net/badges/public/job/635809/main/build.svg)](https://e.coding.net/register?invite_register_token=8480c005dcae42a58ae5b2e89bf258a0) 5 | 6 | 「CODING 公共制品库」已在「CODING 持续集成」生产环境中投入使用,无需担心欠费停机。 7 | 8 | 为中国开发者提供常用的命令行软件下载,解决跨境下载缓慢的问题。 9 | 10 | ## 提交需要的软件 11 | 12 | 修改 `index.md`,加入需要的软件(按照字母顺序),发起合并请求。 13 | 14 | 合并请求会自动检查正确性,如有报错,请修改后再次推送。 15 | 16 | 待管理员合并,会自动发布到内地的「CODING 制品库」: 17 | 18 | https://coding-public.coding.net/public-artifacts/public/downloads/packages 19 | 20 | ## 技术细节 21 | 22 | 提交代码会触发「[CODING 持续集成](https://coding.net/products/ci)」的海外节点构建,自动执行 `coding-generic-sync.sh`: 23 | 24 | - 解析 `index.md` 获取需要下载的软件列表 25 | - 判断是否已存在于「[CODING 制品库](https://coding.net/products/artifacts)」,如不存在,则下载、校验、上传 26 | -------------------------------------------------------------------------------- /coding-generic-sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ "$CODING_GENERIC_REGISTRY" = "" ]; then 5 | echo "WARNING: env CODING_GENERIC_REGISTRY not set, only run download" 6 | elif [ "$CODING_ARTIFACTS_USERNAME" = "" ]; then 7 | echo "WARNING: env CODING_ARTIFACTS_USERNAME not set, only run check and download" 8 | fi 9 | 10 | top_dir=$( 11 | cd "$(dirname "$0")" 12 | pwd 13 | ) 14 | dl_dir=$top_dir/dl 15 | mkdir -p "$dl_dir" 16 | 17 | index_file="$top_dir/index.md" 18 | thead_line_num=$(grep -n "\-|\-" "$index_file" | awk -F: '{print $1}') 19 | offset=$((thead_line_num + 1)) 20 | tail -n +$offset "$index_file" | while read -r line; do 21 | i=0 22 | http_code=200 23 | sha256="" 24 | while IFS='|' read -ra tmp; do 25 | for part in "${tmp[@]}"; do 26 | part=$(echo "${part}" | tr -d '[:space:]') 27 | if [ $i -eq 0 ]; then 28 | package=$part 29 | printf "\n%s\n" "$package" 30 | file_prefix="${part%%.*}" 31 | file_suffix="" 32 | if [[ $part == *"."* ]]; then 33 | file_suffix=".""${part#*.}" 34 | fi 35 | elif [ $i -eq 1 ]; then 36 | version=$part 37 | filename=$file_prefix-$version$file_suffix 38 | elif [ $i -eq 2 ]; then 39 | uri=$part 40 | elif [ $i -eq 3 ]; then 41 | sha256=$part 42 | echo "$sha256 $dl_dir/$filename" > "$dl_dir/$filename.sha256sum" 43 | fi 44 | i=$((i + 1)) 45 | done 46 | done <<< "$line" 47 | 48 | http_code=404 49 | if [ "$CODING_GENERIC_REGISTRY" != "" ]; then 50 | mirror_full_url="${CODING_GENERIC_REGISTRY}$package?version=$version" 51 | echo "check $mirror_full_url" 52 | header=$(curl -sI "$mirror_full_url") 53 | http_code=$(echo "$header" | head -n 1 | awk '{print $2}') 54 | if [ "$http_code" -eq 200 ]; then 55 | echo "skip: file exists on mirror" 56 | fi 57 | fi 58 | if [ "$http_code" -ne 200 ]; then 59 | if [ -f "$dl_dir/$filename" ] && sha256sum -c "$dl_dir/$filename.sha256sum"; then 60 | echo "skip: file exists on local" 61 | else 62 | wget -O "$dl_dir/$filename" "$uri" 63 | sha256sum -c "$dl_dir/$filename.sha256sum" 64 | fi 65 | # coding-generic 自带校验功能,上传成功即可,无需再下载校验。 66 | if [ "$CODING_GENERIC_REGISTRY" != "" ] && 67 | [ "$CODING_ARTIFACTS_USERNAME" != "" ] && 68 | [ "$CODING_ARTIFACTS_PASSWORD" != "" ]; then 69 | coding-generic --username="${CODING_ARTIFACTS_USERNAME}:${CODING_ARTIFACTS_PASSWORD}" \ 70 | --path="${dl_dir}/${filename}" \ 71 | --registry="${CODING_GENERIC_REGISTRY}chunks/${package}?version=${version}" 72 | fi 73 | fi 74 | done 75 | echo 'the end' 76 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | package | version | uri | sha256 2 | --------|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------- 3 | adoptopenjdk-11-openj9-amd64.deb | 11.0.10-9.openj9-0.24.0-3 | https://adoptopenjdk.jfrog.io/ui/api/v1/download?repoKey=deb&path=pool%252Fmain%252Fa%252Fadoptopenjdk-11-openj9%252Fadoptopenjdk-11-openj9_11.0.10%252B9.openj9-0.24.0-3_amd64.deb | 31ded628e72f16e9924786caf9ecc26c4e5728b458e51c7345f89cb05ed77d6b 4 | adoptopenjdk-16-openj9-amd64.deb | 16.0.1-9.openj9-0.26.0-3 | https://adoptopenjdk.jfrog.io/ui/api/v1/download?repoKey=deb&path=pool%252Fmain%252Fa%252Fadoptopenjdk-16-openj9%252Fadoptopenjdk-16-openj9_16.0.1%252B9.openj9-0.26.0-3_amd64.deb | 486e92a3dd6525ec3e360ba21188c9c1d5974d35d3502b082c849172d2e90f11 5 | allure-commandline.tgz | 2.16.1 | https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.16.1/allure-commandline-2.16.1.tgz | c8ae7e2029471cb06d0a1d8c851c3fb3d47a54698ec8353a0e194c48a1a07963 6 | amazon-corretto-17-amd64.deb | 17.0.10.7.1 | https://corretto.aws/downloads/resources/17.0.10.7.1/java-17-amazon-corretto-jdk_17.0.10.7-1_amd64.deb | 192218e576a0b08952aa04cb61af036152a741dd0f7159022cc0e048226e0a2f 7 | amazon-corretto-21-amd64.deb | 21.0.2.13.1 | https://corretto.aws/downloads/resources/21.0.2.13.1/java-21-amazon-corretto-jdk_21.0.2.13-1_amd64.deb | b710aeaf3dde0370c51d5c1a371fd0b3ff7f2a48cba4a12b8e1a6c82cc1aaca0 8 | apache-maven-bin.tar.gz | 3.8.1 | https://mirror.softaculous.com/apache/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz | b98a1905eb554d07427b2e5509ff09bd53e2f1dd7a0afa38384968b113abef02 9 | bazel-linux-x86-64.deb | 4.2.1 | https://github.com/bazelbuild/bazel/releases/download/4.2.1/bazel_4.2.1-linux-x86_64.deb | 67447658b8313316295cd98323dfda2a27683456a237f7a3226b68c9c6c81b3a 10 | chrome-darwin-amd64.dmg | 91.0.4472.106 | https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg | 23348d4864a2c0a1512a43b52d9d9e7dab4fc5138aa80e8f298490e0cb9add19 11 | chrome-darwin-arm64.dmg | 91.0.4472.106 | https://dl.google.com/chrome/mac/universal/stable/GGRO/googlechrome.dmg | 0ec1f9d1f89b5b913c63452b8327e76deb1ddb6b7d3e518fd6eecd15c09a4dd4 12 | chrome-windows-amd64.exe | 91.0.4472.106 | https://dl.google.com/release2/chrome/bxpqrd8QQC3CMG7JLTYU0w_91.0.4472.106/91.0.4472.106_chrome_installer.exe | cffddc1fa70fa7296d033e1754c942b143f2c5995edff17a4ecae8e455775446 13 | composer.phar | 2.0.14 | https://getcomposer.org/download/2.0.14/composer.phar | 29454b41558968ca634bf5e2d4d07ff2275d91b637a76d7a05e6747d36dd3473 14 | dependency-check-release.zip | 6.3.1 | https://github.com/jeremylong/DependencyCheck/releases/download/v6.3.1/dependency-check-6.3.1-release.zip | 3650ef52aa66eeea1cd5f063670aec7304c2f2a3cd4cafd84bcf516660fbdfa2 15 | git-lfs-linux-amd64.tar.gz | 2.11.0 | https://github.com/git-lfs/git-lfs/releases/download/v2.11.0/git-lfs-linux-amd64-v2.11.0.tar.gz | 46508eb932c2ec0003a940f179246708d4ddc2fec439dcacbf20ff9e98b957c9 16 | go-darwin-amd64.pkg | 1.18.4 | https://go.dev/dl/go1.18.4.darwin-amd64.pkg | ed5093acc099dfc4ab14cb5d5bc51d9f6694240d5eed25942f0d85f9995ba3f8 17 | go-darwin-arm64.pkg | 1.18.4 | https://go.dev/dl/go1.18.4.darwin-arm64.pkg | 7f7726eae9c295cc148ae33457cf650c6b088ead027229e5256a312919187f88 18 | go-linux-amd64.tar.gz | 1.24.0 | https://go.dev/dl/go1.24.0.linux-amd64.tar.gz | dea9ca38a0b852a74e81c26134671af7c0fbe65d81b0dc1c5bfe22cf7d4c8858 19 | golangci-lint-linux-amd64.tar.gz | 1.43.0 | https://github.com/golangci/golangci-lint/releases/download/v1.43.0/golangci-lint-1.43.0-linux-amd64.tar.gz | f3515cebec926257da703ba0a2b169e4a322c11dc31a8b4656b50a43e48877f4 | 20 | helm-linux-amd64.tar.gz | v3.7.1 | https://get.helm.sh/helm-v3.7.1-linux-amd64.tar.gz | 6cd6cad4b97e10c33c978ff3ac97bb42b68f79766f1d2284cfd62ec04cd177f4 21 | hugo-extended-linux-amd64.deb | 0.104.3 | https://github.com/gohugoio/hugo/releases/download/v0.104.3/hugo_extended_0.104.3_linux-amd64.deb | 27ffd4e6b33e7359a97569b48cfdca41d9246e9d16151d25eb979d8285c89bdf 22 | hugo-linux-amd64.deb | 0.104.3 | https://github.com/gohugoio/hugo/releases/download/v0.104.3/hugo_0.104.3_linux-amd64.deb | 48c23615b36f847a5fa7a76ea03ac1ad437b0c3d65fbb97b521ad6d555073eef 23 | ibm-semeru-open-jdk-x64-linux.tar.gz | 17.0.12_7_openj9-0.46.1 | https://github.com/ibmruntimes/semeru17-binaries/releases/download/jdk-17.0.12%2B7_openj9-0.46.1/ibm-semeru-open-jdk_x64_linux_17.0.12_7_openj9-0.46.1.tar.gz | 67890f8b705cc1cab1024a4cd86da7eb34adfc76b3917d8f708776e5b0c9f8b3 24 | ibm-semeru-open-jdk-x64-linux.tar.gz | 21.0.4_7_openj9-0.46.1 | https://github.com/ibmruntimes/semeru21-binaries/releases/download/jdk-21.0.4%2B7_openj9-0.46.1/ibm-semeru-open-jdk_x64_linux_21.0.4_7_openj9-0.46.1.tar.gz | eaf8a35c50167da06f1e103602df40aac2a74a1fd170f4701b2076152e104e5c 25 | jenkins-all.deb | 2.190.3 | https://get.jenkins.io/debian-stable/jenkins_2.190.3_all.deb | 96caa1d5ebe4b0c835571e3fae5a30ce25474edfffce01e6df511e69adef69fd 26 | kubectl-darwin-amd64 | v1.22.4 | https://dl.k8s.io/release/v1.22.4/bin/darwin/amd64/kubectl | 9b2ace8f0c991153f8b6319a8f8cb3a8003e6d8e38cc44ce20e012d9b43ac5f4 27 | kubectl-darwin-arm64 | v1.22.4 | https://dl.k8s.io/release/v1.22.4/bin/darwin/arm64/kubectl | 6a0b79f9d15cff722419f29f1c0cb57268a261ecf69d8789079a16674d5222d4 28 | kubectl-linux-amd64 | v1.22.4 | https://dl.k8s.io/release/v1.22.4/bin/linux/amd64/kubectl | 21f24aa723002353eba1cc2668d0be22651f9063f444fd01626dce2b6e1c568c 29 | node-linux-x64.tar.xz | v17.2.0 | https://nodejs.org/dist/v17.2.0/node-v17.2.0-linux-x64.tar.xz | 0b5a6db351f31edf5282c63be7b923e40064ac6d54b5222fdd419ab8f1bedf61 30 | pack-linux.tgz | v0.20.0 | https://github.com/buildpacks/pack/releases/download/v0.20.0/pack-v0.20.0-linux.tgz | 1d879c8f99130b30e080153b1025ee51cfeddfb41612e5c257a89d3a358fc3c2 31 | packer-linux-amd64.zip | 1.7.4 | https://releases.hashicorp.com/packer/1.7.4/packer_1.7.4_linux_amd64.zip | 3660064a56a174a6da5c37ee6b36107098c6b37e35cc84feb2f7f7519081b1b0 32 | php.tar.xz | 8.2.16 | https://www.php.net/distributions/php-8.2.16.tar.xz | 28cdc995b7d5421711c7044294885fcde4390c9f67504a994b4cf9bc1b5cc593 33 | rancherd-amd64.tar.gz | v2.5.9 | https://github.com/rancher/rancher/releases/download/v2.5.9/rancherd-amd64.tar.gz | 61222a6d57ecdd109a0063d6422390c865ab8d11b63b42e43bac09e0a999562e 34 | shellcheck-linux-x86-64.tar.xz | v0.7.2 | https://github.com/koalaman/shellcheck/releases/download/v0.7.2/shellcheck-v0.7.2.linux.x86_64.tar.xz | 70423609f27b504d6c0c47e340f33652aea975e45f312324f2dbf91c95a3b188 35 | shfmt-linux-amd64 | v3.3.1 | https://github.com/mvdan/sh/releases/download/v3.3.1/shfmt_v3.3.1_linux_amd64 | 0f73bf27219571bca7c5ef7d740d6ae72227e3995ffd88c7cb2b5712751538e2 36 | terraform-linux-amd64.zip | 1.0.6 | https://releases.hashicorp.com/terraform/1.0.6/terraform_1.0.6_linux_amd64.zip | 6a454323d252d34e928785a3b7c52bfaff1192f82685dfee4da1279bb700b733 37 | vscode-darwin-universal.zip | 1.59.0 | https://az764295.vo.msecnd.net/stable/379476f0e13988d90fab105c5c19e7abc8b1dea8/VSCode-darwin-universal.zip | da04978c00b1c142eafb97a0db86883cda5ca5b54899b86b88456a82153bba53 38 | vscode-linux-amd64.deb | 1.59.0 | https://az764295.vo.msecnd.net/stable/379476f0e13988d90fab105c5c19e7abc8b1dea8/code_1.59.0-1628120042_amd64.deb | c9c73e3e9e38806c83031954e909c23c50d4d3b8877dc91ab4b51eb66a3f5eea 39 | vscode-windows-user-setup-x64.exe | 1.59.0 | https://az764295.vo.msecnd.net/stable/379476f0e13988d90fab105c5c19e7abc8b1dea8/VSCodeUserSetup-x64-1.59.0.exe | 797c354b28f9a9eeb96e2d7c17f8f341b1830147832c90e686606150f5987b9d 40 | -------------------------------------------------------------------------------- /lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ -z "$1" ]; then 5 | echo "no file" 6 | exit 7 | fi 8 | 9 | shell_files=$(echo "$@" | tr ' ' '\n' | { grep ".sh$" || true; }) 10 | if [ -n "$shell_files" ]; then 11 | echo "lint shell:" 12 | echo "$shell_files" 13 | echo "$shell_files" | xargs shellcheck 14 | echo "$shell_files" | xargs shfmt -d -i 4 -sr 15 | else 16 | echo "no shell file" 17 | fi 18 | 19 | index_file=$(echo "$@" | tr ' ' '\n' | { grep "^index.md$" || true; }) 20 | if [ -n "$index_file" ]; then 21 | echo "lint index.md" 22 | echo "check package name sort by a-z" 23 | tail -n +3 index.md > /tmp/index-body.md 24 | cd /tmp 25 | sort index-body.md > index-body-sorted.md 26 | diff index-body.md index-body-sorted.md 27 | packages=$(awk '{print $1}' index-body.md) 28 | for i in $packages; do 29 | expr "$i" : "[a-z0-9\.-]\+$" > /dev/null || (echo "$i: 包名应该全为小写" && exit 250) 30 | done 31 | fi 32 | ## lint markdown 33 | # TODO 34 | --------------------------------------------------------------------------------