From e9bf80f89564428e56cdbb68efd86a08487f6e27 Mon Sep 17 00:00:00 2001 From: suxb201 Date: Tue, 27 Sep 2022 18:52:45 +0800 Subject: [PATCH] Update release.yml --- .github/workflows/release.yml | 36 ++++++++++++++++++++++--- build.sh | 50 +++++++++++++++++++---------------- 2 files changed, 60 insertions(+), 26 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f9bb2c..7ae0335 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,12 +26,42 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: "Upload release asset" + - name: "Upload release linux-amd64" uses: actions/upload-release-asset@v1 with: upload_url: ${{ steps.release.outputs.upload_url }} - asset_path: ./bin/redis-shake.tar.gz - asset_name: redis-shake.tar.gz + asset_path: ./bin/redis-shake-linux-amd64.tar.gz + asset_name: redis-shake-linux-amd64.tar.gz + asset_content_type: application/gzip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Upload release linux-arm64" + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.release.outputs.upload_url }} + asset_path: ./bin/redis-shake-linux-arm64.tar.gz + asset_name: redis-shake-linux-arm64.tar.gz + asset_content_type: application/gzip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Upload release darwin-amd64" + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.release.outputs.upload_url }} + asset_path: ./bin/redis-shake-darwin-amd64.tar.gz + asset_name: redis-shake-darwin-amd64.tar.gz + asset_content_type: application/gzip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Upload release darwin-arm64" + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.release.outputs.upload_url }} + asset_path: ./bin/redis-shake-darwin-arm64.tar.gz + asset_name: redis-shake-darwin-arm64.tar.gz asset_content_type: application/gzip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.sh b/build.sh index 19f5cf6..50f99a1 100755 --- a/build.sh +++ b/build.sh @@ -7,31 +7,35 @@ BIN_DIR=$(pwd)/bin/ rm -rf "$BIN_DIR" mkdir -p "$BIN_DIR" -# build the current platform -echo "try build for current platform" -go build -v -trimpath -o "$BIN_DIR/redis-shake" "./cmd/redis-shake" -echo "build success" +cp sync.toml "$BIN_DIR" +cp restore.toml "$BIN_DIR" +cp -r filters "$BIN_DIR" +cp -r scripts/cluster_helper "$BIN_DIR" + +dist() { + echo "try build GOOS=$1 GOARCH=$2" + export GOOS=$g + export GOARCH=$a + go build -v -trimpath -o "$BIN_DIR/redis-shake" "./cmd/redis-shake" + unset GOOS + unset GOARCH + echo "build success GOOS=$1 GOARCH=$2" + cd "$BIN_DIR" + tar -czvf ./redis-shake-"$1"-"$2".tar.gz ./sync.toml ./restore.toml ./redis-shake ./filters ./cluster_helper + cd .. +} if [ "$1" == "dist" ]; then - echo "[ DIST ]" - for g in "linux" "darwin"; do - for a in "amd64" "arm64"; do - echo "try build GOOS=$g GOARCH=$a" - export GOOS=$g - export GOARCH=$a - go build -v -trimpath -o "$BIN_DIR/redis-shake-$g-$a" "./cmd/redis-shake" - unset GOOS - unset GOARCH - echo "build success" + echo "[ DIST ]" + for g in "linux" "darwin"; do + for a in "amd64" "arm64"; do + dist "$g" "$a" + done done - done - cp sync.toml "$BIN_DIR" - cp restore.toml "$BIN_DIR" - cp -r filters "$BIN_DIR" - cp -r scripts/cluster_helper "$BIN_DIR" - cd "$BIN_DIR" - tar -czvf ./redis-shake.tar.gz ./sync.toml ./restore.toml ./redis-shake-* ./filters ./cluster_helper - rm -rf ./filters - cd .. fi + +# build the current platform +echo "try build for current platform" +go build -v -trimpath -o "$BIN_DIR/redis-shake" "./cmd/redis-shake" +echo "build success"