File tree Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Original file line number Diff line number Diff line change 1
1
name : Go CI/CD
2
2
3
+ permissions :
4
+ contents : write
5
+
3
6
on :
4
7
push :
5
8
branches : [ "main" ]
9
+ push :
6
10
tags : [ "v*.*.*" ]
7
11
pull_request :
8
12
branches : [ "main" ]
9
13
10
14
jobs :
11
15
build :
16
+ if : github.event_name != 'push' || startsWith(github.ref, 'refs/heads/') # فقط برای شاخه main
12
17
runs-on : ${{ matrix.os }}
13
18
strategy :
14
19
matrix :
15
20
include :
16
- - os : ubuntu-latest
17
- goos : linux
18
- ext : " "
19
- - os : windows-latest
20
- goos : windows
21
- ext : " .exe"
22
- - os : macos-latest
23
- goos : darwin
24
- ext : " "
21
+ - os : ubuntu-latest; goos: linux; ext: ""
22
+ - os : windows-latest; goos: windows; ext: ".exe"
23
+ - os : macos-latest; goos: darwin; ext: ""
25
24
steps :
26
25
- uses : actions/checkout@v4
27
26
- uses : actions/setup-go@v4
28
27
with :
29
28
go-version : ' 1.23.0'
30
- - name : Build artifact
31
- shell : pwsh
29
+ - name : Build
32
30
env :
33
31
GOOS : ${{ matrix.goos }}
34
32
GOARCH : amd64
35
33
run : |
36
- if ($Env:RUNNER_OS -eq 'Windows') {
37
- New-Item -ItemType Directory -Force -Path bin | Out-Null
38
- } else {
39
- mkdir -p bin
40
- }
41
- go build -v -ldflags "-s -w" -o "bin/terminalapp_${Env:GOOS}_amd64${{ matrix.ext }}" ./cmd/terminalapp/main
34
+ mkdir -p bin
35
+ go build -v -ldflags "-s -w" -o bin/terminalapp_${{ matrix.goos }}_amd64${{ matrix.ext }} ./cmd/terminalapp/main
42
36
- uses : actions/upload-artifact@v4
43
37
with :
44
38
name : terminalapp-${{ matrix.goos }}-amd64
45
39
path : bin/terminalapp_${{ matrix.goos }}_amd64${{ matrix.ext }}
46
40
47
41
release :
42
+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
48
43
needs : build
49
44
runs-on : ubuntu-latest
50
- # if: startsWith(github.ref, 'refs/tags/')
51
45
steps :
52
46
- uses : actions/download-artifact@v4
53
47
with :
You can’t perform that action at this time.
0 commit comments