|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +VERSION=$1 |
| 4 | + |
| 5 | +ALIYUN="./out/aliyun" |
| 6 | + |
| 7 | +go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=${VERSION}'" -o $ALIYUN main/main.go |
| 8 | + |
| 9 | +FLAGS="oss://aliyun-cli --force --access-key-id ${ACCESS_KEY_ID} --access-key-secret ${ACCESS_KEY_SECRET} --region cn-hangzhou" |
| 10 | + |
| 11 | +# mac amd64 |
| 12 | +${ALIYUN} oss cp ./aliyun-cli-macosx-${VERSION}-amd64.tgz $FLAGS |
| 13 | +# mac arm64 |
| 14 | +${ALIYUN} oss cp ./aliyun-cli-macosx-${VERSION}-arm64.tgz $FLAGS |
| 15 | +# mac universal |
| 16 | +${ALIYUN} oss cp ./aliyun-cli-macosx-${VERSION}-universal.tgz $FLAGS |
| 17 | +# mac pkg |
| 18 | +${ALIYUN} oss cp ./aliyun-cli-${VERSION}.pkg $FLAGS |
| 19 | + # linux amd64 |
| 20 | +${ALIYUN} oss cp ./aliyun-cli-linux-${VERSION}-amd64.tgz $FLAGS |
| 21 | +# linux arm64 |
| 22 | +${ALIYUN} oss cp ./aliyun-cli-linux-${VERSION}-arm64.tgz $FLAGS |
| 23 | +# windows |
| 24 | +${ALIYUN} oss cp ./aliyun-cli-windows-${VERSION}-amd64.zip $FLAGS |
| 25 | + |
| 26 | +if [[ "$VERSION" == *"-beta" ]]; then |
| 27 | + echo "beta. skip." |
| 28 | +else |
| 29 | + cp ./aliyun-cli-macosx-${VERSION}-amd64.tgz ./aliyun-cli-macosx-latest-amd64.tgz |
| 30 | + ${ALIYUN} oss cp ./aliyun-cli-macosx-latest-amd64.tgz $FLAGS |
| 31 | + |
| 32 | + cp ./aliyun-cli-macosx-${VERSION}-arm64.tgz ./aliyun-cli-macosx-latest-arm64.tgz |
| 33 | + ${ALIYUN} oss cp ./aliyun-cli-macosx-latest-arm64.tgz $FLAGS |
| 34 | + |
| 35 | + cp ./aliyun-cli-macosx-${VERSION}-universal.tgz ./aliyun-cli-macosx-latest-universal.tgz |
| 36 | + ${ALIYUN} oss cp ./aliyun-cli-macosx-latest-arm64.tgz $FLAGS |
| 37 | + |
| 38 | + cp ./aliyun-cli-${VERSION}.pkg ./aliyun-cli-latest.pkg |
| 39 | + ${ALIYUN} oss cp ./aliyun-cli-latest.pkg $FLAGS |
| 40 | + |
| 41 | + cp ./aliyun-cli-linux-${VERSION}-amd64.tgz ./aliyun-cli-linux-latest-amd64.tgz |
| 42 | + ${ALIYUN} oss cp ./aliyun-cli-linux-latest-amd64.tgz $FLAGS |
| 43 | + |
| 44 | + cp ./aliyun-cli-linux-${VERSION}-arm64.tgz ./aliyun-cli-linux-latest-arm64.tgz |
| 45 | + ${ALIYUN} oss cp ./aliyun-cli-linux-latest-arm64.tgz $FLAGS |
| 46 | + |
| 47 | + cp ./aliyun-cli-windows-${VERSION}-amd64.zip ./aliyun-cli-windows-latest-amd64.zip |
| 48 | + ${ALIYUN} oss cp ./aliyun-cli-windows-latest-amd64.zip $FLAGS |
| 49 | + # local version |
| 50 | + |
| 51 | + echo ${VERSION} > out/version |
| 52 | + ${ALIYUN} oss cp out/version $FLAGS |
| 53 | + |
| 54 | + RELEASE_ID=$(curl -fsSL \ |
| 55 | + -H "Accept: application/vnd.github+json" \ |
| 56 | + -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 57 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 58 | + https://api.github.com/repos/aliyun/aliyun-cli/releases/tags/$TAG | jq '.["id"]') |
| 59 | + |
| 60 | + DATA='{"draft":false,"prerelease":false,"make_latest":true}' |
| 61 | + |
| 62 | + curl -fsSL \ |
| 63 | + -X PATCH \ |
| 64 | + -H "Accept: application/vnd.github+json" \ |
| 65 | + -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 66 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 67 | + https://api.github.com/repos/aliyun/aliyun-cli/releases/$RELEASE_ID \ |
| 68 | + -d "$DATA" |
| 69 | +fi |
0 commit comments