From c0876524647f3f497e11c1dd8a037c9a85f47c6f Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Thu, 7 Nov 2024 13:28:12 +0800 Subject: [PATCH] feat: ci for cli auto publish --- .github/workflows/publish-cli.yaml | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/publish-cli.yaml diff --git a/.github/workflows/publish-cli.yaml b/.github/workflows/publish-cli.yaml new file mode 100644 index 0000000..39d5b56 --- /dev/null +++ b/.github/workflows/publish-cli.yaml @@ -0,0 +1,43 @@ +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: | + PLATFORM_TRANSFORMED=$(echo "${{ matrix.platform }}" | tr '/' '-') + echo "PLATFORM_TRANSFORMED=$PLATFORM_TRANSFORMED" >> $GITHUB_ENV + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.22.x + + - name: Build CLI + run: | + go mod tidy + go build -o dify-plugin-${{ env.PLATFORM_TRANSFORMED }} ./cmd/commandline + + - name: Publish CLI + run: | + gh release upload ${{ github.event.release.tag_name }} dify-plugin-${{ env.PLATFORM_TRANSFORMED }} --clobber + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}