-
Notifications
You must be signed in to change notification settings - Fork 228
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
1 parent
241eb48
commit 73550ae
Showing
5 changed files
with
205 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,77 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
env: | ||
RUSTC_WRAPPER: sccache | ||
SCCACHE_CACHE_SIZE: 1G | ||
SCCACHE_DIR: /home/runner/.cache/sccache | ||
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
submodules: 'recursive' | ||
- name: install zig and tools (Linux) | ||
run: | | ||
#pacman -Sy sudo rustup clang llvm lld make git --noconfirm | ||
sudo apt-get install build-essential make git clang | ||
rm -f ~/.cargo/config* | ||
mkdir -p zig | ||
curl -LZ https://ziglang.org/builds/zig-linux-x86_64-0.12.0-dev.2327+b0c8a3f31.tar.xz|tar xJ --strip-component=1 -C zig | ||
sudo mv zig /usr/local/ | ||
echo "/usr/local/zig" >> $GITHUB_PATH | ||
- name: Install sccache | ||
env: | ||
LINK: https://github.com/mozilla/sccache/releases/download | ||
SCCACHE_VERSION: 0.7.5 | ||
run: | | ||
SCCACHE_FILE=sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl | ||
mkdir -p $HOME/.local/bin | ||
curl -L "$LINK/v$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz | ||
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache | ||
chmod +x $HOME/.local/bin/sccache | ||
echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
- name: Install mold linker | ||
uses: rui314/setup-mold@staging | ||
with: | ||
mold-version: 2.4.0 | ||
make-default: true | ||
- name: Cache toolchain | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Update toolchain | ||
run: | | ||
rustup update nightly | ||
rustup default nightly | ||
rustup component add rust-src | ||
rustup target add $(cat target.txt) | ||
rustup +stable target add $(cat target.txt) | ||
- name: Install cargo-zigbuild | ||
run: | | ||
cargo install cargo-zigbuild --target x86_64-unknown-linux-gnu | ||
- name: config.toml | ||
run: | | ||
mkdir -p ~/.cargo/ | ||
rm -f ~/.cargo/config* | ||
cp config.toml ~/.cargo/config.toml | ||
- name: fix duplicate symbol | ||
run: | | ||
sudo sed -e "s|\(void __cdecl _tzset(void)\)|/*\n\1|" -e "s|\(void __cdecl tzset(void)\)|*/\n\1|" -i /usr/local/zig/lib/libc/mingw/crt/ucrtbase_compat.c | ||
- name: Build and archive | ||
shell: bash | ||
run: | | ||
cargo update | ||
make target-archive | ||
- name: Create release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
omitBody: true | ||
artifacts: 'release/*' | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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,38 @@ | ||
TARGET=$(shell cat target.txt) | ||
|
||
.PHONY: lint | ||
lint: | ||
@cargo +nightly clippy | ||
|
||
.PHONY: fix | ||
fix: | ||
@cargo +nightly clippy --fix | ||
|
||
.PHONY: test | ||
test: | ||
@cargo +nightly test | ||
|
||
.PHONY: shellspec | ||
shellspec: | ||
@shellspec | ||
|
||
.PHONY: install | ||
install: | ||
@cargo +nightly install --path . | ||
|
||
.PHONY: check | ||
check: | ||
@cargo +nightly check | ||
|
||
.PHONY: target-add | ||
target-add: | ||
@rustup override set nightly | ||
@rustup target add $(TARGET) | ||
|
||
.PHONY: target-build | ||
target-build: target-add | ||
@for target in $(TARGET); do echo $$target; cargo +nightly zigbuild --release --target $$target || cargo +stable zigbuild --release --target $$target; done | ||
|
||
.PHONY: target-archive | ||
target-archive: target-build | ||
@bash archive.sh $(TARGET) |
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 @@ | ||
#!/bin/bash | ||
version=$(git describe --tags | sed -e 's/^v//g' -e 's/-g.*$//g' -e 's/-/./g') | ||
if [[ "${version}" == "" ]]; then | ||
echo "cannot get version tag from HEAD commit" | ||
exit 1 | ||
fi | ||
bin=$(basename "$(git rev-parse --show-toplevel)") | ||
target="$*" | ||
|
||
if [[ ! -d "release" ]]; then | ||
mkdir "release" | ||
fi | ||
|
||
for target in "$@"; do | ||
archive="${bin}_${version}_${target}" | ||
echo "## make archive ${archive}" | ||
if [[ "$target" == *"windows"* ]]; then | ||
( cd "target/${target}/release/" && zip "../../../release/${archive}.zip" "${bin}.exe" ) | ||
else | ||
( cd "target/${target}/release/" && tar -Jcvf "../../../release/${archive}.tar.xz" "${bin}" ) | ||
fi | ||
done |
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,64 @@ | ||
[build] | ||
target = "x86_64-unknown-linux-musl" | ||
rustc-wrapper = "sccache" | ||
|
||
[unstable] | ||
build-std = ["core", "compiler_builtins", "alloc", "std", "panic_abort"] | ||
build-std-features = ["llvm-libunwind"] | ||
|
||
[target.x86_64-unknown-linux-musl] | ||
linker = "clang" | ||
rustflags = [ | ||
"-Clink-self-contained=on", | ||
"-C", "strip=symbols", | ||
"-C", "no-redzone=y", | ||
"-C", "overflow-checks=y", | ||
"-C", "lto=fat", | ||
"-C", "embed-bitcode=y", | ||
"-C", "codegen-units=1", | ||
"-C", "opt-level=z", | ||
"-C", "control-flow-guard=y", | ||
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now", | ||
] | ||
|
||
[target.x86_64-pc-windows-gnu] | ||
linker = "clang" | ||
rustflags = [ | ||
"-C", "strip=symbols", | ||
"-C", "no-redzone=y", | ||
"-C", "overflow-checks=y", | ||
"-C", "lto=fat", | ||
"-C", "embed-bitcode=y", | ||
"-C", "codegen-units=1", | ||
"-C", "opt-level=z", | ||
"-C", "control-flow-guard=y", | ||
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now", | ||
] | ||
|
||
[target.x86_64-apple-darwin] | ||
linker = "clang" | ||
rustflags = [ | ||
"-C", "strip=symbols", | ||
"-C", "no-redzone=y", | ||
"-C", "overflow-checks=y", | ||
"-C", "lto=fat", | ||
"-C", "embed-bitcode=y", | ||
"-C", "codegen-units=1", | ||
"-C", "opt-level=z", | ||
"-C", "control-flow-guard=y", | ||
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now", | ||
] | ||
|
||
[target.aarch64-apple-darwin] | ||
linker = "clang" | ||
rustflags = [ | ||
"-C", "strip=symbols", | ||
"-C", "no-redzone=y", | ||
"-C", "overflow-checks=y", | ||
"-C", "lto=fat", | ||
"-C", "embed-bitcode=y", | ||
"-C", "codegen-units=1", | ||
"-C", "opt-level=z", | ||
"-C", "control-flow-guard=y", | ||
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now", | ||
] |
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,4 @@ | ||
x86_64-unknown-linux-musl | ||
x86_64-pc-windows-gnu | ||
x86_64-apple-darwin | ||
aarch64-apple-darwin |