+78
-21
.github/workflows/cli.yml
+78
-21
.github/workflows/cli.yml
···
11
required: true
12
type: string
13
14
jobs:
15
build:
16
name: Build CLI Binaries
17
-
runs-on: ubuntu-latest
18
defaults:
19
run:
20
working-directory: cli
21
steps:
22
- name: Checkout
23
uses: actions/checkout@v4
···
33
- name: Check flake
34
run: nix flake check
35
36
-
- name: Build Darwin aarch64 only (for testing)
37
run: |
38
-
echo "Building for macOS aarch64 only..."
39
mkdir -p releases
40
-
nix build .#grain-macos-aarch64 -o result-macos-aarch64
41
-
cp result-macos-aarch64/bin/grain releases/grain-darwin-aarch64
42
43
- name: Prepare release assets
44
run: |
45
mkdir -p release-assets
46
-
cp releases/grain-darwin-aarch64 release-assets/
47
-
cp install.sh release-assets/
48
49
# Create checksums
50
cd release-assets
51
-
sha256sum grain-darwin-aarch64 > checksums.txt
52
53
# List files for verification
54
ls -la
···
70
draft: false
71
prerelease: false
72
files: |
73
-
cli/release-assets/*
74
body: |
75
-
## Grain CLI ${{ steps.tag.outputs.tag }} (Test Build)
76
-
77
-
**Note: This is a test build with only macOS Apple Silicon support.**
78
79
### Installation
80
···
85
86
Or download manually:
87
88
- **macOS Apple Silicon**: `grain-darwin-aarch64`
89
90
### Usage
91
···
127
sleep 30
128
129
# Test the install script
130
-
curl -L https://github.com/grainsocial/grain/releases/download/${{ steps.tag.outputs.tag }}/grain-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m) -o grain-test || exit 0
131
-
132
-
if [ -f grain-test ]; then
133
-
chmod +x grain-test
134
-
./grain-test --help
135
-
echo "โ
Binary works correctly"
136
-
else
137
-
echo "โ ๏ธ Binary not available yet for this platform"
138
-
fi
···
11
required: true
12
type: string
13
14
+
permissions:
15
+
contents: write
16
+
17
jobs:
18
build:
19
name: Build CLI Binaries
20
+
strategy:
21
+
matrix:
22
+
include:
23
+
# - target: x86_64-unknown-linux-gnu
24
+
# os: ubuntu-latest
25
+
# package: grain-linux-x86_64
26
+
# artifact: grain-linux-x86_64
27
+
# - target: aarch64-unknown-linux-gnu
28
+
# os: ubuntu-latest
29
+
# package: grain-linux-aarch64
30
+
# artifact: grain-linux-aarch64
31
+
# - target: x86_64-apple-darwin
32
+
# os: macos-13 # Intel Mac
33
+
# package: grain-macos-x86_64
34
+
# artifact: grain-darwin-x86_64
35
+
- target: aarch64-apple-darwin
36
+
os: macos-latest # Apple Silicon Mac
37
+
package: grain-macos-aarch64
38
+
artifact: grain-darwin-aarch64
39
+
# - target: x86_64-pc-windows-gnu
40
+
# os: ubuntu-latest
41
+
# package: grain-windows-x86_64
42
+
# artifact: grain-windows-x86_64.exe
43
+
44
+
runs-on: ${{ matrix.os }}
45
defaults:
46
run:
47
working-directory: cli
48
+
49
steps:
50
- name: Checkout
51
uses: actions/checkout@v4
···
61
- name: Check flake
62
run: nix flake check
63
64
+
- name: Build ${{ matrix.target }}
65
+
run: nix build .#${{ matrix.package }}
66
+
67
+
- name: Copy binary
68
run: |
69
mkdir -p releases
70
+
if [ "${{ matrix.target }}" == "x86_64-pc-windows-gnu" ]; then
71
+
cp result/bin/grain.exe releases/${{ matrix.artifact }}
72
+
else
73
+
cp result/bin/grain releases/${{ matrix.artifact }}
74
+
fi
75
+
76
+
- name: Upload artifact
77
+
uses: actions/upload-artifact@v4
78
+
with:
79
+
name: ${{ matrix.artifact }}
80
+
path: cli/releases/${{ matrix.artifact }}
81
+
retention-days: 7
82
+
83
+
release:
84
+
name: Create Release
85
+
needs: build
86
+
runs-on: ubuntu-latest
87
+
steps:
88
+
- name: Checkout
89
+
uses: actions/checkout@v4
90
+
91
+
- name: Download all artifacts
92
+
uses: actions/download-artifact@v4
93
+
with:
94
+
path: artifacts
95
96
- name: Prepare release assets
97
run: |
98
mkdir -p release-assets
99
+
100
+
# Copy all binaries
101
+
for dir in artifacts/*/; do
102
+
for file in "$dir"*; do
103
+
if [ -f "$file" ]; then
104
+
cp "$file" release-assets/
105
+
fi
106
+
done
107
+
done
108
+
109
+
# Copy install script
110
+
cp cli/install.sh release-assets/
111
112
# Create checksums
113
cd release-assets
114
+
sha256sum * > checksums.txt
115
116
# List files for verification
117
ls -la
···
133
draft: false
134
prerelease: false
135
files: |
136
+
release-assets/*
137
body: |
138
+
## Grain CLI ${{ steps.tag.outputs.tag }}
139
140
### Installation
141
···
146
147
Or download manually:
148
149
+
- **Linux x86_64**: `grain-linux-x86_64`
150
+
- **Linux aarch64**: `grain-linux-aarch64`
151
+
- **macOS Intel**: `grain-darwin-x86_64`
152
- **macOS Apple Silicon**: `grain-darwin-aarch64`
153
+
- **Windows x86_64**: `grain-windows-x86_64.exe`
154
155
### Usage
156
···
192
sleep 30
193
194
# Test the install script
195
+
curl -L https://github.com/grainsocial/grain/releases/download/${{ steps.tag.outputs.tag }}/install.sh | bash
+22
-1
cli/flake.lock
+22
-1
cli/flake.lock
···
53
"inputs": {
54
"crane": "crane",
55
"flake-utils": "flake-utils",
56
+
"nixpkgs": "nixpkgs",
57
+
"rust-overlay": "rust-overlay"
58
+
}
59
+
},
60
+
"rust-overlay": {
61
+
"inputs": {
62
+
"nixpkgs": [
63
+
"nixpkgs"
64
+
]
65
+
},
66
+
"locked": {
67
+
"lastModified": 1754534980,
68
+
"narHash": "sha256-8cAquqasyPRvgJfKVKxz+gQ+SRoRxiHhX91Avtl9Rn8=",
69
+
"owner": "oxalica",
70
+
"repo": "rust-overlay",
71
+
"rev": "89e92794124b93bddb5f8f92485ed924bd179287",
72
+
"type": "github"
73
+
},
74
+
"original": {
75
+
"owner": "oxalica",
76
+
"repo": "rust-overlay",
77
+
"type": "github"
78
}
79
},
80
"systems": {
+45
-14
cli/flake.nix
+45
-14
cli/flake.nix
···
8
url = "github:ipetkov/crane";
9
inputs.nixpkgs.follows = "nixpkgs";
10
};
11
};
12
13
-
outputs = { self, nixpkgs, flake-utils, crane }:
14
flake-utils.lib.eachDefaultSystem (system:
15
let
16
-
pkgs = import nixpkgs { inherit system; };
17
18
-
craneLib = crane.mkLib pkgs;
19
20
src = craneLib.cleanCargoSource (craneLib.path ./.);
21
···
39
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
40
41
# Build function for different targets
42
-
buildGrainCLI = target: craneLib.buildPackage (commonArgs // {
43
-
inherit cargoArtifacts;
44
-
CARGO_BUILD_TARGET = target;
45
-
} // pkgs.lib.optionalAttrs (target == "x86_64-pc-windows-gnu") {
46
-
depsBuildBuild = with pkgs; [
47
-
pkgsCross.mingwW64.stdenv.cc
48
-
];
49
-
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/x86_64-w64-mingw32-gcc";
50
-
});
51
52
in {
53
packages = {
···
64
devShells.default = pkgs.mkShell {
65
inputsFrom = [ self.packages.${system}.default ];
66
packages = with pkgs; [
67
-
rustc
68
-
cargo
69
pkg-config
70
openssl
71
cargo-cross
···
8
url = "github:ipetkov/crane";
9
inputs.nixpkgs.follows = "nixpkgs";
10
};
11
+
rust-overlay = {
12
+
url = "github:oxalica/rust-overlay";
13
+
inputs.nixpkgs.follows = "nixpkgs";
14
+
};
15
};
16
17
+
outputs = { self, nixpkgs, flake-utils, crane, rust-overlay }:
18
flake-utils.lib.eachDefaultSystem (system:
19
let
20
+
overlays = [ (import rust-overlay) ];
21
+
pkgs = import nixpkgs { inherit system overlays; };
22
+
23
+
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
24
+
extensions = [ "rust-src" ];
25
+
targets = [
26
+
"x86_64-unknown-linux-gnu"
27
+
"x86_64-pc-windows-gnu"
28
+
"x86_64-apple-darwin"
29
+
"aarch64-apple-darwin"
30
+
"aarch64-unknown-linux-gnu"
31
+
];
32
+
};
33
34
+
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
35
36
src = craneLib.cleanCargoSource (craneLib.path ./.);
37
···
55
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
56
57
# Build function for different targets
58
+
buildGrainCLI = target:
59
+
let
60
+
# Only cross-compile if target is different from current system
61
+
isCrossCompiling = target != system;
62
+
in
63
+
if isCrossCompiling then
64
+
# For cross-compilation, use the native build but with target specified
65
+
craneLib.buildPackage (commonArgs // {
66
+
inherit cargoArtifacts;
67
+
CARGO_BUILD_TARGET = target;
68
+
} // pkgs.lib.optionalAttrs (target == "x86_64-pc-windows-gnu") {
69
+
depsBuildBuild = with pkgs; [
70
+
pkgsCross.mingwW64.stdenv.cc
71
+
pkgsCross.mingwW64.windows.pthreads
72
+
];
73
+
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [
74
+
pkgs.pkgsCross.mingwW64.windows.pthreads
75
+
];
76
+
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/x86_64-w64-mingw32-gcc";
77
+
})
78
+
else
79
+
# For native builds, don't specify target
80
+
craneLib.buildPackage (commonArgs // {
81
+
inherit cargoArtifacts;
82
+
});
83
84
in {
85
packages = {
···
96
devShells.default = pkgs.mkShell {
97
inputsFrom = [ self.packages.${system}.default ];
98
packages = with pkgs; [
99
+
rustToolchain
100
pkg-config
101
openssl
102
cargo-cross