Skip to content

Commit 695d860

Browse files
sbernauerTechassi
andauthored
Add action to build stackablectl release binaries (no Windows) (#96)
* try Windows build * Add release workflow * fix release action * Reduce release binary size * Swtich from xdg to directories crate for Windows compatibility * test windows * widnows test * widnows stuff * windoof * windoof * try msvc * diable windows build * uncomment * Apply suggestions from code review Co-authored-by: Techassi <git@techassi.dev> * Remove comment * linter --------- Co-authored-by: Techassi <git@techassi.dev>
1 parent 5ed614c commit 695d860

File tree

4 files changed

+118
-11
lines changed

4 files changed

+118
-11
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,11 @@ jobs:
355355
include:
356356
- target: x86_64-unknown-linux-gnu
357357
os: ubuntu-latest
358-
# Currently Widnows build fails with
359-
# cargo:warning=# runtime/cgo
360-
# cargo:warning=cgo: C compiler "C:\\Program" not found: exec: "C:\\Program": file does not exist
361-
# error occurred: Command "go" "build" "-buildmode" "c-archive" "-o" "D:\\a\\stackable-cockpit\\stackable-cockpit\\target\\debug\\build\\helm-sys-cce901864d7b6e8c\\out\\libgo-helm-wrapper.a" "go-helm-wrapper/main.go" with args "go-helm-wrapper" did not execute successfully (status code exit code: 1).
362-
# so that Windows build is disabled for now
358+
# Commented out, as Windows build is currently not working
363359
# - target: x86_64-pc-windows-gnu
364360
# os: windows-latest
361+
# - target: x86_64-pc-windows-msvc
362+
# os: windows-latest
365363
- target: x86_64-apple-darwin
366364
os: macos-latest
367365
- target: aarch64-apple-darwin
@@ -378,7 +376,24 @@ jobs:
378376
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
379377
with:
380378
key: build-stackablectl-${{ matrix.target }}
381-
- run: cargo build --target ${{ matrix.target }} -p stackablectl
379+
- name: Build for non-Windows
380+
if: matrix.os != 'windows-latest'
381+
run: cargo build --target ${{ matrix.target }} -p stackablectl
382+
# - name: Prepare Windows env
383+
# if: matrix.os == 'windows-latest'
384+
# uses: msys2/setup-msys2@v2
385+
# with:
386+
# msystem: MINGW64
387+
# update: true
388+
# install: base-devel mingw-w64-x86_64-go mingw-w64-x86_64-rust
389+
# # install: base-devel mingw-w64-x86_64-libressl mingw-w64-x86_64-ldns mingw-w64-x86_64-go mingw-w64-x86_64-rust
390+
# - name: Build for Windows
391+
# if: matrix.os == 'windows-latest'
392+
# run: cargo build --target ${{ matrix.target }} -p stackablectl
393+
# shell: msys2 {0}
394+
- name: Build for Windows
395+
if: matrix.os == 'windows-latest'
396+
run: cargo build --target ${{ matrix.target }} -p stackablectl
382397

383398
# Commented out, as this was always failing.
384399
# We can comment it in again once want our image to be certified
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
name: Stackablectl Release Pipeline
3+
4+
on:
5+
push:
6+
tags:
7+
- "stackablectl-[0-9]+.[0-9]+.[0-9]+"
8+
9+
env:
10+
RUST_VERSION: 1.70.0
11+
CARGO_TERM_COLOR: always
12+
CARGO_INCREMENTAL: "0"
13+
CARGO_PROFILE_DEV_DEBUG: "0"
14+
RUSTFLAGS: "-D warnings"
15+
RUSTDOCFLAGS: "-D warnings"
16+
RUST_LOG: "info"
17+
18+
jobs:
19+
release:
20+
name: Release for ${{ matrix.target }}
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
include:
26+
- target: x86_64-unknown-linux-gnu
27+
os: ubuntu-20.04 # We don't use ubuntu-latest because we want to build against an old glibc version. (18.04 has glibc 2.27, 20.04 has glibc 2.31, 22.04 has glibc 2.35)
28+
file-suffix: ""
29+
# Commented out, as Windows build is currently not working
30+
# - target: x86_64-pc-windows-gnu
31+
# os: windows-latest
32+
# file-suffix: ".exe"
33+
- target: x86_64-apple-darwin
34+
os: macos-latest
35+
file-suffix: ""
36+
- target: aarch64-apple-darwin
37+
os: macos-latest
38+
file-suffix: ""
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
42+
with:
43+
submodules: recursive
44+
- uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e # v1
45+
with:
46+
toolchain: ${{ env.RUST_VERSION }}
47+
targets: ${{ matrix.target }}
48+
- name: Build for non-Windows
49+
if: matrix.os != 'windows-latest'
50+
run: cargo build --target ${{ matrix.target }} --release -p stackablectl
51+
- name: Prepare Windows env
52+
if: matrix.os == 'windows-latest'
53+
uses: msys2/setup-msys2@v2
54+
with:
55+
msystem: MINGW64
56+
update: true
57+
install: base-devel mingw-w64-x86_64-go mingw-w64-x86_64-rust
58+
- name: Build for Windows
59+
if: matrix.os == 'windows-latest'
60+
run: cargo build --target ${{ matrix.target }} --release -p stackablectl
61+
shell: msys2 {0}
62+
- name: Rename binary file
63+
run: mv target/${{ matrix.target }}/release/stackablectl${{ matrix.file-suffix }} stackablectl-${{ matrix.target }}${{ matrix.file-suffix }}
64+
- name: Upload Release binaries
65+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
66+
with:
67+
files: stackablectl-${{ matrix.target }}${{ matrix.file-suffix }}

Cargo.lock

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ nu-ansi-term = "0.49"
2727
phf = "0.11"
2828
phf_codegen = "0.11"
2929
rand = "0.8"
30-
# We use the feature "rustls-tls-native-roots" instead of "rustls-tls" to avoid pulling in "webpki-roots" and hence MPL-2.0: https://github.com/rustls/webpki-roots/blob/main/LICENSE
31-
reqwest = { version = "0.11.16", default-features = false, features = ["rustls-tls-native-roots"] }
30+
reqwest = { version = "0.11.16", default-features = false, features = ["rustls-tls"] }
3231
semver = "1.0"
3332
serde = { version = "1.0", features = ["derive"] }
3433
serde_json = "1.0"
@@ -48,6 +47,13 @@ uuid = { version = "1.4.0", features = ["v4"] }
4847
which = "4.4"
4948

5049
[patch."https://github.com/stackabletech/operator-rs.git"]
51-
# TODO: Switch to released version
52-
# We did not want to draw a release of operator-rs just for https://github.com/stackabletech/operator-rs/pull/634
5350
# stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
51+
52+
[profile.release.package.stackablectl]
53+
# opt-level = "z" # We don't use that as the binary saving is not *that* big (think of 1MB) and it's not worth it risiking performance for this
54+
strip = true
55+
# Cannot use because of https://github.com/rust-lang/cargo/issues/8264#issuecomment-751931213
56+
# lto = true
57+
codegen-units = 1
58+
# Cannot use because of https://github.com/rust-lang/cargo/issues/8264#issuecomment-751931213
59+
# panic = "abort"

0 commit comments

Comments
 (0)