Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
realtimetodie committed Jan 1, 2024
0 parents commit 0dc12db
Show file tree
Hide file tree
Showing 22 changed files with 2,217 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI
on:
push:
branches: ["main"]
pull_request: {}
jobs:
cargo:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta]
steps:
- uses: actions/checkout@v4
- name: Install dependencies (linux)
run: |
sudo apt install -y protobuf-compiler
echo "PROTOC=$(which protoc)" >> $GITHUB_ENV
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: clippy, rustfmt
- name: Run cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run cargo fmt
run: cargo fmt --all --check
- name: Run cargo sort
run: |
cargo install cargo-sort
cargo sort --grouped --check
- name: Run cargo test
run: cargo test --all-features --all-targets
84 changes: 84 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: publish
on: workflow_dispatch
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
alias: unknown-linux-gnu
- os: macos-12
alias: x86_64-apple-darwin
- os: macos-13-xlarge
alias: aarch64-apple-darwin
- os: windows-latest
alias: pc-windows-msvc
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- if: matrix.os == 'ubuntu-latest'
name: Install dependencies (linux)
run: |
sudo apt install -y protobuf-compiler
echo "PROTOC=$(which protoc)" >> $GITHUB_ENV
- if: matrix.os == 'macos-12' || matrix.os == 'macos-13-xlarge'
name: Install dependencies (macos)
run: |
brew install protobuf
echo "PROTOC=$(which protoc)" >> $GITHUB_ENV
- if: matrix.sys.os == 'windows-latest'
name: Install MSYS2 (windows)
uses: msys2/setup-msys2@v2
- if: matrix.os == 'windows-latest'
name: Install dependencies (windows)
run: choco install protoc
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Run cargo build
run: cargo build --profile=release-bin
- if: "!cancelled()"
uses: actions/upload-artifact@v4
with:
name: crx-${{ matrix.alias }}
path: target/release-bin/{crx,crx.exe}
if-no-files-found: error
publish:
name: Publish crate
runs-on: [ubuntu-latest]
needs: [build]
if: ${{ always() && !cancelled() && needs.build.result == 'success' }}
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to crates.io
run: cargo login $CRATES_IO_TOKEN
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish
run: cargo publish
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
release:
runs-on: [ubuntu-latest]
needs: [build, publish]
if: ${{ always() && !cancelled() && needs.publish.result == 'success' && needs.build.result == 'success' }}
steps:
- uses: actions/download-artifact@v4
with:
path: /artifacts
- name: Create 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
gh release upload "$tag" /artifacts
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/Cargo.lock
68 changes: 68 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[package]
name = "crx"
version = "0.1.0"
edition = "2021"
authors = ["realtimetodie"]
description = "A library to read and write as CRX packages"
keywords = [
"browser",
"browser extension",
"crx",
"chrome",
"chrome extension",
"extension",
"web",
"web extension",
]
categories = [
"command-line-utilities",
"cryptography",
"decoding",
"encoding",
"web-programming",
"no-std",
]
license = "GPL-3.0"
documentation = "https://docs.rs/crx/"
repository = "https://github.com/realtimetodie/crx"
rust-version = "1.65"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lib]
crate-type = ["cdylib", "rlib"]
path = "src/lib.rs"

[[bin]]
name = "crx"
path = "src/main.rs"

[features]
default = ["ecdsa", "rsa", "std"]
ecdsa = ["dep:ecdsa", "dep:p256"]
rsa = ["dep:rsa", "dep:sha2"]
std = []
wasm = ["getrandom/js", "dep:wasm-bindgen"]

[dependencies]
clap = "4.4.12"
const-oid = { version = "0.9.6", features = ["db"] }
ecdsa = { version = "0.16.9", default-features = false, features = ["pem", "pkcs8", "verifying"], optional = true }
getrandom = { version = "0.2.11", optional = true }
p256 = { version = "0.13.2", optional = true }
pkcs8 = { version = "0.10.2", features = ["encryption", "std", "pkcs5"] }
prost = "0.12.3"
rand = "0.8.5"
rsa = { version = "0.9.6", default-features = false, features = ["sha2"], optional = true }
sha2 = { version = "0.10.8", optional = true }
signature = "2.2.0"
wasm-bindgen = { version = "0.2.89", optional = true }

[build-dependencies]
prost-build = "0.12.3"

[profile.release-bin]
inherits = "release"
strip = "debuginfo"
Loading

0 comments on commit 0dc12db

Please sign in to comment.