-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (112 loc) · 3.52 KB
/
build.yml
File metadata and controls
132 lines (112 loc) · 3.52 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
name: Build & Release
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
workflow_dispatch:
# 같은 브랜치/PR에서 새 커밋이 오면 이전 실행 취소
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set version tag
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
else
echo "VERSION=dev" >> $GITHUB_ENV
fi
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
- name: Build macOS ARM64
env:
CGO_ENABLED: 1
GOOS: darwin
GOARCH: arm64
run: |
go build -ldflags="-s -w" -o build/SwordMacro-darwin-arm64 ./cmd/sword-macro
- name: Build macOS AMD64
env:
CGO_ENABLED: 1
GOOS: darwin
GOARCH: amd64
run: |
go build -ldflags="-s -w" -o build/SwordMacro-darwin-amd64 ./cmd/sword-macro
- name: Create Universal Binary
run: |
lipo -create -output build/SwordMacro-macOS \
build/SwordMacro-darwin-arm64 \
build/SwordMacro-darwin-amd64
- name: Create ZIP
run: |
cd build && zip "SwordMacro-mac-${VERSION}.zip" SwordMacro-macOS
- name: Upload macOS artifact
uses: actions/upload-artifact@v4
with:
name: SwordMacro-mac-${{ env.VERSION }}
path: build/SwordMacro-mac-${{ env.VERSION }}.zip
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set version tag
shell: bash
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
else
echo "VERSION=dev" >> $GITHUB_ENV
fi
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
- name: Build Windows AMD64
env:
CGO_ENABLED: 1
run: |
go build -ldflags="-s -w" -o build/SwordMacro.exe ./cmd/sword-macro
- name: Create ZIP
run: |
Compress-Archive -Path build/SwordMacro.exe -DestinationPath "SwordMacro-win-${{ env.VERSION }}.zip"
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: SwordMacro-win-${{ env.VERSION }}
path: SwordMacro-win-${{ env.VERSION }}.zip
release:
needs: [build-macos, build-windows]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure
run: ls -R artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/SwordMacro-mac-${{ env.VERSION }}/SwordMacro-mac-${{ env.VERSION }}.zip
artifacts/SwordMacro-win-${{ env.VERSION }}/SwordMacro-win-${{ env.VERSION }}.zip
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}