-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (101 loc) · 4.32 KB
/
lint_and _build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: lint and build
on:
push:
branches: ['prep/**', 'release/**', 'test/**', master]
tags: ['**']
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
cache: true
- name: vars
id: vars
run: |
export commit=$(git rev-parse HEAD)
export short=$(git rev-parse --short HEAD)
export github_tag=${{github.ref_name}}
export tag=$github_tag
export branch=$github_tag
export git_message=$(git rev-list --format=%s --max-count=1 HEAD | tail +2)
export repo_name=${GITHUB_REPOSITORY##*/}
export artifact_name=${repo_name}_$(git rev-parse --short HEAD).tar.gz
export job_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
echo "::set-output name=commit::$commit"
echo "::set-output name=short::$short"
echo "::set-output name=github_tag::$github_tag"
echo "::set-output name=git_message::$git_message"
echo "::set-output name=repo_name::$repo_name"
echo "::set-output name=branch::$branch"
echo "::set-output name=tag::$tag"
echo "::set-output name=artifact_name::$artifact_name"
echo "::set-output name=job_url::$job_url"
- name: show environment
run: |
echo bin_name = ${{inputs.bin_name}}
echo has_ffi = ${{inputs.has_ffi}}
echo event = ${{github.event_name}}
echo github_repository: $GITHUB_REPOSITORY
echo vars.commit = ${{steps.vars.outputs.commit}}
echo vars.short_commit = ${{steps.vars.outputs.short}}
echo vars.github_tag = ${{steps.vars.outputs.github_tag}}
echo vars.git_message = "${{steps.vars.outputs.git_message}}"
echo vars.repo_name = ${{steps.vars.outputs.repo_name}}
echo vars.branch = ${{steps.vars.outputs.branch}}
echo vars.tag = ${{steps.vars.outputs.tag}}
echo vars.artifact_name = ${{steps.vars.outputs.artifact_name}}
echo github.ref = ${{github.ref}}
echo github.ref_name = ${{github.ref_name}}
echo vars.job_url = ${{steps.vars.outputs.job_url}}
- name: install deps
run: sudo apt-get -o Acquire::Retries=3 update && sudo apt-get -o Acquire::Retries=3 install make ftp git bzr curl wget hwloc libhwloc-dev mesa-opencl-icd ocl-icd-opencl-dev -y
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
make lint
- name: Detect changes
run: |
go mod tidy
git status --porcelain
test -z "$(git status --porcelain)"
- name: Build
run: |
go clean --modcache && make
mkdir ./release
mkdir ./release/dashboard
mv ./venus-tool ./release
mv ./dashboard/build ./release/dashboard
- name: Zip Release
uses: TheDoctor0/[email protected]
with:
filename: ${{steps.vars.outputs.artifact_name}}
path: ./release
type: tar
- name: Rename bin file
if: startsWith(github.ref, 'refs/tags/')
run: |
cp ./${{steps.vars.outputs.artifact_name}} ./${{steps.vars.outputs.repo_name}}_${{steps.vars.outputs.tag}}.tar.gz
- name: shasum
if: startsWith(github.ref, 'refs/tags/')
run: shasum -a 256 ./${{steps.vars.outputs.repo_name}}_${{steps.vars.outputs.tag}}.tar.gz > ./${{steps.vars.outputs.repo_name}}_${{steps.vars.outputs.tag}}.sha256
shell: bash
- name: Release
id: release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
continue-on-error: true
with:
files: |
./${{steps.vars.outputs.repo_name}}_${{steps.vars.outputs.tag}}.tar.gz
./${{steps.vars.outputs.repo_name}}_${{steps.vars.outputs.tag}}.sha256
- name: upload artifacts
uses: actions/upload-artifact@v3
if: ${{ steps.vars.outputs.pub_method == 'pushRelease' }}
with:
name: ${{steps.vars.outputs.artifact_name}}
path: ./${{steps.vars.outputs.artifact_name}}
if-no-files-found: error