Skip to content

Commit

Permalink
chore: Preparing to use 'dist' for more releases.
Browse files Browse the repository at this point in the history
This relies on the upgrade to the latest version of 'dist'. Since
we now have plugins that we want to produce pre-built binaries for,
this updates our build configuration to support that. It'll need to
be tested.

Signed-off-by: Andrew Lilley Brinker <[email protected]>
  • Loading branch information
alilleybrinker committed Dec 4, 2024
1 parent 5de533f commit 764b5e1
Show file tree
Hide file tree
Showing 60 changed files with 589 additions and 159 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/release-dry-run.yml

This file was deleted.

14 changes: 11 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
# we specify bash to get pipefail; it guards against the `curl` command
# failing. otherwise `sh` won't catch that `curl` returned non-0
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.25.1/cargo-dist-installer.sh | sh"
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.26.0-prerelease.3/cargo-dist-installer.sh | sh"
- name: Cache dist
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -107,6 +107,7 @@ jobs:
# - N "local" tasks that build each platform's binaries and platform-specific installers
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
runs-on: ${{ matrix.runner }}
container: ${{ matrix.container && matrix.container.image || null }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
Expand All @@ -117,8 +118,15 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust non-interactively if not already installed
if: ${{ matrix.container }}
run: |
if ! command -v cargo > /dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
fi
- name: Install dist
run: ${{ matrix.install_dist }}
run: ${{ matrix.install_dist.run }}
# Get the dist-manifest
- name: Fetch local artifacts
uses: actions/download-artifact@v4
Expand All @@ -143,7 +151,7 @@ jobs:
run: |
# Parse out what we just built and upload it to scratch storage
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
Expand Down
38 changes: 4 additions & 34 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,52 +31,22 @@ members = [
"plugins/identity",
"plugins/linguist",
"plugins/review",
"plugins/typo"]
"plugins/typo",
]

# Make sure Hipcheck is run with `cargo run`.
#
# This means to use `xtask` with `cargo run` you need to specify the package.
# See `.cargo/config.toml` for how this is done.
default-members = ["hipcheck"]

