File tree Expand file tree Collapse file tree 6 files changed +138
-0
lines changed
Expand file tree Collapse file tree 6 files changed +138
-0
lines changed Original file line number Diff line number Diff line change 1+ # Ignore macOS specific files
2+ .DS_Store
3+
4+ # Ignore build artifacts
5+ .build /
6+
7+ # Ignore Xcode project files
8+ * .xcodeproj /
9+ xcuserdata /
10+
11+ # Ignore Swift Package Manager files
12+ .swiftpm /
13+ Package.resolved
14+
15+ # Ignore user configuration files
16+ .netrc
17+ .vscode /
18+
19+ # Ignore other temporary files or directories
20+ DerivedData /
21+ images /
22+ release /
Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ DerivedData/
1010.swiftpm
1111Package.resolved
1212.vscode
13+ release /
Original file line number Diff line number Diff line change 1+ .PHONY : clean
2+ clean :
3+ rm -rf .build .swiftpm Package.resolved || true
4+
5+ .PHONY : build-test
6+ build-test :
7+ swift build
8+
9+ .PHONY : build-release
10+ build-release :
11+ swift build --static-swift-stdlib -c release
Original file line number Diff line number Diff line change 1+ FROM swift:5.10.1-bookworm
2+
3+ RUN apt update && \
4+ apt install build-essential -y
5+
6+ COPY . /tmp/lcl-cli
7+ WORKDIR /tmp/lcl-cli
8+ RUN ls -a
9+
10+ RUN swift build \
11+ --static-swift-stdlib \
12+ -c release
13+
14+ RUN mv .build/release/lcl /lcl
15+ RUN strip /lcl
16+ RUN /lcl --help
17+ RUN ldd /lcl
Original file line number Diff line number Diff line change 1+ FROM swift:5.10.1-noble
2+
3+ RUN apt-get update && \
4+ apt-get install build-essential -y
5+
6+ COPY . /tmp/lcl-cli
7+ WORKDIR /tmp/lcl-cli
8+ RUN ls -a
9+
10+ RUN swift build \
11+ --static-swift-stdlib \
12+ -c release
13+
14+ RUN mv .build/release/lcl /lcl
15+ RUN strip /lcl
16+ RUN /lcl --help
17+ RUN ldd /lcl
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -e
4+
5+ if [[ ! -z " $( git status --porcelain=v1 2> /dev/null) " ]]; then
6+ echo " There are uncommitted changes in the local tree, please commit or discard them"
7+ exit 1
8+ fi
9+
10+ raw_arch=" $( uname -m) "
11+ case " $raw_arch " in
12+ " x86_64" )
13+ arch=" x86_64"
14+ ;;
15+
16+ " aarch64" | " arm64" )
17+ arch=" aarch64"
18+ ;;
19+
20+ * )
21+ echo " Error: Unsupported CPU architecture: $raw_arch "
22+ ;;
23+ esac
24+
25+ os=" $( uname) "
26+
27+ release_tag=" $( git describe --tags ` git rev-list --tags --max-count=1` ) "
28+ echo " Release version: $release_tag "
29+ echo " OS: $os "
30+
31+ git checkout " $release_tag "
32+
33+ mkdir -p release
34+
35+ image_name_prefix=" lcl-cli-$release_tag "
36+ binary_name_prefix=" lcl-cli-$release_tag -$arch "
37+
38+ function build_for_linux() {
39+ local platform=$1
40+ local image_name=" $image_name_prefix -$platform "
41+
42+ echo " arch: $arch "
43+ echo " platform: $platform "
44+ echo " image_name: $image_name "
45+ echo " binary_name: $binary_name_prefix -$platform "
46+
47+ docker build -t " $image_name " -f " docker/build_$platform .dockerfile" .
48+ local container_id=$( docker create " $image_name " )
49+ docker cp " $container_id :/lcl" " release/$binary_name_prefix -$platform "
50+ docker rm -v " $container_id "
51+ docker image rm -f " $image_name "
52+
53+ echo " Binary for $platform has been successfully built!"
54+ }
55+
56+ function build_for_macos() {
57+ echo " arch: $arch "
58+ echo " platform: macOS"
59+ echo " binary_name: $binary_name_prefix -macos"
60+
61+ make build-release
62+ mv .build/release/lcl release/lcl
63+ strip release/lcl
64+ ./release/lcl --help
65+ mv release/lcl " release/$binary_name_prefix -macos"
66+ }
67+
68+ build_for_linux ubuntu
69+ build_for_linux debian
70+ build_for_macos
You can’t perform that action at this time.
0 commit comments