Skip to content

Commit 1fd977b

Browse files
authored
Merge pull request #1 from 21-DOT-DEV/001-i-am-building
Initial Working CLI App
2 parents 3ae1525 + 3ba18f6 commit 1fd977b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+9502
-35
lines changed

.github/workflows/pr.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PR Validation
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
jobs:
10+
macos:
11+
name: Test on macOS
12+
runs-on: macos-15
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Run test suite
18+
run: swift test --filter "SubtreeTests"
19+
20+
linux:
21+
name: Test on Linux
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
# - name: Set up Docker Buildx
28+
# uses: docker/setup-buildx-action@v3
29+
30+
- name: Run Linux test suite
31+
run: |
32+
docker run --rm -v "$(pwd):/workspace" -w /workspace swift:6.1 \
33+
bash -c "swift package resolve && swift test --filter 'SubtreeTests'"

.github/workflows/release.yml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: Build Release Artifacts
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
macos:
9+
name: Build macOS binary
10+
runs-on: macos-15
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Build macOS binary
16+
run: swift build -c release --arch arm64 --arch x86_64 -Xswiftc -Osize
17+
18+
- name: Strip macOS binary
19+
run: strip -rSTx .build/apple/Products/Release/subtree
20+
21+
- name: Test binary functionality
22+
run: |
23+
.build/apple/Products/Release/subtree --help
24+
echo "✅ macOS binary responds to --help"
25+
26+
- name: Upload artifacts
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: subtree_macos
30+
path: .build/apple/Products/Release/subtree
31+
retention-days: 5
32+
33+
linux:
34+
name: Build Linux binaries
35+
runs-on: ubuntu-20.04
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Install cross-binutils for aarch64
44+
run: sudo apt install -y binutils-aarch64-linux-gnu
45+
46+
- name: Build and export binaries
47+
uses: docker/build-push-action@v5
48+
with:
49+
context: .
50+
platforms: linux/amd64,linux/arm64
51+
target: output
52+
outputs: type=local,dest=artifacts
53+
54+
- name: Test and organize binaries
55+
run: |
56+
# Test that binaries were built successfully
57+
echo "✅ Linux AMD64 binary built: $(file artifacts/linux_amd64/subtree)"
58+
echo "✅ Linux ARM64 binary built: $(file artifacts/linux_arm64/subtree)"
59+
60+
# Strip and organize AMD64 binary
61+
strip artifacts/linux_amd64/subtree
62+
mv artifacts/linux_amd64/subtree "${HOME}/subtree_linux"
63+
64+
# Strip and organize ARM64 binary
65+
aarch64-linux-gnu-strip artifacts/linux_arm64/subtree
66+
mv artifacts/linux_arm64/subtree "${HOME}/subtree_linux_aarch64"
67+
68+
- name: Upload AMD64 Artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: subtree_linux
72+
path: ~/subtree_linux
73+
retention-days: 5
74+
75+
- name: Upload ARM64 Artifact
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: subtree_linux_aarch64
79+
path: ~/subtree_linux_aarch64
80+
retention-days: 5
81+
82+
upload:
83+
name: Upload release artifacts
84+
runs-on: ubuntu-20.04
85+
needs: [macos, linux]
86+
steps:
87+
- name: Checkout the repository
88+
uses: actions/checkout@v4
89+
90+
- name: Download artifacts
91+
uses: actions/download-artifact@v4
92+
with:
93+
path: downloaded_artifacts
94+
95+
- name: Display structure of downloaded files
96+
run: ls -R downloaded_artifacts
97+
98+
- name: Prepare release binaries
99+
run: |
100+
VERSION="${{ github.event.release.tag_name }}"
101+
102+
# Copy and rename binaries for release upload
103+
cp downloaded_artifacts/subtree_macos/subtree "subtree_${VERSION}_macos"
104+
cp downloaded_artifacts/subtree_linux/subtree_linux "subtree_${VERSION}_linux_x86_64"
105+
cp downloaded_artifacts/subtree_linux_aarch64/subtree_linux_aarch64 "subtree_${VERSION}_linux_arm64"
106+
107+
# Make all binaries executable
108+
chmod +x subtree_${VERSION}_*
109+
110+
- name: Build artifact bundle
111+
run: |
112+
VERSION="${{ github.event.release.tag_name }}"
113+
BUNDLE_DIR="subtree.artifactbundle"
114+
115+
mkdir -p "${BUNDLE_DIR}"
116+
117+
# Organize binaries by platform (universal macOS binary)
118+
mkdir -p "${BUNDLE_DIR}/macos"
119+
mkdir -p "${BUNDLE_DIR}/linux-x86_64"
120+
mkdir -p "${BUNDLE_DIR}/linux-arm64"
121+
122+
# Copy binaries to bundle structure
123+
cp downloaded_artifacts/subtree_macos/subtree "${BUNDLE_DIR}/macos/subtree"
124+
cp downloaded_artifacts/subtree_linux/subtree_linux "${BUNDLE_DIR}/linux-x86_64/subtree"
125+
cp downloaded_artifacts/subtree_linux_aarch64/subtree_linux_aarch64 "${BUNDLE_DIR}/linux-arm64/subtree"
126+
127+
# Create artifact bundle manifest
128+
cat > "${BUNDLE_DIR}/artifactbundle.json" << EOF
129+
{
130+
"schemaVersion": "1.0",
131+
"artifacts": {
132+
"subtree": {
133+
"version": "${VERSION}",
134+
"type": "executable",
135+
"variants": [
136+
{
137+
"path": "macos/subtree",
138+
"supportedTriples": ["arm64-apple-macosx", "x86_64-apple-macosx"]
139+
},
140+
{
141+
"path": "linux-x86_64/subtree",
142+
"supportedTriples": ["x86_64-unknown-linux-gnu"]
143+
},
144+
{
145+
"path": "linux-arm64/subtree",
146+
"supportedTriples": ["aarch64-unknown-linux-gnu"]
147+
}
148+
]
149+
}
150+
}
151+
}
152+
EOF
153+
154+
# Create zip archive
155+
zip -r "subtree.artifactbundle.zip" "${BUNDLE_DIR}"
156+
157+
- name: Upload release binaries
158+
uses: skx/github-action-publish-binaries@master
159+
env:
160+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
161+
with:
162+
args: 'subtree_${{ github.event.release.tag_name }}_macos subtree_${{ github.event.release.tag_name }}_linux_x86_64 subtree_${{ github.event.release.tag_name }}_linux_arm64 subtree.artifactbundle.zip'

