Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ci publish workflow #22

Merged
merged 30 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c13ec5e
Added initial workflow for publishing
ScottGibb Nov 7, 2024
3f276ee
Adjusted trigger for testing purposes
ScottGibb Nov 7, 2024
8a25399
remove branch for testing
ScottGibb Nov 7, 2024
b003d0c
adjusted format of release
ScottGibb Nov 7, 2024
1ae1e98
Reduced trigger criteria
ScottGibb Nov 7, 2024
fe53465
debugging commit
ScottGibb Nov 7, 2024
df5de5e
Debugging the trigger
ScottGibb Nov 7, 2024
0e5ef91
removing if statement for CI passing
ScottGibb Nov 7, 2024
c14fcbd
release cycle verified and works
ScottGibb Nov 7, 2024
e26e3a8
Attempting to trigger it purely on tag based
ScottGibb Nov 7, 2024
f4a73ca
Added release
ScottGibb Nov 7, 2024
8db3e0a
workflow debugging
ScottGibb Nov 7, 2024
9894954
Updated ReadMe and Added Release
ScottGibb Nov 7, 2024
55b3608
Updated dependencies
ScottGibb Nov 7, 2024
5f514c4
Debugging
ScottGibb Nov 7, 2024
b66d8db
commented out version handler
ScottGibb Nov 7, 2024
b6c0b53
Putting code back to state for Tagging and Release Management
ScottGibb Nov 7, 2024
daeda22
Updated if statement for checking if CI passed
ScottGibb Nov 7, 2024
cbff2e7
reset versioning number
ScottGibb Nov 7, 2024
6621de0
Changing order to check for tags first
ScottGibb Nov 7, 2024
21e98b4
Latest changes on workflow
ScottGibb Nov 7, 2024
bd7cb6e
adding staging release registry
ScottGibb Nov 7, 2024
929f065
Added main check
ScottGibb Nov 7, 2024
fa05d88
Making the code a bit clearer for publishing to crates.io
ScottGibb Nov 7, 2024
94545f7
Commented back in main registry push
ScottGibb Nov 8, 2024
89745c8
Removed staging registry
ScottGibb Nov 11, 2024
ec51743
Reverting back to old README
ScottGibb Nov 11, 2024
7e73ad3
Removed formatting change
ScottGibb Nov 11, 2024
6dcd7fc
removed cargo.toml formatting
ScottGibb Nov 11, 2024
eab937a
removed staging registry environment variable
ScottGibb Nov 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[registries]
staging = { index = "https://github.com/rust-lang/staging.crates.io-index" }
ScottGibb marked this conversation as resolved.
Show resolved Hide resolved
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
contents: write

jobs:
# Re Run the Checks
check:
name: Check Rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install nightly
run: rustup toolchain add --component=rustfmt nightly
- name: Checks
run: ./ci.sh

release:
# Only run if the checks pass
name: Publish to crates.io
needs: check
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Verify Version
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
CARGO_VERSION=$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Version mismatch: tag is $TAG_VERSION but Cargo.toml is $CARGO_VERSION"
exit 1 # Exits with a non-zero status to fail the workflow
fi
shell: bash

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
ScottGibb marked this conversation as resolved.
Show resolved Hide resolved

- name: Build project
run: cargo build --release

- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes

- name: Publish to crates.io
env:
CARGO_REGISTRIES_STAGING_TOKEN: ${{ secrets.CARGO_REGISTRIES_STAGING_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# run: |
ScottGibb marked this conversation as resolved.
Show resolved Hide resolved
# echo "Publishing to crates.io"
# cargo publish
run: |
echo "Publishing to staging"
cargo publish --registry=staging
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ documentation = "https://docs.rs/bt-hci"
keywords = ["bluetooth", "hci", "BLE"]
categories = ["embedded", "hardware-support", "no-std"]
rust-version = "1.77"
exclude = [".github", ".vscode", "ci.sh", "rust-toolchain.toml", "rustfmt.toml", "update_uuids"]
exclude = [
".github",
".vscode",
"ci.sh",
"rust-toolchain.toml",
"rustfmt.toml",
"update_uuids",
]
ScottGibb marked this conversation as resolved.
Show resolved Hide resolved

[features]
defmt = ["dep:defmt", "embedded-io/defmt-03", "embedded-io-async/defmt-03"]
Expand Down
15 changes: 9 additions & 6 deletions README.md
ScottGibb marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[![crates.io][crates-badge]][crates-url] [![docs.rs][docs-badge]][docs-url]
# bt-hci

[crates-badge]: https://img.shields.io/crates/v/bt-hci
[crates-url]: https://crates.io/crates/bt-hci
[docs-badge]: https://docs.rs/bt-hci/badge.svg
[docs-url]: https://docs.rs/bt-hci
[![checks][checks-badge]][checks-url] [![docs.rs][docs-badge]][docs-url] [![publish][publish-badge]][crates-url] [![crates.io][crates-badge]][crates-url]
ScottGibb marked this conversation as resolved.
Show resolved Hide resolved

# bt-hci
[crates-badge]: <https://img.shields.io/crates/v/bt-hci>
[crates-url]: <https://crates.io/crates/bt-hci>
[docs-badge]: <https://docs.rs/bt-hci/badge.svg>
[docs-url]: <https://docs.rs/bt-hci>
[checks-badge]: <https://github.com/embassy-rs/bt-hci/actions/workflows/check.yml/badge.svg>
[checks-url]: <https://github.com/embassy-rs/bt-hci/actions/workflows/check.yml>
[publish-badge]: <https://github.com/embassy-rs/bt-hci/actions/workflows/publish.yml/badge.svg>

Rust types for the Bluetooth HCI (Host Controller Interface) specification, and traits for implementing the `Controller` part
of the interface.
Expand Down