Skip to content

Commit

Permalink
Upload the assets to OSS
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Aug 17, 2023
1 parent e39fa1d commit a574a32
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 5 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ jobs:
run: |
TAG=${{ github.ref_name }}
VERSION=${TAG#v}
GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=${VERSION}'" -o out/aliyun.amd64 main/main.go
GOOS=darwin GOARCH=arm64 go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=${VERSION}'" -o out/aliyun.arm64 main/main.go
GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=${VERSION}'" -o out/aliyun main/main.go
tar zcvf out/aliyun-cli-macosx-${VERSION}-amd64.tgz -C out aliyun
bash tools/upload_asset.sh ${VERSION} out/aliyun-cli-macosx-${VERSION}-amd64.tgz
cp out/aliyun out/aliyun.amd64
GOOS=darwin GOARCH=arm64 go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=${VERSION}'" -o out/aliyun main/main.go
tar zcvf out/aliyun-cli-macosx-${VERSION}-arm64.tgz -C out aliyun
bash tools/upload_asset.sh ${VERSION} out/aliyun-cli-macosx-${VERSION}-arm64.tgz
cp out/aliyun out/aliyun.arm64
lipo -output out/aliyun -create out/aliyun.amd64 out/aliyun.arm64
tar zcvf out/aliyun-cli-macosx-${VERSION}-universal.tgz -C out aliyun
bash tools/upload_asset.sh ${VERSION} out/aliyun-cli-macosx-${VERSION}-universal.tgz
Expand Down Expand Up @@ -102,6 +108,8 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }}
ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -112,4 +120,5 @@ jobs:
TAG=${{ github.ref_name }}
VERSION=${TAG#v}
bash tools/download_assets.sh ${VERSION}
bash tools/upload_asset.sh ${VERSION} SHASUMS256.txt
bash tools/upload_asset.sh ${VERSION} SHASUMS256.txt
bash tools/finish_release.sh ${VERSION}
2 changes: 1 addition & 1 deletion tools/create_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

TAGNAME=$1

DATA='{"tag_name":"'$TAGNAME'","name":"'$TAGNAME'","body":"TBD","draft":false,"prerelease":true,"generate_release_notes":false}'
DATA='{"tag_name":"'$TAGNAME'","name":"'$TAGNAME'","draft":false,"prerelease":true,"generate_release_notes":true}'

curl -fsSL \
-H "Accept: application/vnd.github+json" \
Expand Down
2 changes: 2 additions & 0 deletions tools/download_assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ RELEASE_ID=$(curl -fsSL \
https://api.github.com/repos/aliyun/aliyun-cli/releases/tags/v$VERSION | jq '.["id"]')

LIST=(
"aliyun-cli-macosx-$VERSION-amd64.tgz"
"aliyun-cli-macosx-$VERSION-arm64.tgz"
"aliyun-cli-$VERSION.pkg"
"aliyun-cli-macosx-$VERSION-universal.tgz"
"aliyun-cli-linux-$VERSION-amd64.tgz"
Expand Down
69 changes: 69 additions & 0 deletions tools/finish_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash

VERSION=$1

ALIYUN="./out/aliyun"

go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=${VERSION}'" -o $ALIYUN main/main.go

FLAGS="oss://aliyun-cli --force --access-key-id ${ACCESS_KEY_ID} --access-key-secret ${ACCESS_KEY_SECRET} --region cn-hangzhou"

# mac amd64
${ALIYUN} oss cp ./aliyun-cli-macosx-${VERSION}-amd64.tgz $FLAGS
# mac arm64
${ALIYUN} oss cp ./aliyun-cli-macosx-${VERSION}-arm64.tgz $FLAGS
# mac universal
${ALIYUN} oss cp ./aliyun-cli-macosx-${VERSION}-universal.tgz $FLAGS
# mac pkg
${ALIYUN} oss cp ./aliyun-cli-${VERSION}.pkg $FLAGS
# linux amd64
${ALIYUN} oss cp ./aliyun-cli-linux-${VERSION}-amd64.tgz $FLAGS
# linux arm64
${ALIYUN} oss cp ./aliyun-cli-linux-${VERSION}-arm64.tgz $FLAGS
# windows
${ALIYUN} oss cp ./aliyun-cli-windows-${VERSION}-amd64.zip $FLAGS

if [[ "$VERSION" == *"-beta" ]]; then
echo "beta. skip."
else
cp ./aliyun-cli-macosx-${VERSION}-amd64.tgz ./aliyun-cli-macosx-latest-amd64.tgz
${ALIYUN} oss cp ./aliyun-cli-macosx-latest-amd64.tgz $FLAGS

cp ./aliyun-cli-macosx-${VERSION}-arm64.tgz ./aliyun-cli-macosx-latest-arm64.tgz
${ALIYUN} oss cp ./aliyun-cli-macosx-latest-arm64.tgz $FLAGS

cp ./aliyun-cli-macosx-${VERSION}-universal.tgz ./aliyun-cli-macosx-latest-universal.tgz
${ALIYUN} oss cp ./aliyun-cli-macosx-latest-arm64.tgz $FLAGS

cp ./aliyun-cli-${VERSION}.pkg ./aliyun-cli-latest.pkg
${ALIYUN} oss cp ./aliyun-cli-latest.pkg $FLAGS

cp ./aliyun-cli-linux-${VERSION}-amd64.tgz ./aliyun-cli-linux-latest-amd64.tgz
${ALIYUN} oss cp ./aliyun-cli-linux-latest-amd64.tgz $FLAGS

cp ./aliyun-cli-linux-${VERSION}-arm64.tgz ./aliyun-cli-linux-latest-arm64.tgz
${ALIYUN} oss cp ./aliyun-cli-linux-latest-arm64.tgz $FLAGS

cp ./aliyun-cli-windows-${VERSION}-amd64.zip ./aliyun-cli-windows-latest-amd64.zip
${ALIYUN} oss cp ./aliyun-cli-windows-latest-amd64.zip $FLAGS
# local version

echo ${VERSION} > out/version
${ALIYUN} oss cp out/version $FLAGS

RELEASE_ID=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/aliyun/aliyun-cli/releases/tags/$TAG | jq '.["id"]')

DATA='{"draft":false,"prerelease":false,"make_latest":true}'

curl -fsSL \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/aliyun/aliyun-cli/releases/$RELEASE_ID \
-d "$DATA"
fi
1 change: 0 additions & 1 deletion tools/upload_asset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ else
TYPE=application/zip
fi


RELEASE_ID=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
Expand Down

0 comments on commit a574a32

Please sign in to comment.