From 4a2877c0841b4c2f99b6eb2352f0e893d0a0831a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8F=B7?= <2402324010@qq.com> Date: Sat, 8 Apr 2023 10:53:52 +0800 Subject: [PATCH] Create ci.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整构建版本设置,修复应用更新问题 --- .github/workflows/ci.yml | 42 +++++++--------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd9e9f0..549f2ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,6 @@ 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" - UPLOAD_RELEASE: "true" jobs: build: @@ -34,14 +33,14 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - + - name: Fetch all tags + run: git fetch --force --tags - name: Set up Go uses: actions/setup-go@v3 with: go-version: 1.18 - name: Build binary file - id: build env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} @@ -54,36 +53,9 @@ jobs: export LD_FLAGS="-w -s -X main.VERSION=unknown" go mod tidy go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./ - echo "FIRMWARE=$PWD/output/*" >> $GITHUB_ENV - - - 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: steps.tag.outputs.status == 'success' && !cancelled() - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload artifact + uses: actions/upload-artifact@v2 + if: ${{ !github.head_ref }} with: - tag_name: ${{ steps.tag.outputs.release_tag }} - files: ${{ env.FIRMWARE }} - - - 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 }} - + name: ${{ matrix.goos }}_${{ matrix.goarch }} + path: output/