-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.github/workflows: add build and release binary executable
Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
- Loading branch information
Showing
2 changed files
with
108 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,62 @@ | ||
name: Build Binary Executable | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- "v*.*.*" | ||
pull_request: | ||
|
||
jobs: | ||
build-all: | ||
strategy: | ||
matrix: | ||
target: | ||
- "aarch64-apple-darwin" | ||
- "x86_64-apple-darwin" | ||
- "x86_64-unknown-linux-gnu" | ||
- "aarch64-unknown-linux-gnu" | ||
# - "x86_64-pc-windows-msvc" | ||
name: Build For ${{ matrix.target }} | ||
uses: ./.github/workflows/zigbuild.yml | ||
with: | ||
target: ${{ matrix.target }} | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: build-all | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Download All Artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: product | ||
pattern: name-* | ||
merge-multiple: false | ||
- name: compress | ||
run: | | ||
cd product | ||
for dir in */; do | ||
dirname="${dir%/}" | ||
if [[ $dirname == *"windows"* ]]; then | ||
echo "package $dirname to $dirname.zip" | ||
zip -r "$dirname.zip" "$dirname" | ||
else | ||
echo "package $dirname to $dirname.tar.gz" | ||
tar -czf "$dirname.tar.gz" "$dirname" | ||
fi | ||
done | ||
- name: List Directory | ||
run: ls -R product | ||
- name: Upload Release | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
draft: false | ||
fail_on_unmatched_files: true | ||
prerelease: false | ||
files: | | ||
./product/*.zip | ||
./product/*.tar.gz |
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,46 @@ | ||
name: Zigbuild Specify Target | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
target: | ||
required: true | ||
type: string | ||
description: compile target | ||
workflow_call: | ||
inputs: | ||
target: | ||
required: true | ||
type: string | ||
description: compile target | ||
|
||
jobs: | ||
release: | ||
runs-on: ${{ contains( inputs.target, 'linux' ) && 'ubuntu-latest' || ( contains( inputs.target, 'apple' ) && 'macos-latest' || ( contains( inputs.target, 'windows' ) && 'windows-latest' || 'ubuntu-latest' ) ) }} | ||
env: | ||
build-tool: ${{ contains( inputs.target, 'windows-msvc' ) && 'build' || 'zigbuild' }} | ||
executable: ./target/${{inputs.target}}/release/*.exe | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: install target | ||
run: rustup target add ${{ inputs.target }} | ||
- uses: goto-bus-stop/setup-zig@v2 | ||
if: ${{ env.build-tool == 'zigbuild' }} | ||
- name: Install cargo-zigbuild | ||
if: ${{ env.build-tool == 'zigbuild' }} | ||
run: cargo install cargo-zigbuild | ||
- name: cargo compile | ||
run: cargo ${{ env.build-tool }} --target ${{ inputs.target }} --release | ||
- name: show target | ||
run: ls -R ./target | ||
- name: Get product path | ||
if: ${{ runner.os != 'Windows' }} | ||
run: echo "executable=$(find . -maxdepth 4 -type f -exec file {} \; | grep 'executable' | grep 'target' | grep -o '^[^:]*')" >> "$GITHUB_ENV" | ||
- name: Upload product as an artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: executable | ||
path: | | ||
${{ env.executable }} |