Skip to content

Commit 6fd3043

Browse files
god has abandoned us
Signed-off-by: vaibhav <vaibhavmattoo1@gmail.com>
1 parent 3d23ada commit 6fd3043

File tree

1 file changed

+69
-19
lines changed

1 file changed

+69
-19
lines changed

.github/workflows/release.yml

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Cross-compile and Upload Release Assets for bitchat-tui
1+
name: Cross-compile and Upload Bitchat-TUI Release Assets
22

33
on:
44
push:
@@ -10,6 +10,7 @@ permissions:
1010

1111
env:
1212
CARGO_TERM_COLOR: always
13+
APP_NAME: bitchat-tui
1314

1415
jobs:
1516
build-and-upload:
@@ -32,43 +33,92 @@ jobs:
3233
- target: aarch64-apple-darwin
3334
os: macos-latest
3435
ext: tar.gz
36+
- target: x86_64-pc-windows-msvc
37+
os: windows-latest
38+
ext: zip
3539

3640
runs-on: ${{ matrix.os }}
3741
steps:
3842
- name: Checkout code at the pushed tag
3943
uses: actions/checkout@v4
4044

41-
- name: Install cross (if needed)
45+
- name: Install Rust toolchain
46+
uses: actions-rs/toolchain@v1
47+
with:
48+
toolchain: stable
49+
target: ${{ matrix.target }}
50+
override: true
51+
52+
- name: Install dependencies (Linux)
4253
if: runner.os == 'Linux'
4354
run: |
55+
sudo apt-get update
56+
sudo apt-get install -y pkg-config
4457
cargo install cross --git https://github.com/cross-rs/cross
4558
46-
- name: Build with cross/cargo
47-
uses: houseabsolute/actions-rust-cross@v1
48-
with:
49-
command: build
50-
target: ${{ matrix.target }}
51-
args: --locked --release
52-
strip: true
59+
- name: Install dependencies (macOS)
60+
if: runner.os == 'macOS'
61+
run: brew install pkg-config
62+
63+
- name: Configure cross-rs for Linux dependencies
64+
if: runner.os == 'Linux'
65+
run: |
66+
cat > Cross.toml <<'EOF'
67+
[target.x86_64-unknown-linux-musl]
68+
pre-build = ["apt-get update && apt-get install -y --no-install-recommends libdbus-1-dev"]
69+
70+
[target.aarch64-unknown-linux-musl]
71+
pre-build = [
72+
"dpkg --add-architecture arm64",
73+
"apt-get update",
74+
"apt-get install -y --no-install-recommends libdbus-1-dev:arm64",
75+
]
5376
54-
- name: Package binary (tar.gz/zip)
77+
[target.armv7-unknown-linux-musleabihf]
78+
pre-build = [
79+
"dpkg --add-architecture armhf",
80+
"apt-get update",
81+
"apt-get install -y --no-install-recommends libdbus-1-dev:armhf",
82+
]
83+
EOF
84+
85+
- name: Build with cross (Linux)
86+
if: runner.os == 'Linux'
87+
run: cross build --locked --release --target ${{ matrix.target }}
88+
89+
- name: Build with cargo (non-Linux)
90+
if: runner.os != 'Linux'
91+
run: cargo build --locked --release --target ${{ matrix.target }}
92+
93+
- name: Strip binary (Unix)
94+
if: runner.os != 'Windows'
95+
run: strip "target/${{ matrix.target }}/release/${{ env.APP_NAME }}"
96+
97+
- name: Package binary
5598
shell: bash
5699
run: |
57100
set -e
58-
NAME="bitchat-tui"
59101
TARGET="${{ matrix.target }}"
60102
EXT="${{ matrix.ext }}"
61103
OUTDIR="release"
104+
105+
# Determine binary name based on OS
106+
if [[ "$TARGET" == *windows* ]]; then
107+
BIN_NAME="${{ env.APP_NAME }}.exe"
108+
else
109+
BIN_NAME="${{ env.APP_NAME }}"
110+
fi
111+
112+
# Create release directory and copy binary
62113
mkdir -p "$OUTDIR"
114+
cp "target/${TARGET}/release/${BIN_NAME}" "${BIN_NAME}"
115+
116+
# Package into tar.gz or zip
63117
if [[ "$TARGET" == *windows* ]]; then
64-
BIN="${NAME}.exe"
65-
cp "target/${TARGET}/release/${BIN}" "${BIN}"
66-
7z a -tzip "$OUTDIR/${NAME}-${TARGET}.zip" "${BIN}" LICENSE README.md || \
67-
zip "$OUTDIR/${NAME}-${TARGET}.zip" "${BIN}" LICENSE README.md
118+
7z a -tzip "$OUTDIR/${{ env.APP_NAME }}-${TARGET}.zip" "${BIN_NAME}" LICENSE README.md || \
119+
zip "$OUTDIR/${{ env.APP_NAME }}-${TARGET}.zip" "${BIN_NAME}" LICENSE README.md
68120
else
69-
BIN="${NAME}"
70-
cp "target/${TARGET}/release/${BIN}" "${BIN}"
71-
tar czf "$OUTDIR/${NAME}-${TARGET}.tar.gz" "${BIN}" LICENSE README.md
121+
tar czf "$OUTDIR/${{ env.APP_NAME }}-${TARGET}.tar.gz" "${BIN_NAME}" LICENSE README.md
72122
fi
73123
74124
- name: List packaged files
@@ -87,4 +137,4 @@ jobs:
87137
uses: shogo82148/actions-upload-release-asset@v1
88138
with:
89139
upload_url: ${{ steps.get_release.outputs.upload_url }}
90-
asset_path: release/bitchat-tui-${{ matrix.target }}.${{ matrix.ext }}
140+
asset_path: release/${{ env.APP_NAME }}-${{ matrix.target }}.${{ matrix.ext }}

0 commit comments

Comments
 (0)