clash/.github/workflows/go.yml

72 lines
1.9 KiB
YAML
Raw Normal View History

2019-08-15 03:40:40 +00:00
name: Go
2021-07-01 14:49:29 +00:00
on: [push]
2019-08-15 03:40:40 +00:00
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
2019-10-14 02:40:00 +00:00
- name: Setup Go
2020-06-04 02:38:30 +00:00
uses: actions/setup-go@v2
2019-08-15 03:40:40 +00:00
with:
2021-08-18 05:26:23 +00:00
go-version: 1.17
2019-08-15 03:40:40 +00:00
- name: Check out code into the Go module directory
2020-06-04 02:38:30 +00:00
uses: actions/checkout@v2
2019-11-06 04:05:18 +00:00
- name: Cache go module
2020-06-04 02:38:30 +00:00
uses: actions/cache@v2
2019-11-06 04:05:18 +00:00
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
2019-08-15 03:40:40 +00:00
2020-08-25 14:32:23 +00:00
- name: Get dependencies, run test and static check
2019-08-15 03:40:40 +00:00
run: |
go test ./...
2020-08-25 14:32:23 +00:00
go vet ./...
go install honnef.co/go/tools/cmd/staticcheck@latest
2020-08-25 14:32:23 +00:00
staticcheck -- $(go list ./...)
2019-10-14 02:40:00 +00:00
- name: Build
2021-07-01 14:49:29 +00:00
#if: startsWith(github.ref, 'refs/tags/')
2019-10-14 02:40:00 +00:00
env:
NAME: clash
BINDIR: bin
run: make -j releases
2021-07-01 14:49:29 +00:00
- name: Prepare upload
run: |
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
echo "FILE_SHA=$(git describe --tags --always 2>/dev/null)" >> $GITHUB_ENV
- name: Upload files to Artifacts
uses: actions/upload-artifact@v2
with:
name: clash_${{ env.FILE_SHA }}${{ env.FILE_DATE }}
path: |
bin/*
2019-10-14 02:40:00 +00:00
- name: Upload Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: bin/*
draft: true
2021-07-01 14:49:29 +00:00
- name: Delete workflow runs
uses: GitRML/delete-workflow-runs@main
with:
retain_days: 1
keep_minimum_runs: 2
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@v0.2.0
if: startsWith(github.ref, 'refs/tags/') && !cancelled()
with:
keep_latest: 1
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}