From 5fad9f0ec68c7ac20afb47db18c130addbdb8bd4 Mon Sep 17 00:00:00 2001 From: Mitchell Berendhuysen <45570310+MitchellBerend@users.noreply.github.com> Date: Sat, 25 Oct 2025 18:02:04 +0200 Subject: [PATCH] chore(release): Add .deb auto completion script (#1353) Co-authored-by: GideonBear <87426140+GideonBear@users.noreply.github.com> --- .github/workflows/create_release_assets.yml | 49 +++++++++++++++++++++ Cargo.toml | 9 ++++ 2 files changed, 58 insertions(+) diff --git a/.github/workflows/create_release_assets.yml b/.github/workflows/create_release_assets.yml index aa1ad921..0931c6ef 100644 --- a/.github/workflows/create_release_assets.yml +++ b/.github/workflows/create_release_assets.yml @@ -65,6 +65,29 @@ jobs: - name: Run tests run: cargo test + # Used `https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml` + # as a reference. + - name: Build debug binary to create release assets + shell: bash + run: | + cargo build --all-features + bin="target/debug/topgrade" + echo "BIN=$bin" >> $GITHUB_ENV + + - name: Create deployment directory + shell: bash + run: | + dir=deployment/deb + mkdir -p "$dir" + echo "DEPLOY_DIR=$dir" >> $GITHUB_ENV + + - name: Generate shell completions + shell: bash + run: | + "$BIN" --gen-completion bash > "$DEPLOY_DIR/topgrade.bash" + "$BIN" --gen-completion fish > "$DEPLOY_DIR/topgrade.fish" + "$BIN" --gen-completion zsh > "$DEPLOY_DIR/_topgrade" + - name: Build in Release profile with all features enabled run: cargo build --release --all-features @@ -198,6 +221,32 @@ jobs: - name: Run tests run: cross test --target ${{matrix.target}} + # Used `https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml` + # as a reference. + - name: Build debug binary to create release assets + shell: bash + run: | + # This build is not using the target arch since this binary is only needed in CI. It needs + # to be the compiled for the runner since it has the run the binary to generate completion + # scripts. + cargo build --all-features + bin="target/debug/topgrade" + echo "BIN=$bin" >> $GITHUB_ENV + + - name: Create deployment directory + shell: bash + run: | + dir=deployment/deb + mkdir -p "$dir" + echo "DEPLOY_DIR=$dir" >> $GITHUB_ENV + + - name: Generate shell completions + shell: bash + run: | + "$BIN" --gen-completion bash > "$DEPLOY_DIR/topgrade.bash" + "$BIN" --gen-completion fish > "$DEPLOY_DIR/topgrade.fish" + "$BIN" --gen-completion zsh > "$DEPLOY_DIR/_topgrade" + - name: Build in Release profile with all features enabled run: cross build --release --all-features --target ${{matrix.target}} diff --git a/Cargo.toml b/Cargo.toml index 661ab9f0..bed5b1bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,6 +71,15 @@ extended-description = "Keeping your system up to date usually involves invoking section = "utils" priority = "optional" default-features = true +assets = [ + ["target/release/topgrade", "usr/bin/", "755"], + ["README.md", "usr/share/doc/topgrade/README.md", "644"], + # The man page is automatically generated by topgrade's build process in CI, so + # these files aren't actually committed. + ["deployment/deb/topgrade.bash", "usr/share/bash-completion/completions/topgrade", "644"], + ["deployment/deb/topgrade.fish", "usr/share/fish/vendor_completions.d/topgrade.fish", "644"], + ["deployment/deb/_topgrade", "usr/share/zsh/vendor-completions/", "644"], +] [target.'cfg(unix)'.dependencies] nix = { version = "~0.29", features = ["hostname", "signal", "user"] }