diff --git a/.changeset/quiet-plums-deliver.md b/.changeset/quiet-plums-deliver.md new file mode 100644 index 000000000..8f3b65804 --- /dev/null +++ b/.changeset/quiet-plums-deliver.md @@ -0,0 +1,7 @@ +--- +"fnm": patch +--- + +Add Debian packages for amd64 and arm64 + +`.deb` packages are now built for amd64 and arm64, wrapping the same statically linked musl binary already shipped in the `fnm-linux` / `fnm-arm64` zip assets. They're a convenience download — install with `sudo dpkg -i fnm_-1_.deb` — not a package submitted to Debian's official archive. Like every other release asset, they're produced as CI artifacts and attached to releases by hand. diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bff8a273e..3ec1594af 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -334,6 +334,64 @@ jobs: name: fnm-${{ matrix.arch }} path: target/${{ env.RUST_TARGET }}/release/fnm + build_deb: + name: "Build Debian packages" + runs-on: ubuntu-latest + needs: [build_static_linux_binary, build_static_arm_binary] + steps: + - uses: actions/checkout@v4 + - uses: hecrj/setup-rust-action@v2 + with: + rust-version: ${{env.RUST_VERSION}} + - uses: Swatinem/rust-cache@v2 + with: + key: deb-packages + - name: "Download `cargo-deb` crate" + run: cargo install cargo-deb@3.7.0 --locked + - uses: actions/download-artifact@v4 + with: + name: fnm-linux + path: target/x86_64-unknown-linux-musl/release + - uses: actions/download-artifact@v4 + with: + name: fnm-arm64 + path: target/aarch64-unknown-linux-musl/release + - name: mark binaries as executable + run: | + chmod +x target/x86_64-unknown-linux-musl/release/fnm + chmod +x target/aarch64-unknown-linux-musl/release/fnm + - name: Build Debian packages + run: | + cargo deb --target x86_64-unknown-linux-musl --no-build --no-strip + cargo deb --target aarch64-unknown-linux-musl --no-build --no-strip + - name: Sanity test amd64 package + run: | + set -- target/debian/fnm_*_amd64.deb + test "$#" -eq 1 + test -f "$1" + sudo dpkg -i "$1" + test "$(fnm --version)" = "fnm $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')" + - name: Verify arm64 package + run: | + set -- target/debian/fnm_*_arm64.deb + test "$#" -eq 1 + test -f "$1" + deb="$1" + test "$(dpkg-deb -f "$deb" Package)" = "fnm" + test "$(dpkg-deb -f "$deb" Architecture)" = "arm64" + dpkg-deb -c "$deb" | grep -q '^-rwxr-xr-x .*\./usr/bin/fnm$' + test "$(dpkg-deb -c "$deb" | grep -c './usr/bin/[^/]')" -eq 1 + dpkg-deb --fsys-tarfile "$deb" | tar -xO ./usr/bin/fnm > /tmp/fnm-arm64 + readelf -h /tmp/fnm-arm64 | grep -qi aarch64 + - uses: actions/upload-artifact@v4 + with: + name: fnm-deb-amd64 + path: target/debian/fnm_*_amd64.deb + - uses: actions/upload-artifact@v4 + with: + name: fnm-deb-arm64 + path: target/debian/fnm_*_arm64.deb + ensure_commands_markdown_is_up_to_date: runs-on: ubuntu-latest name: Ensure command docs are up-to-date diff --git a/Cargo.toml b/Cargo.toml index 6fd2ebd89..e324f99dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,17 @@ license = "GPL-3.0" repository = "https://github.com/Schniz/fnm" description = "Fast and simple Node.js version manager" +[package.metadata.deb] +maintainer = "Gal Schlezinger " +section = "utils" +depends = "" +license-file = ["LICENSE", "0"] +assets = [["target/release/fnm", "usr/bin/", "755"]] +extended-description = """\ +fnm is a fast and simple Node.js version manager. It works with .node-version +and .nvmrc files, and is enabled in your shell by evaluating the output of +`fnm env`. See https://github.com/Schniz/fnm for shell setup instructions.""" + [dependencies] serde = { version = "1.0.203", features = ["derive"] } clap = { version = "4.5.4", features = ["derive", "env"] }