-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Ignore macOS specific files | ||
.DS_Store | ||
|
||
# Ignore build artifacts | ||
.build/ | ||
|
||
# Ignore Xcode project files | ||
*.xcodeproj/ | ||
xcuserdata/ | ||
|
||
# Ignore Swift Package Manager files | ||
.swiftpm/ | ||
Package.resolved | ||
|
||
# Ignore user configuration files | ||
.netrc | ||
.vscode/ | ||
|
||
# Ignore other temporary files or directories | ||
DerivedData/ | ||
images/ | ||
release/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ DerivedData/ | |
.swiftpm | ||
Package.resolved | ||
.vscode | ||
release/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.PHONY: clean | ||
clean: | ||
rm -rf .build .swiftpm Package.resolved || true | ||
|
||
.PHONY: build-test | ||
build-test: | ||
swift build | ||
|
||
.PHONY: build-release | ||
build-release: | ||
swift build --static-swift-stdlib -c release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM swift:5.10.1-bookworm | ||
|
||
RUN apt update && \ | ||
apt install build-essential -y | ||
|
||
COPY . /tmp/lcl-cli | ||
WORKDIR /tmp/lcl-cli | ||
RUN ls -a | ||
|
||
RUN swift build \ | ||
--static-swift-stdlib \ | ||
-c release | ||
|
||
RUN mv .build/release/lcl /lcl | ||
RUN strip /lcl | ||
RUN /lcl --help | ||
RUN ldd /lcl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM swift:5.10.1-noble | ||
|
||
RUN apt-get update && \ | ||
apt-get install build-essential -y | ||
|
||
COPY . /tmp/lcl-cli | ||
WORKDIR /tmp/lcl-cli | ||
RUN ls -a | ||
|
||
RUN swift build \ | ||
--static-swift-stdlib \ | ||
-c release | ||
|
||
RUN mv .build/release/lcl /lcl | ||
RUN strip /lcl | ||
RUN /lcl --help | ||
RUN ldd /lcl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [[ ! -z "$(git status --porcelain=v1 2>/dev/null)" ]]; then | ||
echo "There are uncommitted changes in the local tree, please commit or discard them" | ||
exit 1 | ||
fi | ||
|
||
raw_arch="$(uname -m)" | ||
case "$raw_arch" in | ||
"x86_64") | ||
arch="x86_64" | ||
;; | ||
|
||
"aarch64" | "arm64") | ||
arch="aarch64" | ||
;; | ||
|
||
*) | ||
echo "Error: Unsupported CPU architecture: $raw_arch" | ||
;; | ||
esac | ||
|
||
os="$(uname)" | ||
|
||
release_tag="$(git describe --tags `git rev-list --tags --max-count=1`)" | ||
echo "Release version: $release_tag" | ||
echo "OS: $os" | ||
|
||
git checkout "$release_tag" | ||
|
||
mkdir -p release | ||
|
||
image_name_prefix="lcl-cli-$release_tag" | ||
binary_name_prefix="lcl-cli-$release_tag-$arch" | ||
|
||
function build_for_linux() { | ||
local platform=$1 | ||
local image_name="$image_name_prefix-$platform" | ||
|
||
echo "arch: $arch" | ||
echo "platform: $platform" | ||
echo "image_name: $image_name" | ||
echo "binary_name: $binary_name_prefix-$platform" | ||
|
||
docker build -t "$image_name" -f "docker/build_$platform.dockerfile" . | ||
local container_id=$(docker create "$image_name") | ||
docker cp "$container_id:/lcl" "release/$binary_name_prefix-$platform" | ||
docker rm -v "$container_id" | ||
docker image rm -f "$image_name" | ||
|
||
echo "Binary for $platform has been successfully built!" | ||
} | ||
|
||
function build_for_macos() { | ||
echo "arch: $arch" | ||
echo "platform: macOS" | ||
echo "binary_name: $binary_name_prefix-macos" | ||
|
||
make build-release | ||
mv .build/release/lcl release/lcl | ||
strip release/lcl | ||
./release/lcl --help | ||
mv release/lcl "release/$binary_name_prefix-macos" | ||
} | ||
|
||
build_for_linux ubuntu | ||
build_for_linux debian | ||
build_for_macos |