-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
72 lines (66 loc) · 2.28 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# .github/actions/cbindgen-action/action.yml
name: 'Generate bindings with cbindgen'
description: 'Generates C bindings with cbindgen for a Rust project'
branding:
icon: 'hash'
color: 'red'
inputs:
rust-project-path:
description: 'Path to the Rust project'
required: false
default: '.'
config-file:
description: 'Configuration file for cbindgen'
required: true
default: 'cbindgen.toml'
output-header-file:
description: 'Path to the output header file generated by cbindgen'
required: true
default: 'bindings_c.h'
upload-artifact:
description: 'Whether to upload the generated header file as an artifact'
required: false
default: 'true'
github-token:
description: 'A GitHub token for pushing to the repo. Example: `secrets.GITHUB_TOKEN`'
required: false
commit-updated-bindings:
description: 'Whether to commit the updated bindings'
required: false
default: 'false'
runs:
using: 'composite'
steps:
# Rust preinstalled on runner
- name: Setup Rust Caching
uses: Swatinem/rust-cache@v2
with:
key: ${{ inputs.target }}
cache-on-failure: true
# Note: Cached by setup-rust-toolchain
- name: Install cbindgen
shell: bash
working-directory: ${{ inputs.rust-project-path }}
run: cargo install cbindgen
- name: Generate bindings
shell: bash
working-directory: ${{ inputs.rust-project-path }}
run: cbindgen --config ${{ inputs.config-file }} --output ${{ inputs.output-header-file }}
- name: Upload header file
if: ${{ inputs.upload-artifact == 'true' }}
uses: actions/upload-artifact@v4
with:
name: C-Bindings-${{ inputs.output-header-file }}
path: ${{ inputs.rust-project-path }}/${{ inputs.output-header-file }}
- name: Commit updated bindings
if: ${{ inputs.commit-updated-bindings == 'true' }}
uses: stefanzweifel/git-auto-commit-action@v4
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
with:
commit_message: Update generated C bindings
branch: ${{ github.ref_name }}
commit_user_name: cbindgen-action
commit_user_email: [email protected]
commit_author: cbindgen-action <[email protected]>
file_pattern: ${{ inputs.output-header-file }}