Skip to content

Commit

Permalink
Use cross-compile CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
KmolYuan committed Aug 24, 2024
1 parent 8f223aa commit 1ca2b2d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 42 deletions.
7 changes: 7 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build]
target = [
"wasm32-unknown-unknown",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin",
]
82 changes: 40 additions & 42 deletions .github/workflows/gh-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,68 +17,66 @@ jobs:
cargo publish -p four-bar || true
cargo publish -p four-bar-ui || true
gh-test-release:
strategy:
matrix:
include:
- os: ubuntu-latest
asset_name: four-bar-linux-amd64
artifact_name: target/release/four-bar
- os: ubuntu-latest
asset_name: four-bar-wasm-unknown
artifact_name: four-bar-ui/dist/
- os: macos-latest
asset_name: four-bar-macos-amd64
artifact_name: target/release/four-bar
- os: windows-latest
asset_name: four-bar-windows-amd64
artifact_name: target/release/four-bar.exe
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- if: matrix.asset_name == 'four-bar-linux-amd64'
name: Linux requirements
run: |
- run: |
sudo apt update
sudo apt install -y libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libgtk-3-dev
- if: matrix.asset_name == 'four-bar-wasm-unknown'
name: WASM Build
working-directory: four-bar-ui
cargo clippy -- -D warnings
cargo test -p four-bar
cargo build --release -F native-win-release --target x86_64-pc-windows-gnu
cargo build --release --target x86_64-unknown-linux-gnu
cargo build --release --target x86_64-apple-darwin
- name: WASM Build
run: |
rustup target add wasm32-unknown-unknown
cargo install trunk
trunk build --release --filehash=false
# For GH-Pages
trunk build --release --filehash=false --public-url=/four-bar-rs/ --dist=docs
- if: matrix.asset_name != 'four-bar-wasm-unknown'
name: Native Build
run: |
cargo clippy -- -D warnings
cargo test -p four-bar
cargo build --release --features=native-win-release
- name: Pack
uses: vimtor/action-zip@v1
- name: Artifacts
uses: actions/upload-artifact@v4
with:
files: ${{ matrix.artifact_name }}
dest: ${{ matrix.asset_name }}.zip
- name: Upload artifact
uses: actions/upload-artifact@v3
name: four-bar-x86_64
path: target/*/release/four-bar
if-no-files-found: error
- name: WASM Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.artifact_name }}
name: four-bar-wasm32
path: four-bar-ui/docs/*
if-no-files-found: error
- name: WASM Pack
uses: vimtor/action-zip@v1
with:
files: four-bar-ui/docs/*
dest: four-bar-wasm32.zip
- name: Windows Pack
uses: vimtor/action-zip@v1
with:
files: target/x86_64-pc-windows-gnu/release/four-bar.exe
dest: four-bar-windows-x86_64.zip
- name: Linux Pack
uses: vimtor/action-zip@v1
with:
files: target/x86_64-unknown-linux-gnu/release/four-bar
dest: four-bar-linux-x86_64.zip
- name: MacOS Pack
uses: vimtor/action-zip@v1
with:
files: target/x86_64-apple-darwin/release/four-bar
dest: four-bar-macos-x86_64.zip
- if: startsWith(github.ref, 'refs/tags/v')
name: Release binary
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.PUBLISH_TOKEN }}
files: ${{ matrix.asset_name }}.zip
- if: matrix.asset_name == 'four-bar-wasm-unknown'
name: Deploy to gh-pages
files: four-bar-*.zip
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
token: ${{ secrets.PUBLISH_TOKEN }}
Expand Down

0 comments on commit 1ca2b2d

Please sign in to comment.