-
Notifications
You must be signed in to change notification settings - Fork 99
63 lines (60 loc) · 2.78 KB
/
publish-crates.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
# This workflow is used for publish crate to crates.io. The workflow will use
# environment "Publish to crates.io" which needs approval to access the `CARGO_REGISTRY_TOKEN`
name: Publish Crates
on:
# The workflow can be triggered or by creating new release: please ensure the tag name used for the
# release follow this format: '${crate name}_v{version number}', although in this workflow
# only ${crate name} is used, but {version number} is still needed for a good tag name.
release:
types: [created]
# The workflow can be also manually triggered by `workflow_dispatch`, see more
# from: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
inputs:
crate_name:
description: 'Name of crate to be published'
required: true
type: string
permissions:
contents: read
jobs:
crate_publish:
environment: "Publish to crates.io"
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install build dependencies
run: |
cat llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main" | sudo tee -a /etc/apt/sources.list
cat intel-sgx-deb.key | sudo apt-key add -
echo "deb https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y clang-11 libsgx-dcap-ql-dev protobuf-compiler
# Create a symbolic link to ensure correct usage of libclang
sudo ln -s /lib/x86_64-linux-gnu/libclang-11.so.1 /lib/x86_64-linux-gnu/libclang.so
- name: Get name of crate to be published
run: |
# If this workflow is manually triggered through `workflow_dispatch`
if [[ -z "${{ inputs.crate_name }}" ]]; then
# Extract the crate name from the GITHUB_REF environment variable
# GITHUB_REF contains the GitHub reference (e.g., refs/tags/rs-lic_v0.2.4) associated with the event
export CRATE_NAME=$(python3 -c "print('$GITHUB_REF'.split('/')[2].rsplit('_v', 1)[0])")
else
export CRATE_NAME="${{ inputs.crate_name }}"
fi
echo "CRATE_NAME=$CRATE_NAME" >> $GITHUB_ENV
- name: Publish crate to crates.io
run: |
echo "Publishing crate: $CRATE_NAME"
cargo publish --locked --token ${CARGO_REGISTRY_TOKEN} --package "$CRATE_NAME"
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
RUST_BACKTRACE: "1"
PYTHONDONTWRITEBYTECODE: "1"