Skip to content

Commit

Permalink
Publish as a Cargo package with explicit binary and library targets (#19
Browse files Browse the repository at this point in the history
)

Following @Holzhaus's great feedback in #16 and initial implementation in #17, this configures the project so that it can be published as a Cargo package on [Crates.io](https://crates.io/).

The Cargo package exposes a binary target, which can be easily installed with `cargo install litra`, plus a library target which can be used to integrate Litra control into other Rust applications.

The package will be automatically published to Crates.io when a release is created.
  • Loading branch information
timrogers authored Feb 12, 2024
1 parent a2d6a5c commit 78d1dd6
Show file tree
Hide file tree
Showing 4 changed files with 496 additions and 435 deletions.
57 changes: 54 additions & 3 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,31 @@ jobs:
with:
path: litra_${{ steps.sanitise_ref.outputs.value }}_${{ matrix.job.binary_name }}
name: litra_${{ steps.sanitise_ref.outputs.value }}_${{ matrix.job.binary_name }}
release:
cargo_publish_dry_run:
name: Publish with Cargo in dry-run mode
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Install libudev-dev
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: Cache Rust dependencies
uses: actions/[email protected]
with:
path: target
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-build-
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
profile: minimal
components: rustc, cargo
toolchain: nightly
override: true
- name: Publish to Crates.io
run: cargo publish --dry-run
create_github_release:
name: Create release with binary assets
runs-on: ubuntu-latest
needs: build
Expand Down Expand Up @@ -83,7 +107,7 @@ jobs:
publish_on_homebrew:
name: Publish release on Homebrew
runs-on: ubuntu-latest
needs: release
needs: create_github_release
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Get released version
Expand All @@ -97,4 +121,31 @@ jobs:
push-to: timrogers/homebrew-tap
create-pullrequest: true
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
cargo_publish:
name: Publish with Cargo to Crates.io
runs-on: ubuntu-latest
needs:
- create_github_release
- cargo_publish_dry_run
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Install libudev-dev
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: Cache Rust dependencies
uses: actions/[email protected]
with:
path: target
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-build-
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
profile: minimal
components: rustc, cargo
toolchain: nightly
override: true
- name: Publish to Crates.io
run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
name = "litra"
version = "0.2.1"
edition = "2021"
authors = ["Tim Rogers <[email protected]>"]
description = "Control your Logitech Litra light from the command line"
repository = "https://github.com/timrogers/litra-rs"
license = "MIT"
readme = "README.md"
categories = ["hardware-support", "command-line-utilities"]
keywords = ["logitech", "litra", "glow", "beam", "light"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
Loading

0 comments on commit 78d1dd6

Please sign in to comment.