-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (100 loc) · 3.2 KB
/
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
name: Build
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
defaults:
run:
shell: bash
env:
GO_VERSION: 1.18.10
# GO_VERSION: 1.16.15
OSEXT_MAP: '{"Linux": "linux", "macOS": "macos", "Windows": "exe"}'
CACHE_PREFIX: upload-${{ github.run_id }}-${{ github.run_attempt }}
SAVE_ARTIFACT: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}
jobs:
# Job1: build and test
build:
# For various OSes
name: Build on ${{ matrix.vm-os }}
runs-on: ${{ matrix.vm-os }}
strategy:
max-parallel: 10
fail-fast: false
matrix:
vm-os: [ubuntu-20.04, macos-12, windows-2022]
outputs:
save_artifact: ${{ env.SAVE_ARTIFACT }}
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Go Build
env:
OSEXT: ${{ fromJSON(env.OSEXT_MAP)[runner.os] }}
run: |
export
git status
go version
make build
make artifact
- name: Go Run
run: |
make preview
- name: Cache Artifact
uses: actions/cache/save@v3
if: ${{ fromJSON(env.SAVE_ARTIFACT) }}
with:
path: _upload
key: ${{ env.CACHE_PREFIX }}-${{ runner.os }}
enableCrossOsArchive: true
- name: Analyze
if: ${{ runner.os == 'Linux' }}
run: |
# tokei -- count
wget -cqL https://github.com/XAMPPRocky/tokei/releases/download/v12.1.2/tokei-i686-unknown-linux-musl.tar.gz -O tokei.tgz
tar zxf tokei.tgz tokei && chmod +x tokei && $SUDO mv tokei /usr/local/bin && rm tokei.tgz
echo "=== Tokei Result ==="
tokei
# revive -- lint
wget -cqL https://github.com/mgechev/revive/releases/download/v1.3.3/revive_linux_amd64.tar.gz -O revive.tgz
tar zxf revive.tgz revive && chmod +x revive && $SUDO mv revive /usr/local/bin && rm revive.tgz
wget -cqL https://bitbucket.org/ai69/common/raw/master/revive.toml -O revive.toml
echo "=== Revive Result ==="
revive -config revive.toml -formatter friendly ./...
# Job2: collect artifacts
collect:
name: Upload Artifact
runs-on: ubuntu-latest
needs: build
if: ${{ fromJSON(needs.build.outputs.save_artifact) }}
steps:
- name: Restore Cache Linux
uses: actions/cache/restore@v3
with:
path: _upload
key: ${{ env.CACHE_PREFIX }}-Linux
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: Restore Cache macOS
uses: actions/cache/restore@v3
with:
path: _upload
key: ${{ env.CACHE_PREFIX }}-macOS
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: Restore Cache Windows
uses: actions/cache/restore@v3
with:
path: _upload
key: ${{ env.CACHE_PREFIX }}-Windows
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: dist-gh${{ github.run_number }}
path: _upload