Skip to content

Commit 17c5fbf

Browse files
Update go.yml
1 parent a111e54 commit 17c5fbf

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

.github/workflows/go.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,47 @@
11
name: Go CI/CD
22

3+
permissions:
4+
contents: write
5+
36
on:
47
push:
58
branches: [ "main" ]
9+
push:
610
tags: [ "v*.*.*" ]
711
pull_request:
812
branches: [ "main" ]
913

1014
jobs:
1115
build:
16+
if: github.event_name != 'push' || startsWith(github.ref, 'refs/heads/') # فقط برای شاخه main
1217
runs-on: ${{ matrix.os }}
1318
strategy:
1419
matrix:
1520
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: ""
2524
steps:
2625
- uses: actions/checkout@v4
2726
- uses: actions/setup-go@v4
2827
with:
2928
go-version: '1.23.0'
30-
- name: Build artifact
31-
shell: pwsh
29+
- name: Build
3230
env:
3331
GOOS: ${{ matrix.goos }}
3432
GOARCH: amd64
3533
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
4236
- uses: actions/upload-artifact@v4
4337
with:
4438
name: terminalapp-${{ matrix.goos }}-amd64
4539
path: bin/terminalapp_${{ matrix.goos }}_amd64${{ matrix.ext }}
4640

4741
release:
42+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
4843
needs: build
4944
runs-on: ubuntu-latest
50-
# if: startsWith(github.ref, 'refs/tags/')
5145
steps:
5246
- uses: actions/download-artifact@v4
5347
with:

0 commit comments

Comments
 (0)