Skip to content

Commit 42c02cc

Browse files
authored
Merge pull request #247 from LedgerHQ/y333/motherfucker_readme
Y333/motherfucker readme
2 parents 17fa220 + 78fc734 commit 42c02cc

File tree

8 files changed

+93
-105
lines changed

8 files changed

+93
-105
lines changed

.github/workflows/publish.yml

Lines changed: 36 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ name: Publish to Crates.io
22

33
on:
44
push:
5-
tags:
6-
- '*@*.*.*' # Match tags like '[email protected]'
5+
branches:
6+
- master
77
workflow_dispatch: # Allow manual workflow dispatch
88

99
jobs:
10-
test-dry-run:
10+
dry-run-publish:
1111
runs-on: ubuntu-latest
1212
if: github.event_name == 'workflow_dispatch' # Only run this job for manual triggers
1313

@@ -21,33 +21,31 @@ jobs:
2121
profile: minimal
2222
toolchain: stable
2323

24-
- name: Retrieve Package Names from workspace root
25-
id: get-root-packages
26-
run: |
27-
# Retrieve package names from the workspace root
28-
PACKAGE_NAMES=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[].name' | tr '\n' ' ')
29-
30-
# Set the package names as an output
31-
echo "Package names from root Cargo.toml: $PACKAGE_NAMES"
32-
echo "::set-output name=package-names::$PACKAGE_NAMES"
33-
shell: bash
34-
working-directory: ${{ github.workspace }}
35-
3624
- name: Test Dry-Run Publish for Each Package
3725
run: |
3826
# Iterate through package names retrieved
39-
PACKAGE_NAMES="${{ steps.get-root-packages.outputs.package-names }}"
27+
PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk"
4028
for PACKAGE_NAME in $PACKAGE_NAMES; do
41-
# Test a dry-run publish for each package within the workspace
42-
cargo publish --dry-run --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --package "$PACKAGE_NAME"
29+
# Test a dry-run publish for each package within the workspace if required
30+
last_published_version=$(cargo search -q --limit 1 $PACKAGE_NAME | grep -oP '\d+\.\d+\.\d+')
31+
echo "Published version of $PACKAGE_NAME is $version_published"
32+
manifest_version=$(cargo metadata --format-version=1 --no-deps | jq -r --arg PACKAGE_NAME "$PACKAGE_NAME" '.packages[] | select(.name == $PACKAGE_NAME) | .version')
33+
echo "Current version in manifest for $PACKAGE_NAME is $manifest_version"
34+
if [ "$last_published_version" == "$manifest_version" ]; then
35+
echo "Package $PACKAGE_NAME is already published with version $manifest_version."
36+
else
37+
echo "Package $PACKAGE_NAME is not published with version $manifest_version."
38+
echo "Dry-run publishing $PACKAGE_NAME..."
39+
cargo publish --dry-run --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --package "$PACKAGE_NAME"
40+
fi
4341
done
4442
env:
4543
CARGO_TERM_COLOR: always
4644
working-directory: ${{ github.workspace }}
4745

48-
build-and-publish:
46+
crates-io-publish:
4947
runs-on: ubuntu-latest
50-
if: github.event_name == 'push' # Only run this job for tag pushes
48+
if: github.event_name == 'push' # Only run this job for pushes
5149

