From 9c346dd5ef6d4abb2e0de3d20177559c1dc40a8d Mon Sep 17 00:00:00 2001 From: Matt Luongo Date: Tue, 17 Mar 2026 12:15:59 -0400 Subject: [PATCH] cli: merge the binary and library crates --- .github/workflows/ci.yml | 4 +- .github/workflows/release.yml | 70 ++++++++++++++++++- Cargo.lock | 20 ++---- Cargo.toml | 2 +- age-plugin-argon2-cli/Cargo.toml | 33 --------- age-plugin-argon2/Cargo.toml | 13 ++++ .../age-plugin-argon2}/commands/generate.rs | 0 .../bin/age-plugin-argon2}/commands/list.rs | 0 .../bin/age-plugin-argon2}/commands/mod.rs | 0 .../src/bin/age-plugin-argon2}/encoding.rs | 0 .../src/bin/age-plugin-argon2}/main.rs | 0 .../src/bin/age-plugin-argon2}/plugin.rs | 0 .../tests/e2e.rs | 0 .../tests/integration.rs | 0 14 files changed, 88 insertions(+), 54 deletions(-) delete mode 100644 age-plugin-argon2-cli/Cargo.toml rename {age-plugin-argon2-cli/src => age-plugin-argon2/src/bin/age-plugin-argon2}/commands/generate.rs (100%) rename {age-plugin-argon2-cli/src => age-plugin-argon2/src/bin/age-plugin-argon2}/commands/list.rs (100%) rename {age-plugin-argon2-cli/src => age-plugin-argon2/src/bin/age-plugin-argon2}/commands/mod.rs (100%) rename {age-plugin-argon2-cli/src => age-plugin-argon2/src/bin/age-plugin-argon2}/encoding.rs (100%) rename {age-plugin-argon2-cli/src => age-plugin-argon2/src/bin/age-plugin-argon2}/main.rs (100%) rename {age-plugin-argon2-cli/src => age-plugin-argon2/src/bin/age-plugin-argon2}/plugin.rs (100%) rename {age-plugin-argon2-cli => age-plugin-argon2}/tests/e2e.rs (100%) rename {age-plugin-argon2-cli => age-plugin-argon2}/tests/integration.rs (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 291f0d9..38f365e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,9 +52,9 @@ jobs: git clone https://github.com/FiloSottile/passage sudo make -C passage install PREFIX=/usr/local - name: Build plugin binary - run: cargo build -p age-plugin-argon2-cli + run: cargo build -p age-plugin-argon2 - name: Run e2e tests - run: cargo test -p age-plugin-argon2-cli --features e2e --test e2e + run: cargo test -p age-plugin-argon2 --features e2e --test e2e deny: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15f3dfd..f968adf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Release on: push: - tags: ["age-plugin-argon2-v*"] + tags: ["v*"] permissions: contents: write @@ -11,7 +11,60 @@ env: CARGO_TERM_COLOR: always jobs: + build: + name: Build ${{ matrix.target }} + strategy: + matrix: + include: + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + - target: x86_64-apple-darwin + os: macos-latest + - target: aarch64-apple-darwin + os: macos-latest + - target: x86_64-pc-windows-msvc + os: windows-latest + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 + + - name: Install musl tools + if: matrix.target == 'x86_64-unknown-linux-musl' + run: sudo apt-get install -y musl-tools + + - name: Build + run: cargo build -p age-plugin-argon2 --release --target ${{ matrix.target }} + + - name: Package (Unix) + if: runner.os != 'Windows' + run: | + VERSION="${GITHUB_REF_NAME#age-plugin-argon2-}" + ARCHIVE="age-plugin-argon2-${VERSION}-${{ matrix.target }}.tar.gz" + tar czf "$ARCHIVE" -C "target/${{ matrix.target }}/release" age-plugin-argon2 + echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV" + + - name: Package (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + $version = $env:GITHUB_REF_NAME -replace '^age-plugin-argon2-', '' + $archive = "age-plugin-argon2-${version}-${{ matrix.target }}.zip" + Compress-Archive ` + -Path "target/${{ matrix.target }}/release/age-plugin-argon2.exe" ` + -DestinationPath $archive + echo "ARCHIVE=$archive" | Out-File -FilePath $env:GITHUB_ENV -Append + + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.target }} + path: ${{ env.ARCHIVE }} + publish: + needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,7 +79,20 @@ jobs: env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + release: + needs: [build, publish] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + - name: Create GitHub release - run: gh release create "${{ github.ref_name }}" --generate-notes + run: | + gh release create "${{ github.ref_name }}" \ + --repo "${{ github.repository }}" \ + --generate-notes \ + artifacts/* env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index be854e4..967648e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,12 +74,16 @@ version = "0.2.0" dependencies = [ "age", "age-core", + "age-plugin", "argon2", "base64 0.22.1", + "bech32", "chacha20poly1305", + "clap", "hkdf", "hmac", "rand", + "rexpect", "secrecy", "serde", "serde_json", @@ -90,22 +94,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "age-plugin-argon2-cli" -version = "0.1.0" -dependencies = [ - "age", - "age-core", - "age-plugin", - "age-plugin-argon2", - "bech32", - "clap", - "rexpect", - "secrecy", - "tempfile", - "thiserror 1.0.69", -] - [[package]] name = "aho-corasick" version = "1.1.4" diff --git a/Cargo.toml b/Cargo.toml index 168eb2a..dc35cc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,3 @@ [workspace] -members = ["age-plugin-argon2", "age-plugin-argon2-cli"] +members = ["age-plugin-argon2"] resolver = "2" diff --git a/age-plugin-argon2-cli/Cargo.toml b/age-plugin-argon2-cli/Cargo.toml deleted file mode 100644 index 55e6183..0000000 --- a/age-plugin-argon2-cli/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -name = "age-plugin-argon2-cli" -version = "0.1.0" -edition = "2021" -license = "MIT OR Apache-2.0" -publish = false - -[[bin]] -name = "age-plugin-argon2" -path = "src/main.rs" - -[dependencies] -age-plugin-argon2 = { path = "../age-plugin-argon2" } -age = "0.11" -age-core = "0.11" -age-plugin = "0.6" -bech32 = "0.9" -clap = { version = "4", features = ["derive"] } -secrecy = "0.10" -thiserror = "1.0" - -[features] -e2e = [] - -[[test]] -name = "e2e" -required-features = ["e2e"] - -[dev-dependencies] -tempfile = "3" - -[target.'cfg(unix)'.dev-dependencies] -rexpect = "0.6" diff --git a/age-plugin-argon2/Cargo.toml b/age-plugin-argon2/Cargo.toml index 3bdebaf..ec9cdeb 100644 --- a/age-plugin-argon2/Cargo.toml +++ b/age-plugin-argon2/Cargo.toml @@ -9,11 +9,21 @@ readme = "../README.md" categories = ["cryptography", "authentication"] keywords = ["age", "argon2", "encryption", "password", "plugin"] +[features] +e2e = [] + +[[test]] +name = "e2e" +required-features = ["e2e"] + [dependencies] age-core = "0.11" age = "0.11" +age-plugin = "0.6" argon2 = { version = "0.5", features = ["std"] } +bech32 = "0.9" chacha20poly1305 = "0.10" +clap = { version = "4", features = ["derive"] } rand = { version = "0.8", features = ["std_rng"] } base64 = "0.22" uuid = { version = "1", features = ["v4"] } @@ -28,3 +38,6 @@ thiserror = "1.0" [dev-dependencies] serde_json = "1.0" tempfile = "3" + +[target.'cfg(unix)'.dev-dependencies] +rexpect = "0.6" diff --git a/age-plugin-argon2-cli/src/commands/generate.rs b/age-plugin-argon2/src/bin/age-plugin-argon2/commands/generate.rs similarity index 100% rename from age-plugin-argon2-cli/src/commands/generate.rs rename to age-plugin-argon2/src/bin/age-plugin-argon2/commands/generate.rs diff --git a/age-plugin-argon2-cli/src/commands/list.rs b/age-plugin-argon2/src/bin/age-plugin-argon2/commands/list.rs similarity index 100% rename from age-plugin-argon2-cli/src/commands/list.rs rename to age-plugin-argon2/src/bin/age-plugin-argon2/commands/list.rs diff --git a/age-plugin-argon2-cli/src/commands/mod.rs b/age-plugin-argon2/src/bin/age-plugin-argon2/commands/mod.rs similarity index 100% rename from age-plugin-argon2-cli/src/commands/mod.rs rename to age-plugin-argon2/src/bin/age-plugin-argon2/commands/mod.rs diff --git a/age-plugin-argon2-cli/src/encoding.rs b/age-plugin-argon2/src/bin/age-plugin-argon2/encoding.rs similarity index 100% rename from age-plugin-argon2-cli/src/encoding.rs rename to age-plugin-argon2/src/bin/age-plugin-argon2/encoding.rs diff --git a/age-plugin-argon2-cli/src/main.rs b/age-plugin-argon2/src/bin/age-plugin-argon2/main.rs similarity index 100% rename from age-plugin-argon2-cli/src/main.rs rename to age-plugin-argon2/src/bin/age-plugin-argon2/main.rs diff --git a/age-plugin-argon2-cli/src/plugin.rs b/age-plugin-argon2/src/bin/age-plugin-argon2/plugin.rs similarity index 100% rename from age-plugin-argon2-cli/src/plugin.rs rename to age-plugin-argon2/src/bin/age-plugin-argon2/plugin.rs diff --git a/age-plugin-argon2-cli/tests/e2e.rs b/age-plugin-argon2/tests/e2e.rs similarity index 100% rename from age-plugin-argon2-cli/tests/e2e.rs rename to age-plugin-argon2/tests/e2e.rs diff --git a/age-plugin-argon2-cli/tests/integration.rs b/age-plugin-argon2/tests/integration.rs similarity index 100% rename from age-plugin-argon2-cli/tests/integration.rs rename to age-plugin-argon2/tests/integration.rs