Update ci.yml
This commit is contained in:
parent
1d700c8996
commit
e75c33ddab
|
@ -8,7 +8,7 @@ env:
|
||||||
COMMIT_ID: "${{ github.sha }}"
|
COMMIT_ID: "${{ github.sha }}"
|
||||||
PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request."
|
PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request."
|
||||||
LD_FLAGS: "-w -s"
|
LD_FLAGS: "-w -s"
|
||||||
HEAD_REF: "true"
|
UPLOAD_RELEASE: "true"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
@ -42,6 +42,7 @@ jobs:
|
||||||
go-version: 1.18
|
go-version: 1.18
|
||||||
|
|
||||||
- name: Build binary file
|
- name: Build binary file
|
||||||
|
id: build
|
||||||
env:
|
env:
|
||||||
GOOS: ${{ matrix.goos }}
|
GOOS: ${{ matrix.goos }}
|
||||||
GOARCH: ${{ matrix.goarch }}
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
@ -54,19 +55,37 @@ jobs:
|
||||||
export LD_FLAGS="-w -s -X main.VERSION=unknown"
|
export LD_FLAGS="-w -s -X main.VERSION=unknown"
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./
|
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./
|
||||||
- name: Upload artifact
|
echo "::set-output name=status::success"
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
if: true
|
- name: Generate release tag
|
||||||
with:
|
id: tag
|
||||||
name: ${{ matrix.goos }}_${{ matrix.goarch }}
|
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
|
||||||
path: output/
|
run: |
|
||||||
|
echo "::set-output name=release_tag::$(date +"%Y.%m.%d-%H%M")"
|
||||||
|
echo "::set-output name=status::success"
|
||||||
|
|
||||||
- name: Upload firmware to release
|
- name: Upload firmware to release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: true
|
if: steps.tag.outputs.status == 'success' && !cancelled()
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ matrix.goos }}_${{ matrix.goarch }}
|
tag_name: ${{ steps.tag.outputs.release_tag }}
|
||||||
files: output/*
|
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 }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue