Skip to content

Commit aac9c1f

Browse files
committed
chore(scripts): add install scripts
1 parent 0b2139e commit aac9c1f

4 files changed

Lines changed: 872 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,27 @@ steps:
2828
- tag
2929
- push
3030
- cron
31+
32+
- name: publish-scripts
33+
image: bash
34+
commands:
35+
- podman run --rm
36+
-e CI_FORGE_TYPE=github
37+
-e CI_PIPELINE_EVENT=tag
38+
-e CI_REPO_OWNER="$CI_REPO_OWNER"
39+
-e CI_REPO_NAME="$CI_REPO_NAME"
40+
-e CI_COMMIT_REF="refs/tags/$CI_COMMIT_TAG"
41+
-e PLUGIN_API_KEY="$GITHUB_TOKEN"
42+
-e PLUGIN_BASE_URL="https://api.github.com/"
43+
-e PLUGIN_UPLOAD_URL="https://uploads.github.com/"
44+
-e PLUGIN_OVERWRITE="true"
45+
-e PLUGIN_FILES="*.sh"
46+
-v $(pwd):$(pwd)
47+
-w $(pwd)
48+
docker.io/woodpeckerci/plugin-release
49+
environment:
50+
GITHUB_TOKEN:
51+
from_secret: github_token
52+
when:
53+
event:
54+
- tag

install-cli.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
set -eo pipefail
3+
shopt -s expand_aliases
4+
5+
check_platform_arch() {
6+
local supported="darwin-amd64 darwin-arm64 linux-amd64 linux-386 linux-arm linux-arm64 windows-386 windows-amd64"
7+
8+
if ! echo "${supported}" | tr ' ' '\n' | grep -q "${PLATFORM}-${ARCH}"; then
9+
cat <<EOF
10+
11+
The Drycc Workflow CLI (drycc) is not currently supported on ${PLATFORM}-${ARCH}.
12+
13+
See https://github.com/drycc/workflow-cli for more information.
14+
15+
EOF
16+
fi
17+
}
18+
19+
PLATFORM="$(uname | tr '[:upper:]' '[:lower:]')"
20+
if [[ "${INSTALL_DRYCC_MIRROR}" == "cn" ]] ; then
21+
DRYCC_BIN_URL_BASE="https://github.com/drycc/workflow-cli/releases"
22+
else
23+
DRYCC_BIN_URL_BASE="https://github.com/drycc/workflow-cli/releases"
24+
fi
25+
26+
# initArch discovers the architecture for this system.
27+
init_arch() {
28+
ARCH=$(uname -m)
29+
case $ARCH in
30+
armv5*) ARCH="armv5";;
31+
armv6*) ARCH="armv6";;
32+
armv7*) ARCH="arm";;
33+
aarch64) ARCH="arm64";;
34+
x86) ARCH="386";;
35+
x86_64) ARCH="amd64";;
36+
i686) ARCH="386";;
37+
i386) ARCH="386";;
38+
esac
39+
}
40+
41+
init_latest_version() {
42+
VERSION=$(curl -Ls $DRYCC_BIN_URL_BASE|grep /drycc/workflow-cli/releases/tag/ | sed -E 's/.*\/drycc\/workflow-cli\/releases\/tag\/(v[0-9\.]+)".*/\1/g' | head -1)
43+
}
44+
45+
init_arch
46+
init_latest_version
47+
check_platform_arch
48+
49+
DRYCC_CLI="drycc-${VERSION}-${PLATFORM}-${ARCH}"
50+
DRYCC_CLI_PATH="${DRYCC_CLI}"
51+
if [ "${VERSION}" != 'stable' ]; then
52+
DRYCC_CLI_PATH="${VERSION}/${DRYCC_CLI_PATH}"
53+
fi
54+
55+
echo "Downloading ${DRYCC_CLI} From Google Cloud Storage..."
56+
echo "Downloading binary from here: ${DRYCC_BIN_URL_BASE}/download/${DRYCC_CLI_PATH}"
57+
curl -fsSL -o drycc "${DRYCC_BIN_URL_BASE}/download/${DRYCC_CLI_PATH}"
58+
59+
chmod +x drycc
60+
61+
cat <<EOF
62+
63+
The Drycc Workflow CLI (drycc) is now available in your current directory.
64+
65+
To learn more about Drycc Workflow, execute:
66+
67+
$ ./drycc --help
68+
69+
You can also move it to other directories, such as:
70+
71+
$ mv $PWD/drycc /usr/local/bin
72+
73+
EOF

0 commit comments

Comments
 (0)