5250
steps:
5351
- name: Checkout Code
@@ -58,48 +56,25 @@ jobs:
5856
with:
5957
profile: minimal
6058
toolchain: stable
61-
62-
- name: Determine Package to Publish
63-
id: determine-package
64-
run: |
65-
# Extract package name from the tag name
66-
TAG_NAME="${{ github.ref }}"
67-
PACKAGE_NAME=$(echo "$TAG_NAME" | cut -d'/' -f3 | cut -d'@' -f1)
68-
69-
PACKAGE_NAMES=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[].name' | tr '\n' ' ')
70-
71-
# Check if the extracted package name is a valid package in the workspace root Cargo.toml
72-
if [[ ! " $PACKAGE_NAMES " =~ " $PACKAGE_NAME " ]]; then
73-
echo "Invalid package name: $PACKAGE_NAME"
74-
exit 1
75-
fi
76-
echo "Package to publish: $PACKAGE_NAME"
77-
echo "::set-output name=package::$PACKAGE_NAME"
78-
shell: bash
79-
working-directory: ${{ github.workspace }}
80-
81-
- name: Check Package Version
82-
id: check-version
83-
run: |
84-
PACKAGE_NAME="${{ steps.determine-package.outputs.package }}"
85-
TAG_VERSION=$(echo "${{ github.ref }}" | cut -d'@' -f2)
86-
MANIFEST_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r --arg PACKAGE_NAME "$PACKAGE_NAME" '.packages[] | select(.name == $PACKAGE_NAME) | .version')
87-
88-
if [ "$TAG_VERSION" != "$MANIFEST_VERSION" ]; then
89-
echo "Package version in manifest $MANIFEST_VERSION does not match tag version $TAG_VERSION."
90-
exit 1
91-
else
92-
echo "Package version in manifest matches tag version."
93-
fi
94-
shell: bash
95-
working-directory: ${{ github.workspace }}
96-
97-
- name: Build and Publish
59+
60+
- name: Publish Package on crates.io if required
9861
run: |
99-
PACKAGE_NAME="${{ steps.determine-package.outputs.package }}"
100-
101-
# Publish the specified package within the workspace to crates.io
102-
cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --package "$PACKAGE_NAME"
62+
# Iterate through package names retrieved
63+
PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk"
64+
for PACKAGE_NAME in $PACKAGE_NAMES; do
65+
# Publish each package within the workspace if required
66+
last_published_version=$(cargo search -q --limit 1 $PACKAGE_NAME | grep -oP '\d+\.\d+\.\d+')
67+
echo "Published version of $PACKAGE_NAME is $version_published"
68+
manifest_version=$(cargo metadata --format-version=1 --no-deps | jq -r --arg PACKAGE_NAME "$PACKAGE_NAME" '.packages[] | select(.name == $PACKAGE_NAME) | .version')
69+
echo "Current version in manifest for $PACKAGE_NAME is $manifest_version"
70+
if [ "$last_published_version" == "$manifest_version" ]; then
71+
echo "Package $PACKAGE_NAME is already published with version $manifest_version."
72+
else
73+
echo "Package $PACKAGE_NAME is not published with version $manifest_version."
74+
echo "Publishing $PACKAGE_NAME..."
75+
cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --package "$PACKAGE_NAME"
76+
fi
77+
done
10378
env:
10479
CARGO_TERM_COLOR: always
10580
working-directory: ${{ github.workspace }}

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
# Ledger Device Rust SDK
2-
This workspace contains the 5 crates members of Ledger Device Rust SDK
2+
[![DEV SUPPORT](https://img.shields.io/badge/Dev_Support-red?logo=discord
3+
)](https://discord.com/channels/885256081289379850/912241185677000704)
34

4-
* [ledger_device_sdk](./ledger_device_sdk): main Rust SDK crate used to build an application that runs on BOLOS OS,
5-
* [ledger_secure_sdk_sys](./ledger_secure_sdk_sys): bindings to [ledger_secure_sdk](https://github.com/LedgerHQ/ledger-secure-sdk)
6-
* [include_gif](./include_gif): procedural macro used to manage GIF
7-
* [testmacro](./testmacro): procedural macro used by unit and integrations tests
8-
* [cargo-ledger](./cargo-ledger): tool to build Ledger device applications developped in Rust
5+
## Crates
6+
7+
| Crate | Description | Latest Release |
8+
| ------------------------------------------------ | --------------------------------------------------------------- | -------------- |
9+
| [cargo-ledger](./cargo-ledger) | Cargo extension required to build Ledger applications | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fcargo-ledger%2FCargo.toml&query=%24.package.version&label=version) |
10+
| [ledger_device_sdk](./ledger_device_sdk) | Rust SDK | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_device_sdk%2FCargo.toml&query=%24.package.version&label=version) |
11+
| [ledger_secure_sdk_sys](./ledger_secure_sdk_sys) | [C SDK](https://github.com/LedgerHQ/ledger-secure-sdk) bindings | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_secure_sdk_sys%2FCargo.toml&query=%24.package.version&label=version) |
12+
| [include_gif](./include_gif) | Procedural macro to integrate logo in the UI/UX | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Finclude_gif%2FCargo.toml&query=%24.package.version&label=version) |
13+
| [testmacro](./testmacro) | Procedural macro used by unit and integrations tests | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Ftestmacro%2FCargo.toml&query=%24.package.version&label=version) |
14+
15+
## Docker builder
16+
17+
Docker images are available and shall be used to build and test Rust applications for Ledger devices.
18+
19+
||`full` | `dev-tools` |
20+
| ---- | ----- | ----------- |
21+
| Rust nightly-2024-12-01 toolchain | :white_check_mark: | :white_check_mark: |
22+
| cargo-ledger | :white_check_mark: | :white_check_mark: |
23+
| Rust Ledger devices custom targets | :white_check_mark: | :white_check_mark: |
24+
| ARM & LLVM toolchains | :white_check_mark: | :white_check_mark: |
25+
| [Speculos](https://github.com/LedgerHQ/speculos) | :x: | :white_check_mark: |
26+
| [Ragger](https://github.com/LedgerHQ/ragger)  | :x: | :white_check_mark: |
27+
28+
Please check [here](https://github.com/LedgerHQ/ledger-app-builder) for more details.
29+
30+
## Links
31+
32+
To learn more about using the SDK and what is required to publish an app on the Ledger Live app store, please don't hesitate to check the following resources:
33+
34+
- 📚 [Developer's documentation](https://developers.ledger.com/)
35+
- 🗣️ [Ledger's Discord server](https://discord.gg/Ledger)
36+
- 📦 [Fully featured boilerplate app](https://github.com/LedgerHQ/app-boilerplate-rust)

cargo-ledger/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# Cargo-ledger
1+
# cargo-ledger
2+
![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fcargo-ledger%2FCargo.toml&query=%24.package.version&label=version)
23

3-
Builds a Nano App and outputs a JSON manifest file that can be used by [ledgerctl](https://github.com/LedgerHQ/ledgerctl) to install an application directly.
4+
Builds a Ledger device embedded app and outputs a JSON/TOML manifest file that can be used by [ledgerctl](https://github.com/LedgerHQ/ledgerctl) to install an application directly on a device.
45

5-
In order to build for Nano S, Nano X, and Nano S Plus, [custom target files](https://docs.rust-embedded.org/embedonomicon/custom-target.html) are used. They can be found at the root of the [Rust SDK](https://github.com/LedgerHQ/ledger-nanos-sdk/) and can be installed automatically with the command `setup`.
6+
In order to build for Nano X, Nano S Plus, Stax and Flex [custom target files](https://docs.rust-embedded.org/embedonomicon/custom-target.html) are used. They can be found at the root of the [ledger_secure_sdk_sys](https://github.com/LedgerHQ/ledger_secure_sdk_sys/) and can be installed automatically with the command `cargo ledger setup`.
67

78
## Installation
89

@@ -41,9 +42,10 @@ cargo ledger setup
4142
### Building
4243

4344
```
44-
cargo ledger build nanos
4545
cargo ledger build nanox
4646
cargo ledger build nanosplus
47+
cargo ledger build stax
48+
cargo ledger build flex
4749
```
4850

4951
Loading on device can optionally be performed by appending `--load` or `-l` to the command.

include_gif/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
# sdk_include_gif
1+
# include_gif
2+
![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Finclude_gif%2FCargo.toml&query=%24.package.version&label=version)
23

3-
This crate provides a macro `include_gif!("path/to/image.gif")` that packs a gif image into a byte representation that can be understood by the [Rust Nano SDK](https://github.com/LedgerHQ/ledger-device-rust-sdk/tree/master/ledger_device_sdk) and included at compile time to produce black-and-white icons.
4+
This crate provides a macro `include_gif!("path/to/image.gif")` that packs a gif image into a byte representation that can be understood by the [Rust SDK](https://github.com/LedgerHQ/ledger-device-rust-sdk/tree/master/ledger_device_sdk) and included at compile time to produce icons.

ledger_device_sdk/README.md

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Ledger wallets SDK for Rust Applications
1+
# Ledger device SDK for Rust Applications
2+
![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_device_sdk%2FCargo.toml&query=%24.package.version&label=version)
23

34
Crate that allows developing Ledger device apps in Rust with a default configuration.
45

@@ -9,20 +10,11 @@ Contains:
910
- signature abstractions
1011
- UI libraries (the `ui` module for Nano (S/SP/X) apps, `nbgl` module for Stax and Flex apps)
1112

12-
## Links
13-
14-
To learn more about using the SDK and what is required to publish an app on the Ledger Live app store, please don't hesitate to check the following resources :
15-
16-
- 📚 [Developer's documentation](https://developers.ledger.com/)
17-
- 🗣️ [Ledger's Discord server](https://discord.gg/Ledger)
18-
- 📦 [Fully featured boilerplate app](https://github.com/LedgerHQ/app-boilerplate-rust)
19-
- 📦 [A Password Manager app](https://github.com/LedgerHQ/rust-app-password-manager)
20-
2113
## Supported devices
2214

23-
| Nano S | Nano X | Nano S Plus | Stax | Flex |
24-
| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ |
25-
| :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
15+
| Nano X | Nano S Plus | Stax | Flex |
16+
| ------------------ | ------------------ | ------------------ | ------------------ |
17+
| :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
2618

2719
## Usage
2820

@@ -31,7 +23,7 @@ On Ubuntu, `gcc-multilib` might also be required.
3123

3224
Using rustc nightly builds is mandatory as some unstable features are required.
3325

34-
- `rustup default nightly`
26+
- `rustup default nightly-2024-12-01`
3527
- `rustup component add rust-src`
3628
- install [Clang](http://releases.llvm.org/download.html).
3729
- install an [ARM gcc toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
@@ -51,45 +43,33 @@ sudo pacman -S clang arm-none-eabi-gcc arm-none-eabi-newlib
5143

5244
This SDK provides [custom target](https://doc.rust-lang.org/rustc/targets/custom.html) files. One for each supported device.
5345

54-
### Building for Nano S
55-
56-
```
57-
cargo build --release -Z build-std=core --target=./nanos.json
58-
```
59-
6046
### Building for Nano X
6147

6248
```
63-
cargo build --release -Z build-std=core --target=./nanox.json
49+
cargo build --release --target=nanox
6450
```
6551

6652
### Building for Nano S+
6753

6854
```
69-
cargo build --release -Z build-std=core --target=./nanosplus.json
55+
cargo build --release --target=nanosplus
7056
```
7157

7258
### Building for Stax
7359

7460
```
75-
cargo build --release -Z build-std=core --target=./stax.json
61+
cargo build --release --target=stax
7662
```
7763

7864
### Building for Flex
7965

8066
```
81-
cargo build --release -Z build-std=core --target=./flex.json
67+
cargo build --release --target=flex
8268
```
8369

84-
## Building with rustc < 1.54
85-
86-
Building before rustc 1.54 should fail with `error[E0635]: unknown feature const_fn_trait_bound`.
87-
88-
This is solved by activating a specific feature: `cargo build --features pre1_54`
89-
9070
## Contributing
9171

92-
You can submit an issue or even a pull request if you wish to contribute, we will check what we can do.
72+
You can submit an issue or even a pull request if you wish to contribute.
9373

9474
Make sure you've followed the installation steps above. In order for your PR to be accepted, it will have to pass the CI, which performs the following checks:
9575

ledger_secure_sdk_sys/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Rust Low-level bindings to the Ledger C SDK
2+
![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_secure_sdk_sys%2FCargo.toml&query=%24.package.version&label=version)
23

34
Provides access to low-level APIs to the operating system of Ledger devices.
45

testmacro/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# testmacro
2+
![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Ftestmacro%2FCargo.toml&query=%24.package.version&label=version)
23

34
A macro inspired from [Writing an OS in Rust](https://os.phil-opp.com/testing/) and [Rust Raspberry OS tutorials](https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials/tree/master/13_integrated_testing) that helps building `#![no_std]` tests in some other projects.

0 commit comments

Comments
 (0)