Skip to content

Commit

Permalink
Split debug and release build
Browse files Browse the repository at this point in the history
  • Loading branch information
creatoy committed Nov 7, 2023
1 parent 9feb5b0 commit 94a693f
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 22 deletions.
97 changes: 76 additions & 21 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Action name
name: Deploy
name: Release

# 触发条件,这里是新的 tag 被 push 时触发
on:
Expand Down Expand Up @@ -85,6 +85,70 @@ jobs:
command: build
args: --verbose --target ${{ matrix.target }}

# 打包上传二进制文件
- name: Archive files (debug)
shell: bash
run: |
addon_name="hid"
bin_dir="debug_build/addons/$addon_name/bin"
bin_name="${addon_name}_ext"
mkdir -p $bin_dir
if [ "${{ matrix.platform }}" = "linux" ]; then
tree target/${{ matrix.target }}/debug/
bin_file_debug="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.debug.so"
mv target/${{ matrix.target }}/debug/lib$bin_name.so $bin_dir/$bin_file_debug
debug_info="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.debug.so.dwp"
mv target/${{ matrix.target }}/debug/lib$bin_name.so.dwp $bin_dir/$debug_info
elif [ "${{ matrix.platform }}" = "macos" ]; then
tree target/${{ matrix.target }}/debug/
bin_file_debug="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.debug.dylib"
mv target/${{ matrix.target }}/debug/lib$bin_name.dylib $bin_dir/$bin_file_debug
debug_info="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.debug.dylib.dSYM"
mv target/${{ matrix.target }}/debug/deps/lib$bin_name.dylib.dSYM $bin_dir/$debug_info
elif [ "${{ matrix.platform }}" = "windows" ]; then
bin_file_debug="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.debug.dll"
mv target/${{ matrix.target }}/debug/$bin_name.dll $bin_dir/$bin_file_debug
debug_info="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.debug.pdb"
mv target/${{ matrix.target }}/debug/$bin_name.pdb $bin_dir/$debug_info
else
echo "Unsupported platform: ${{ matrix.platform }}"
fi
cat>$bin_dir/../$addon_name.gdextension<<EOF
[configuration]
entry_symbol = "${addon_name}_ext_init"
compatibility_minimum = 4.1
[libraries]
${{ matrix.platform }}.debug.${{ matrix.arch }} = "bin/$bin_file_debug"
EOF
archive_name="$addon_name-${{ env.VERSION }}-${{ matrix.platform }}-debug-${{ matrix.arch }}"
cd debug_build
if [ "${{ matrix.platform }}" = "windows" ]; then
7z a "../$archive_name.zip" "addons"
echo "ASSET_DEBUG=$archive_name.zip" >> $GITHUB_ENV
else
tree addons
tar -czvf "../$archive_name.tar.gz" "addons"
echo "ASSET_DEBUG=$archive_name.tar.gz" >> $GITHUB_ENV
fi
- name: Release files (debug)
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.ASSET_DEBUG }}
# 构建二进制文件
- name: Build binary files (release)
uses: actions-rs/cargo@v1
with:
Expand All @@ -93,32 +157,22 @@ jobs:
args: --verbose --release --target ${{ matrix.target }}

# 打包上传二进制文件
- name: Archive files
- name: Archive files (release)
shell: bash
run: |
addon_name="hid"
bin_dir="addons/$addon_name/bin"
bin_dir="release_build/addons/$addon_name/bin"
bin_name="${addon_name}_ext"
mkdir -p $bin_dir
if [ "${{ matrix.platform }}" = "linux" ]; then
bin_file_debug="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.debug.so"
bin_file_release="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.release.so"
mv target/${{ matrix.target }}/debug/lib$bin_name.so $bin_dir/$bin_file_debug
mv target/${{ matrix.target }}/release/lib$bin_name.so $bin_dir/$bin_file_release
elif [ "${{ matrix.platform }}" = "macos" ]; then
bin_file_debug="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.debug.dylib"
bin_file_release="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.release.dylib"
mv target/${{ matrix.target }}/debug/lib$bin_name.dylib $bin_dir/$bin_file_debug
mv target/${{ matrix.target }}/release/lib$bin_name.dylib $bin_dir/$bin_file_release
elif [ "${{ matrix.platform }}" = "windows" ]; then
bin_file_debug="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.debug.dll"
bin_file_release="lib$bin_name.${{ matrix.platform }}.${{ matrix.arch }}.release.dll"
mv target/${{ matrix.target }}/debug/$bin_name.dll $bin_dir/$bin_file_debug
mv target/${{ matrix.target }}/release/$bin_name.dll $bin_dir/$bin_file_release
else
echo "Unsupported platform: ${{ matrix.platform }}"
Expand All @@ -130,23 +184,24 @@ jobs:
compatibility_minimum = 4.1
[libraries]
${{ matrix.platform }}.debug.${{ matrix.arch }} = "bin/$bin_file_debug"
${{ matrix.platform }}.release.${{ matrix.arch }} = "bin/$bin_file_release"
EOF
archive_name="$addon_name-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}"
archive_name="$addon_name-${{ env.VERSION }}-${{ matrix.platform }}-release-${{ matrix.arch }}"
cd release_build
if [ "${{ matrix.platform }}" = "windows" ]; then
7z a "$archive_name.zip" "addons"
echo "ASSET=$archive_name.zip" >> $GITHUB_ENV
7z a "../$archive_name.zip" "addons"
echo "ASSET_RELEASE=$archive_name.zip" >> $GITHUB_ENV
else
tree addons
tar -czvf "$archive_name.tar.gz" "addons"
echo "ASSET=$archive_name.tar.gz" >> $GITHUB_ENV
tar -czvf "../$archive_name.tar.gz" "addons"
echo "ASSET_RELEASE=$archive_name.tar.gz" >> $GITHUB_ENV
fi
- name: Release files
- name: Release files (release)
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.ASSET }}
${{ env.ASSET_RELEASE }}
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hid"
version = "0.0.2"
version = "0.0.3"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -12,3 +12,6 @@ crate-type = ["cdylib"]
[dependencies]
hidapi = "2.4.1"
godot = { git = "https://github.com/godot-rust/gdext", branch = "master" }

[profile.dev]
split-debuginfo = "packed"

0 comments on commit 94a693f

Please sign in to comment.