name: Build and Publish CLI on: release: types: [published] concurrency: group: publish-cli-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: build: runs-on: ${{ matrix.platform == 'linux/arm64' && 'arm64_runner' || 'ubuntu-latest' }} if: github.repository == 'langgenius/dify-plugin-daemon' strategy: matrix: include: - platform: linux/amd64 - platform: linux/arm64 steps: - name: Checkout code uses: actions/checkout@v3 - name: Transform platform run: | GOARCH=$(echo "${{ matrix.platform }}" | cut -d '/' -f 2) echo "GOARCH=$GOARCH" >> $GITHUB_ENV - name: Set up Go uses: actions/setup-go@v4 with: go-version: 1.22.x - name: Build CLI run: | go mod tidy GOOS=windows GOARCH=${{ env.GOARCH }} go build -ldflags "-X 'main.VersionX=v${{ github.event.release.tag_name }}'" -o dify-plugin-windows-${{ env.GOARCH }} ./cmd/commandline 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 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 - name: Publish CLI run: | gh release upload ${{ github.event.release.tag_name }} dify-plugin-windows-${{ env.GOARCH }} --clobber gh release upload ${{ github.event.release.tag_name }} dify-plugin-darwin-${{ env.GOARCH }} --clobber gh release upload ${{ github.event.release.tag_name }} dify-plugin-linux-${{ env.GOARCH }} --clobber env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}