From e75c33ddab6a8a9987b91d5d65e9ac3d55363b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8F=B7?= <2402324010@qq.com> Date: Sun, 19 Mar 2023 19:11:27 +0800 Subject: [PATCH] Update ci.yml --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7cf665..1fafe1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ env: COMMIT_ID: "${{ github.sha }}" PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request." LD_FLAGS: "-w -s" - HEAD_REF: "true" + UPLOAD_RELEASE: "true" jobs: build: @@ -42,6 +42,7 @@ jobs: go-version: 1.18 - name: Build binary file + id: build env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} @@ -54,19 +55,37 @@ jobs: export LD_FLAGS="-w -s -X main.VERSION=unknown" go mod tidy go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./ - - name: Upload artifact - uses: actions/upload-artifact@v2 - if: true - with: - name: ${{ matrix.goos }}_${{ matrix.goarch }} - path: output/ + echo "::set-output name=status::success" + + - name: Generate release tag + id: tag + if: env.UPLOAD_RELEASE == 'true' && !cancelled() + run: | + echo "::set-output name=release_tag::$(date +"%Y.%m.%d-%H%M")" + echo "::set-output name=status::success" - name: Upload firmware to release uses: softprops/action-gh-release@v1 - if: true + if: steps.tag.outputs.status == 'success' && !cancelled() env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ matrix.goos }}_${{ matrix.goarch }} - files: output/* + tag_name: ${{ steps.tag.outputs.release_tag }} + body_path: release.txt + files: /opt/openwrt_packit/output/* + + - name: Delete workflow runs + uses: GitRML/delete-workflow-runs@main + with: + retain_days: 1 + keep_minimum_runs: 3 + + - name: Remove old Releases + uses: dev-drprasad/delete-older-releases@v0.1.0 + if: env.UPLOAD_RELEASE == 'true' && !cancelled() + with: + keep_latest: 3 + delete_tags: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}