Skip to content

Commit

Permalink
feat: rust bindgen and publish flow
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek committed Jun 24, 2024
1 parent 5ca1067 commit 13cc458
Show file tree
Hide file tree
Showing 8 changed files with 276 additions and 50 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/cargo-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: cargo publish

on:
push:
tags: ["**"]

permissions: write-all

jobs:
build:
57 changes: 39 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ jobs:
if: startsWith(matrix.config.os, 'ubuntu')
run: |
sudo apt-get install -y clang-format
clang-format --Werror --dry-run src/binding.cc
clang-format --verbose --Werror --dry-run src/*.cc src/*.hpp
- name: Test (ASAN)
env:
Expand Down Expand Up @@ -231,10 +231,10 @@ jobs:

- name: Prepare binary publish
if: matrix.config.variant == 'debug' || matrix.config.variant == 'release'
run: gzip -9c
target/${{ matrix.config.target }}/${{ matrix.config.variant }}/gn_out/obj/${{ env.LIB_NAME }}.${{ env.LIB_EXT }} >
target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz &&
run: |
gzip -9c target/${{ matrix.config.target }}/${{ matrix.config.variant }}/gn_out/obj/${{ env.LIB_NAME }}.${{ env.LIB_EXT }} > target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
ls -l target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
cp target/${{ matrix.config.target }}/${{ matrix.config.variant}}/gn_out/src_binding.rs target/src_binding_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
- name: Binary publish
uses: softprops/[email protected]
Expand All @@ -247,25 +247,46 @@ jobs:
with:
files: target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz

# TODO: add clang-format and maybe cpplint.
- name: Upload CI artifacts
uses: actions/upload-artifacts@v4
with:
name: src_binding_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
path: target/src_binding_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs

publish:
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'denoland/rusty_v8'
needs: build
runs-on: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
steps:
- name: Configure git
run: git config --global core.symlinks true

- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 10
submodules: recursive

- name: Install rust
uses: dsherret/rust-toolchain-file@v1

- name: Install python
uses: actions/setup-python@v4
with:
python-version: 3.11.x
architecture: x64

- name: Download CI artifacts
uses: actions/download-artifact@v4
with:
path: gen
pattern: src_binding_*.rs
merge-multiple: true

- name: Cargo Package
if: >-
github.repository == 'denoland/rusty_v8' &&
startsWith(matrix.config.target , 'x86_64') &&
matrix.config.variant == 'debug' &&
runner.os == 'Linux'
run: cargo package -vv --locked

- name: Publish
# Only publish on x64 linux when there's a git tag:
if: >-
startsWith(github.ref, 'refs/tags/') &&
github.repository == 'denoland/rusty_v8' &&
startsWith(matrix.config.target , 'x86_64') &&
!endsWith(matrix.config.target , 'android') &&
matrix.config.variant == 'debug' &&
runner.os == 'Linux'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -vv
111 changes: 110 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ gzip-header = "1.0.0"
fslock = "0.2"
which = "6"
home = "0"
bindgen = "0.69"

[dev-dependencies]
miniz_oxide = "0.7.3"
Expand All @@ -107,6 +108,7 @@ trybuild = "1.0.96"
which = "6"
home = "0"
rustversion = "1"
bindgen = "0.69"

[[example]]
name = "hello_world"
Expand Down
Loading

0 comments on commit 13cc458

Please sign in to comment.