# Config for 'dist'
[workspace.metadata.dist]
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.25.1"
# CI backends to support
ci = "github"
# The installers to generate for each app
installers = ["shell", "powershell"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
# Which actions to run on pull requests
pr-run-mode = "plan"
# Whether to install an updater program
install-updater = true
# Extra static files to include in each App (path relative to this Cargo.toml's dir)
include = ["config/"]
# Path that installers should place binaries in
install-path = "CARGO_HOME"

# Ubuntu build dependencies for `cargo-dist`
[workspace.metadata.dist.dependencies.apt]
protobuf-compiler = "*"

# macOS build dependencies for 'cargo-dist'
[workspace.metadata.dist.dependencies.homebrew]
protobuf = "*"

# Windows build dependencies for `cargo-dist`
[workspace.metadata.dist.dependencies.chocolatey]
protoc = "*"

# The profile that 'cargo dist' will build with
[profile.dist]

#
# For now this is just the release profile, but with "thin" Link-Time
# Optimization enabled. This performs _some_ LTO and tries to hit the
# right trade-off between the runtime performance improvements of more
# LTO and the compile time cost of doing LTO.
[profile.dist]
inherits = "release"
lto = "thin"

Expand Down
24 changes: 24 additions & 0 deletions dist-workspace.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[workspace]

# All the packages which 'cargo-dist' is responsible for.
# This is _only_ the binary packages in the overall project, so it excludes
# libraries including any SDKs and our supporting libraries.
members = ["cargo:."]

# Config for 'dist'
[dist]
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.26.0-prerelease.3"
# CI backends to support
ci = "github"
# Which actions to run on pull requests
pr-run-mode = "plan"
# Path that installers should place binaries in
install-path = ["~/.local/bin", "~/.hipcheck/bin"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = [
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc",
]
5 changes: 0 additions & 5 deletions hipcheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,3 @@ which = { version = "7.0.0", default-features = false }

dirs = "5.0.1"
test-log = "0.2.16"

[package.metadata.dist]

# Make sure that `cargo-dist` can find this binary.
dist = true
27 changes: 27 additions & 0 deletions hipcheck/dist.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

[dist]

# Make sure that 'dist' will handle releases for this. Otherwise, since
# the crate is set to 'publish = false', 'dist' would ignore it by default.
dist = true

# The installers to generate for each app
installers = ["shell", "powershell"]

# Whether to install an updater program
install-updater = true

# Make sure to include the configuration.
include = ["../config/"]

# Make sure that both Hipcheck and all the plugins are built with the protobuf
# compiler present on their platform.

[dist.dependencies.apt]
protobuf-compiler = "*"

[dist.dependencies.homebrew]
protobuf = "*"

[dist.dependencies.chocolatey]
protoc = "*"
1 change: 1 addition & 0 deletions plugins/activity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "activity"
version = "0.1.0"
license = "Apache-2.0"
edition = "2021"
repository = "https://github.com/mitre/hipcheck"
publish = false

[dependencies]
Expand Down
17 changes: 17 additions & 0 deletions plugins/activity/dist.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

[dist]

# Make sure that 'dist' will handle releases for this. Otherwise, since
# the crate is set to 'publish = false', 'dist' would ignore it by default.
dist = true

# We explicitly *don't* want 'dist' to produce installers; just to prebuild
# the binaries for us and bundle everything together. Hipcheck itself will
# handle people getting the prebuilt binaries based on the download manifest.
installers = []

# Do not install an updater.
install-updater = false

# Make sure to include the plugin manifest.
include = ["plugin.kdl"]
15 changes: 15 additions & 0 deletions plugins/activity/local-plugin.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
publisher "mitre"
name "activity"
version "0.1.0"
license "Apache-2.0"

entrypoint {
on arch="aarch64-apple-darwin" "./target/debug/activity"
on arch="x86_64-apple-darwin" "./target/debug/activity"
on arch="x86_64-unknown-linux-gnu" "./target/debug/activity"
on arch="x86_64-pc-windows-msvc" "./target/debug/activity.exe"
}

dependencies {
plugin "mitre/git" version="0.1.0" manifest="./plugins/git/local-plugin.kdl"
}
12 changes: 7 additions & 5 deletions plugins/activity/plugin.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ publisher "mitre"
name "activity"
version "0.1.0"
license "Apache-2.0"

entrypoint {
on arch="aarch64-apple-darwin" "./target/debug/activity"
on arch="x86_64-apple-darwin" "./target/debug/activity"
on arch="x86_64-unknown-linux-gnu" "./target/debug/activity"
on arch="x86_64-pc-windows-msvc" "./target/debug/activity.exe"
on arch="aarch64-apple-darwin" "activity"
on arch="x86_64-apple-darwin" "activity"
on arch="x86_64-unknown-linux-gnu" "activity"
on arch="x86_64-pc-windows-msvc" "activity.exe"
}

dependencies {
plugin "mitre/git" version="0.1.0" manifest="./plugins/git/plugin.kdl"
plugin "mitre/git" version="0.1.0" manifest="https://hipcheck.mitre.org/dl/plugin/mitre/git.kdl"
}
5 changes: 3 additions & 2 deletions plugins/affiliation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ name = "affiliation"
version = "0.1.0"
license = "Apache-2.0"
edition = "2021"
repository = "https://github.com/mitre/hipcheck"
publish = false

[dependencies]
anyhow = "1.0.91"
clap = { version = "4.5.21", features = ["derive"] }
hipcheck-sdk = { path = "../../sdk/rust", features = ["macros"]}
hipcheck-sdk = { path = "../../sdk/rust", features = ["macros"] }
kdl = "4.6.0"
log = "0.4.22"
pathbuf = "1.0.0"
Expand All @@ -19,4 +20,4 @@ strum = { version = "0.26.3", features = ["derive"] }
tokio = { version = "1.41.1", features = ["rt"] }

[dev-dependencies]
hipcheck-sdk = { path = "../../sdk/rust", features = ["macros", "mock_engine"]}
hipcheck-sdk = { path = "../../sdk/rust", features = ["macros", "mock_engine"] }
17 changes: 17 additions & 0 deletions plugins/affiliation/dist.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

[dist]

# Make sure that 'dist' will handle releases for this. Otherwise, since
# the crate is set to 'publish = false', 'dist' would ignore it by default.
dist = true

# We explicitly *don't* want 'dist' to produce installers; just to prebuild
# the binaries for us and bundle everything together. Hipcheck itself will
# handle people getting the prebuilt binaries based on the download manifest.
installers = []

# Do not install an updater.
install-updater = false

# Make sure to include the plugin manifest.
include = ["plugin.kdl"]
15 changes: 15 additions & 0 deletions plugins/affiliation/local-plugin.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
publisher "mitre"
name "affiliation"
version "0.1.0"
license "Apache-2.0"

entrypoint {
on arch="aarch64-apple-darwin" "./target/debug/affiliation"
on arch="x86_64-apple-darwin" "./target/debug/affiliation"
on arch="x86_64-unknown-linux-gnu" "./target/debug/affiliation"
on arch="x86_64-pc-windows-msvc" "./target/debug/affiliation.exe"
}

dependencies {
plugin "mitre/git" version="0.1.0" manifest="./plugins/git/local-plugin.kdl"
}
11 changes: 6 additions & 5 deletions plugins/affiliation/plugin.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ publisher "mitre"
name "affiliation"
version "0.1.0"
license "Apache-2.0"

entrypoint {
on arch="aarch64-apple-darwin" "./target/debug/affiliation"
on arch="x86_64-apple-darwin" "./target/debug/affiliation"
on arch="x86_64-unknown-linux-gnu" "./target/debug/affiliation"
on arch="x86_64-pc-windows-msvc" "./target/debug/affiliation.exe"
on arch="aarch64-apple-darwin" "affiliation"
on arch="x86_64-apple-darwin" "affiliation"
on arch="x86_64-unknown-linux-gnu" "affiliation"
on arch="x86_64-pc-windows-msvc" "affiliation.exe"
}

dependencies {
plugin "mitre/git" version="0.1.0" manifest="./plugins/git/plugin.kdl"
plugin "mitre/git" version="0.1.0" manifest="https://hipcheck.mitre.org/dl/plugin/mitre/git.kdl"
}
5 changes: 4 additions & 1 deletion plugins/binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ name = "binary"
version = "0.1.0"
license = "Apache-2.0"
edition = "2021"
repository = "https://github.com/mitre/hipcheck"
publish = false

[dependencies]
clap = { version = "4.5.21", features = ["derive"] }
content_inspector = "0.2.4"
hipcheck-sdk = { version = "0.1.0", path = "../../sdk/rust", features = ["macros"] }
hipcheck-sdk = { version = "0.1.0", path = "../../sdk/rust", features = [
"macros",
] }
log = "0.4.22"
pathbuf = "1.0.0"
schemars = "0.8.21"
Expand Down
17 changes: 17 additions & 0 deletions plugins/binary/dist.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

[dist]

# Make sure that 'dist' will handle releases for this. Otherwise, since
# the crate is set to 'publish = false', 'dist' would ignore it by default.
dist = true

# We explicitly *don't* want 'dist' to produce installers; just to prebuild
# the binaries for us and bundle everything together. Hipcheck itself will
# handle people getting the prebuilt binaries based on the download manifest.
installers = []

# Do not install an updater.
install-updater = false

# Make sure to include the plugin manifest.
include = ["plugin.kdl"]
11 changes: 11 additions & 0 deletions plugins/binary/local-plugin.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
publisher "mitre"
name "binary"
version "0.1.0"
license "Apache-2.0"

entrypoint {
on arch="aarch64-apple-darwin" "./target/debug/binary"
on arch="x86_64-apple-darwin" "./target/debug/binary"
on arch="x86_64-unknown-linux-gnu" "./target/debug/binary"
on arch="x86_64-pc-windows-msvc" "./target/debug/binary.exe"
}
Loading

0 comments on commit 764b5e1

Please sign in to comment.