forked from zgsm-sangfor/codebase-indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (195 loc) · 7.14 KB
/
Copy pathbuild-all-platforms.yml
File metadata and controls
221 lines (195 loc) · 7.14 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Build and Package All Platforms
on:
push:
tags:
- '*'
jobs:
build:
# 使用矩阵策略来定义不同的操作系统和架构组合
strategy:
fail-fast: false
matrix:
include:
# Linux amd64
- os: ubuntu-latest
goos: linux
goarch: amd64
artifact_name: codebase-indexer-linux-amd64
# Linux arm64
- os: ubuntu-latest
goos: linux
goarch: arm64
artifact_name: codebase-indexer-linux-arm64
# Linux 386
- os: ubuntu-latest
goos: linux
goarch: 386
artifact_name: codebase-indexer-linux-386
# Linux arm
- os: ubuntu-latest
goos: linux
goarch: arm
artifact_name: codebase-indexer-linux-arm
# Windows amd64
- os: windows-latest
goos: windows
goarch: amd64
artifact_name: codebase-indexer-windows-amd64
# Windows 386 - temporarily disabled
# - os: windows-latest
# goos: windows
# goarch: 386
# artifact_name: codebase-indexer-windows-386
# Windows arm64 - temporarily disabled
# - os: windows-latest
# goos: windows
# goarch: arm64
# artifact_name: codebase-indexer-windows-arm64
# macOS amd64
- os: macos-latest
goos: darwin
goarch: amd64
artifact_name: codebase-indexer-darwin-amd64
# macOS ARM64 (Apple Silicon)
- os: macos-latest
goos: darwin
goarch: arm64
artifact_name: codebase-indexer-darwin-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.4'
- name: Install cross-compilation dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
# Install base tools first
sudo apt-get install -y musl-tools
# Install cross-compilation tools without multilib conflicts
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf
# Install multilib support separately if needed for 386 architecture
if [ "${{ matrix.goarch }}" == "386" ]; then
sudo apt-get install -y gcc-multilib
fi
- name: Install cross-compilation dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
# Windows already has MinGW-w64 installed by default
# Just verify the compilers are available
gcc --version
echo "Windows cross-compilation tools are available by default"
- name: Install cross-compilation dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
# macOS cross-compilation tools are available by default
clang --version
echo "macOS cross-compilation tools are available by default"
- name: Build for ${{ matrix.goos }} ${{ matrix.goarch }}
shell: bash
run: |
echo "Starting build for ${{ matrix.goos }} ${{ matrix.goarch }} version ${{ github.ref_name }}"
echo "Current directory: $(pwd)"
echo "Directory contents:"
ls -la
# Make build script executable
chmod +x scripts/build.sh
# Run build script with error handling
echo "Running build script..."
if ! ./scripts/build.sh "${{ matrix.goos }}" "${{ matrix.goarch }}" "${{ github.ref_name }}"; then
echo "Build script failed with exit code $?"
echo "Checking if scripts directory exists:"
if [ -d "scripts" ]; then
echo "Scripts directory contents:"
ls -la scripts/
else
echo "Scripts directory does not exist"
fi
exit 1
fi
echo "Build script completed successfully"
- name: Check build output
shell: bash
run: |
echo "Checking if build directory exists..."
echo "Current directory: $(pwd)"
if [ -d "bin" ]; then
echo "bin directory exists, contents:"
ls -la bin/
if [ -d "bin/${{ github.ref_name }}" ]; then
echo "Build directory exists, contents:"
ls -la "bin/${{ github.ref_name }}/"
# Check if the expected executable file exists
EXPECTED_FILE="codebase-indexer-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}"
if [ "${{ matrix.goos }}" = "windows" ]; then
EXPECTED_FILE="${EXPECTED_FILE}.exe"
fi
if [ -f "bin/${{ github.ref_name }}/$EXPECTED_FILE" ]; then
echo "Expected executable file exists: $EXPECTED_FILE"
echo "File details:"
ls -la "bin/${{ github.ref_name }}/$EXPECTED_FILE"
else
echo "Expected executable file does not exist: $EXPECTED_FILE"
echo "Available files in build directory:"
ls -la "bin/${{ github.ref_name }}/"
exit 1
fi
else
echo "Build directory does not exist: bin/${{ github.ref_name }}"
exit 1
fi
else
echo "bin directory does not exist"
echo "Current directory contents:"
ls -la
exit 1
fi
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}-${{ github.ref_name }}
path: |
bin/${{ github.ref_name }}/codebase-indexer-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}*
retention-days: 30
upload-release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release-assets
find artifacts -name "codebase-indexer-*" -type f | while read file; do
cp "$file" release-assets/
done
ls -la release-assets/
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
Codebase Indexer ${{ github.ref_name }}
## Build Information
- Version: ${{ github.ref_name }}
## Download Instructions
Please select the appropriate binary file based on your operating system and architecture:
- Linux: `codebase-indexer-linux-*`
- Windows: `codebase-indexer-windows-*.exe`
- macOS: `codebase-indexer-darwin-*`
## Supported Platforms and Architectures
- Linux amd64, arm64, 386, arm
- Windows amd64
- macOS amd64, arm64
files: release-assets/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}