.gitignore

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Xcode
2+
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4+
5+
## User settings
6+
xcuserdata/
7+
8+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
9+
*.xcscmblueprint
10+
*.xccheckout
11+
12+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
13+
build/
14+
DerivedData/
15+
*.moved-aside
16+
*.pbxuser
17+
!default.pbxuser
18+
*.mode1v3
19+
!default.mode1v3
20+
*.mode2v3
21+
!default.mode2v3
22+
*.perspectivev3
23+
!default.perspectivev3
24+
25+
## Obj-C/Swift specific
26+
*.hmap
27+
28+
## App packaging
29+
*.ipa
30+
*.dSYM.zip
31+
*.dSYM
32+
33+
## Playgrounds
34+
timeline.xctimeline
35+
playground.xcworkspace
36+
37+
## macOS
38+
.DS_Store
39+
40+
# Swift Package Manager
41+
#
42+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
43+
Packages/
44+
Package.pins
45+
Package.resolved
46+
*.xcodeproj
47+
48+
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
49+
# hence it is not needed unless you have added a package configuration file to your project
50+
.swiftpm
51+
52+
.build/
53+
54+
# CocoaPods
55+
#
56+
# We recommend against adding the Pods directory to your .gitignore. However
57+
# you should judge for yourself, the pros and cons are mentioned at:
58+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
59+
#
60+
# Pods/
61+
#
62+
# Add this line if you want to avoid checking in source code from the Xcode workspace
63+
*.xcworkspace
64+
65+
# Carthage
66+
#
67+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
68+
# Carthage/Checkouts
69+
70+
Carthage/Build/
71+
72+
# Accio dependency management
73+
Dependencies/
74+
.accio/
75+
76+
# fastlane
77+
#
78+
# It is recommended to not store the screenshots in the git repo.
79+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
80+
# For more information about the recommended setup visit:
81+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
82+
83+
fastlane/report.xml
84+
fastlane/Preview.html
85+
fastlane/screenshots/**/*.png
86+
fastlane/test_output
87+
88+
# Code Injection
89+
#
90+
# After new code Injection tools there's a generated folder /iOSInjectionProject
91+
# https://github.com/johnno1962/injectionforxcode
92+
93+
iOSInjectionProject/

0 commit comments

Comments
 (0)