Skip to content

Commit a6f7149

Browse files
authored
optimize: optimize the workflow (#9)
* optimize: optimize the workflow * optimize: optimize the workflow * optimize: optimize the workflow * optimize: optimize the workflow
1 parent 383fa26 commit a6f7149

File tree

2 files changed

+64
-26
lines changed

2 files changed

+64
-26
lines changed

.github/workflows/build.yml

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,45 @@ on:
2424
push:
2525
branches: [ "main" ]
2626
pull_request:
27-
branches:
28-
- 'main'
27+
branches: [ "main" ]
2928

3029
jobs:
31-
3230
build:
33-
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
os: [ubuntu-latest, macos-latest]
34+
include:
35+
- os: ubuntu-latest
36+
goos: linux
37+
ext: ""
38+
- os: macos-latest
39+
goos: darwin
40+
ext: ""
41+
runs-on: ${{ matrix.os }}
42+
timeout-minutes: 15
43+
3444
steps:
35-
- uses: actions/checkout@v3
45+
- name: Checkout Code
46+
uses: actions/checkout@v4
47+
48+
- name: Setup Go
49+
uses: actions/setup-go@v5
50+
with:
51+
go-version: "1.21"
52+
check-latest: true
3653

37-
- name: Set up Go
38-
uses: actions/setup-go@v4
39-
with:
40-
go-version: '1.20'
54+
- name: Configure Build
55+
shell: bash
56+
run: |
57+
echo "GOOS=${{ matrix.goos }}" >> $GITHUB_ENV
58+
echo "GOARCH=amd64" >> $GITHUB_ENV
59+
echo "OUTPUT=seata-ctl-${{ matrix.goos }}-amd64${{ matrix.ext }}" >> $GITHUB_ENV
4160
42-
- name: Build
43-
run: go build .
61+
- name: Build
62+
run: go build -v -o ${{ env.OUTPUT }} .
4463

45-
- name: Upload Artifacts
46-
uses: actions/upload-artifact@v3
47-
with:
48-
name: seata-ctl-linux-amd64
49-
path: ./seata-ctl
64+
- name: Upload Artifacts
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: ${{ env.OUTPUT }}
68+
path: ${{ env.OUTPUT }}

.github/workflows/go-lint.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,36 @@ on:
2424
push:
2525
branches: [ "main" ]
2626
pull_request:
27-
branches:
28-
- 'main'
27+
branches: [ "main" ]
2928

3029
jobs:
31-
32-
build:
33-
runs-on: ubuntu-latest
30+
lint:
31+
name: Linter Check
32+
runs-on: ubuntu-22.04
33+
timeout-minutes: 10
3434
steps:
35-
- uses: actions/checkout@v3
35+
- name: Checkout Code
36+
uses: actions/checkout@v4
37+
38+
- name: Setup Go
39+
uses: actions/setup-go@v4
40+
with:
41+
go-version: '1.21'
42+
43+
- name: Install golangci-lint
44+
run: |
45+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.0
46+
47+
- name: Cache golangci-lint
48+
uses: actions/cache@v3
49+
with:
50+
path: ~/.cache/golangci-lint
51+
key: ${{ runner.os }}-gci-${{ hashFiles('**/go.mod') }}
52+
restore-keys: |
53+
${{ runner.os }}-gci-
54+
55+
- name: Run Linter
56+
run: |
57+
export PATH=$PATH:$(go env GOPATH)/bin
58+
golangci-lint run --timeout 5m -v
3659
37-
- name: Lint check
38-
run: |
39-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/local/bin v1.51.2
40-
golangci-lint run

0 commit comments

Comments
 (0)