diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..79522326 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,35 @@ +name-template: 'v$NEXT_PATCH_VERSION 🌈' +tag-template: 'v$NEXT_PATCH_VERSION' +categories: + - title: '🆕 Features' + labels: + - 'feat' + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + label: 'chore' + - title: '📖 Document' + label: 'doc' + - title: '🚀 CI/CD' + label: 'ci' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch +template: | + ## Changes + + $CHANGES \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..33dfdb6d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: release + +on: + push: + branches: + - dev +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Build Cli + run: | + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o gopeed.exe cmd/gopeed/* + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o gopeed cmd/gopeed/* + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o gopeed cmd/gopeed/* + zip gopeed-windows-x64.zip gopeed.exe + zip gopeed-linux-x64.zip gopeed + zip gopeed-darwin-x64.zip gopeed + - uses: release-drafter/release-drafter@v5 + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload Cli windows + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./gopeed-windows-x64.zip + asset_name: gopeed-${{ steps.create_release.outputs.name }}-windows-x64.zip + asset_content_type: application/zip + - name: Upload Cli linux + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./gopeed-linux-x64.zip + asset_name: gopeed-${{ steps.create_release.outputs.name }}-linux-x64.zip + asset_content_type: application/zip + - name: Upload Cli darwin + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./gopeed-darwin-x64.zip + asset_name: gopeed-${{ steps.create_release.outputs.name }}-darwin-x64.zip + asset_content_type: application/zip \ No newline at end of file diff --git a/_docs/img/cli-demo.gif b/_docs/img/cli-demo.gif new file mode 100644 index 00000000..2cc835fa Binary files /dev/null and b/_docs/img/cli-demo.gif differ diff --git a/_examples/basic/main.go b/_examples/basic/main.go new file mode 100644 index 00000000..02b60d22 --- /dev/null +++ b/_examples/basic/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/monkeyWie/gopeed-core/pkg/base" + "github.com/monkeyWie/gopeed-core/pkg/download" +) + +func main() { + finallyCh := make(chan error) + err := download.Boot(). + URL("https://www.baidu.com/index.html"). + Listener(func(event *download.Event) { + if event.Key == download.EventKeyFinally { + finallyCh <- event.Err + } + }). + Create(&base.Options{ + Connections: 8, + }) + if err != nil { + panic(err) + } + err = <-finallyCh + if err != nil { + fmt.Printf("download fail:%v\n", err) + } else { + fmt.Println("download success") + } +}