diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08663a3..fe92fce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,8 +11,8 @@ jobs: build: strategy: matrix: - platform: [ubuntu-latest] - go-version: [1.17] + platform: [ ubuntu-latest ] + go-version: [ 1.17 ] name: Build runs-on: ${{ matrix.platform }} steps: @@ -38,51 +38,47 @@ jobs: fi - name: Build linux run: | - CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o linux_amd64/alidrive main.go - CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o linux_arm64/alidrive main.go - CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -o linux_arm/alidrive main.go + CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o alidrive_uploader_linux_amd64/alidrive main.go + CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o alidrive_uploader_linux_arm64/alidrive main.go + CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -o alidrive_uploader_linux_arm/alidrive main.go - name: Build windows run: | - CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -tags forceposix -o windows_amd64/alidrive.exe main.go + CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -tags forceposix -o alidrive_uploader_windows_amd64/alidrive.exe main.go - name: Build linux_386 run: | sudo apt-get -y install libc6-dev-i386 - CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -o linux_386/alidrive main.go + CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -o alidrive_uploader_linux_386/alidrive main.go - name: Copy additional files run: | - cp example.config.yaml linux_amd64/config.yaml - cp example.config.yaml linux_arm64/config.yaml - cp example.config.yaml linux_arm/config.yaml - cp example.config.yaml windows_amd64/config.yaml - cp example.config.yaml linux_386/config.yaml + ls | grep "alidrive_uploader_" | awk '{ print "cp example.config.yaml "$0"/example.config.yaml" | "/bin/bash" }' - name: Upload artifacts linux_amd64 uses: actions/upload-artifact@v2 with: name: alidrive_uploader_linux_amd64 - path: linux_amd64 + path: alidrive_uploader_linux_amd64 - name: Upload artifacts linux_arm64 uses: actions/upload-artifact@v2 with: name: alidrive_uploader_linux_arm64 - path: linux_arm64 + path: alidrive_uploader_linux_arm64 - name: Upload artifacts linux_arm uses: actions/upload-artifact@v2 with: name: alidrive_uploader_linux_arm - path: linux_arm + path: alidrive_uploader_linux_arm - name: Upload artifacts windows_amd64 uses: actions/upload-artifact@v2 with: name: alidrive_uploader_windows_amd64 - path: windows_amd64 + path: alidrive_uploader_windows_amd64 - name: Upload artifacts linux_386 uses: actions/upload-artifact@v2 with: name: alidrive_uploader_linux_386 - path: linux_386 \ No newline at end of file + path: alidrive_uploader_linux_386 \ No newline at end of file diff --git a/.github/workflows/build_dev.yml b/.github/workflows/build_dev.yml new file mode 100644 index 0000000..35b55d8 --- /dev/null +++ b/.github/workflows/build_dev.yml @@ -0,0 +1,84 @@ +name: build dev + +on: + push: + branches: [ dev ] + pull_request: + branches: [ dev ] + +jobs: + + build: + strategy: + matrix: + platform: [ ubuntu-latest ] + go-version: [ 1.17 ] + name: Build + runs-on: ${{ matrix.platform }} + steps: + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + sudo apt-get update + sudo apt-get -y install gcc-mingw-w64-x86-64 + sudo apt-get -y install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross + sudo apt-get -y install gcc-aarch64-linux-gnu libc6-dev-arm64-cross + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + - name: Build linux + run: | + CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o alidrive_uploader_linux_amd64/alidrive main.go + CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o alidrive_uploader_linux_arm64/alidrive main.go + CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -o alidrive_uploader_linux_arm/alidrive main.go + - name: Build windows + run: | + CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -tags forceposix -o alidrive_uploader_windows_amd64/alidrive.exe main.go + - name: Build linux_386 + run: | + sudo apt-get -y install libc6-dev-i386 + CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -o alidrive_uploader_linux_386/alidrive main.go + + - name: Copy additional files + run: | + ls | grep "alidrive_uploader_" | awk '{ print "cp example.config.yaml "$0"/example.config.yaml" | "/bin/bash" }' + + - name: Upload artifacts linux_amd64 + uses: actions/upload-artifact@v2 + with: + name: alidrive_uploader_linux_amd64 + path: alidrive_uploader_linux_amd64 + + - name: Upload artifacts linux_arm64 + uses: actions/upload-artifact@v2 + with: + name: alidrive_uploader_linux_arm64 + path: alidrive_uploader_linux_arm64 + + - name: Upload artifacts linux_arm + uses: actions/upload-artifact@v2 + with: + name: alidrive_uploader_linux_arm + path: alidrive_uploader_linux_arm + + - name: Upload artifacts windows_amd64 + uses: actions/upload-artifact@v2 + with: + name: alidrive_uploader_windows_amd64 + path: alidrive_uploader_windows_amd64 + + - name: Upload artifacts linux_386 + uses: actions/upload-artifact@v2 + with: + name: alidrive_uploader_linux_386 + path: alidrive_uploader_linux_386 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5b0a7fd..6461a89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,28 +38,22 @@ jobs: fi - name: Build linux run: | - CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o linux_amd64/alidrive main.go - CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o linux_arm64/alidrive main.go - CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -o linux_arm/alidrive main.go + CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o alidrive_uploader_linux_amd64/alidrive main.go + CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o alidrive_uploader_linux_arm64/alidrive main.go + CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -o alidrive_uploader_linux_arm/alidrive main.go - name: Build windows run: | - CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -tags forceposix -o windows_amd64/alidrive.exe main.go + CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -tags forceposix -o alidrive_uploader_windows_amd64/alidrive.exe main.go - name: Build linux_386 run: | sudo apt-get -y install libc6-dev-i386 - CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -o linux_386/alidrive main.go + CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -o alidrive_uploader_linux_386/alidrive main.go - name: compress run: | - cp example.config.yaml linux_arm64/config.yaml - cp example.config.yaml linux_amd64/config.yaml - cp example.config.yaml linux_arm/config.yaml - cp example.config.yaml linux_386/config.yaml - cp example.config.yaml windows_amd64/config.yaml - tar -czvf alidrive_uploader_linux_amd64.tar.gz linux_amd64 - tar -czvf alidrive_uploader_linux_arm64.tar.gz linux_arm64 - tar -czvf alidrive_uploader_linux_arm.tar.gz linux_arm - tar -czvf alidrive_uploader_linux_386.tar.gz linux_386 - zip -r alidrive_uploader_windows_amd64.zip windows_amd64 + ls | grep "alidrive_uploader_" | awk '{ print "cp example.config.yaml "$0"/example.config.yaml" | "/bin/bash" }' + ls | grep "linux" | awk '{ print "tar -zcvf "$0".tar.gz "$0 | "/bin/bash" }' + zip -r alidrive_uploader_windows_amd64.zip alidrive_uploader_windows_amd64 + - name: Build Changelog id: github_release uses: mikepenz/release-changelog-builder-action@main diff --git a/README.md b/README.md index 133c4df..6f2f315 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ ![](docs/preview_1.gif) ## 使用方法 - +```shell +curl -sL https://raw.githubusercontent.com/aoaostar/alidrive-uploader/v2/install.sh | bash +``` * 重命名`example.config.yaml`为`config.yaml` * 填写好`config.yaml`的内容 diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..1330b82 --- /dev/null +++ b/install.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -e +hash tar uname grep curl head + +OS="$(uname)" +case $OS in + Linux) + OS='linux' + ;; + Darwin) + OS='darwin' + ;; + *) + echo 'OS not supported' + exit 2 + ;; +esac + +ARCH="$(uname -m)" +case $ARCH in + x86_64|amd64) + ARCH='amd64' + ;; + aarch64) + ARCH='arm64' + ;; + i?86|x86) + ARCH='386' + ;; + arm*) + ARCH='arm' + ;; + *) + echo 'OS type not supported' + exit 2 + ;; +esac + + +Install() +{ + echo '正在下载阿里云盘上传工具...' + CORE_DOWNLOAD_URL=$(curl -fsSL https://api.github.com/repos/aoaostar/alidrive-uploader/releases/latest | grep "browser_download_url.*$OS.*$ARCH" | cut -d '"' -f 4) + curl -L "$CORE_DOWNLOAD_URL" | tar -xz + #================================================================== + echo '================================================' + echo '阿里云盘上传工具下载完成' +} + +Install