publish-cli.yaml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. name: Build and Publish CLI
  2. on:
  3. release:
  4. types: [published]
  5. concurrency:
  6. group: publish-cli-${{ github.head_ref || github.run_id }}
  7. cancel-in-progress: true
  8. jobs:
  9. build:
  10. runs-on: ${{ matrix.platform == 'linux/arm64' && 'arm64_runner' || 'ubuntu-latest' }}
  11. if: github.repository == 'langgenius/dify-plugin-daemon'
  12. strategy:
  13. matrix:
  14. include:
  15. - platform: linux/amd64
  16. - platform: linux/arm64
  17. steps:
  18. - name: Checkout code
  19. uses: actions/checkout@v3
  20. - name: Transform platform
  21. run: |
  22. GOARCH=$(echo "${{ matrix.platform }}" | cut -d '/' -f 2)
  23. echo "GOARCH=$GOARCH" >> $GITHUB_ENV
  24. - name: Set up Go
  25. uses: actions/setup-go@v4
  26. with:
  27. go-version: 1.22.x
  28. - name: Build CLI
  29. run: |
  30. go mod tidy
  31. GOOS=windows GOARCH=${{ env.GOARCH }} go build -ldflags "-X 'main.VersionX=v${{ github.event.release.tag_name }}'" -o dify-plugin-windows-${{ env.GOARCH }}.exe ./cmd/commandline
  32. GOOS=darwin GOARCH=${{ env.GOARCH }} go build -ldflags "-X 'main.VersionX=v${{ github.event.release.tag_name }}'" -o dify-plugin-darwin-${{ env.GOARCH }} ./cmd/commandline
  33. GOOS=linux GOARCH=${{ env.GOARCH }} go build -ldflags "-X 'main.VersionX=v${{ github.event.release.tag_name }}'" -o dify-plugin-linux-${{ env.GOARCH }} ./cmd/commandline
  34. - name: Publish CLI
  35. run: |
  36. gh release upload ${{ github.event.release.tag_name }} dify-plugin-windows-${{ env.GOARCH }}.exe --clobber
  37. gh release upload ${{ github.event.release.tag_name }} dify-plugin-darwin-${{ env.GOARCH }} --clobber
  38. gh release upload ${{ github.event.release.tag_name }} dify-plugin-linux-${{ env.GOARCH }} --clobber
  39. env:
  40. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}