Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for and consume the dist-manifest.json file #854

Open
passcod opened this issue Mar 2, 2023 · 7 comments · May be fixed by #1450
Open

Look for and consume the dist-manifest.json file #854

passcod opened this issue Mar 2, 2023 · 7 comments · May be fixed by #1450

Comments

@passcod
Copy link
Member

passcod commented Mar 2, 2023

We can use https://crates.io/crates/cargo-dist-schema to parse it.

Finding that file still requires us to autodiscover the tag, but if we do find it, we can have a much more efficient discovery.

@NobodyXu
Copy link
Member

NobodyXu commented Mar 3, 2023

This looks great and it could be used to reduce amount of urls created if GitHubApiClient is not usable.

@NobodyXu
Copy link
Member

NobodyXu commented Jun 18, 2023

Example of such dist-manifest.json from cargo-dist:

{
  "dist_version": "0.0.6-prerelease.8",
  "announcement_tag": "v0.0.7",
  "announcement_is_prerelease": false,
  "announcement_title": "Version 0.0.7 (2023-05-09)",
  "announcement_changelog": "This is just a quick little release that makes the npm package tarballs we can generate\nlook like \"properly\" packed tarballs that can be directly published to npm without unpacking them.\nThis allows you to `npm publish URL_TO_TARBALL` directly without any issues.\n\n@gankra [impl](https://github.com/axodotdev/cargo-dist/pull/246)",
  "announcement_github_body": "## Release Notes\n\nThis is just a quick little release that makes the npm package tarballs we can generate\nlook like \"properly\" packed tarballs that can be directly published to npm without unpacking them.\nThis allows you to `npm publish URL_TO_TARBALL` directly without any issues.\n\n@gankra [impl](https://github.com/axodotdev/cargo-dist/pull/246)\n\n## Install cargo-dist 0.0.7\n\n### Install prebuilt binaries via shell script\n\n```shell\ncurl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh\n```\n\n### Install prebuilt binaries via powershell script\n\n```shell\nirm https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.ps1 | iex\n```\n\n## Download cargo-dist 0.0.7\n\n| target | kind | download |\n|--------|------|----------|\n| aarch64-apple-darwin | tarball | [cargo-dist-aarch64-apple-darwin.tar.xz](https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-aarch64-apple-darwin.tar.xz) |\n| x86_64-apple-darwin | tarball | [cargo-dist-x86_64-apple-darwin.tar.xz](https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-x86_64-apple-darwin.tar.xz) |\n| x86_64-pc-windows-msvc | tarball | [cargo-dist-x86_64-pc-windows-msvc.zip](https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-x86_64-pc-windows-msvc.zip) |\n| x86_64-unknown-linux-gnu | tarball | [cargo-dist-x86_64-unknown-linux-gnu.tar.xz](https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-x86_64-unknown-linux-gnu.tar.xz) |\n\n",
  "releases": [
    {
      "app_name": "cargo-dist",
      "app_version": "0.0.7",
      "artifacts": [
        "cargo-dist-installer.sh",
        "cargo-dist-installer.ps1",
        "cargo-dist-aarch64-apple-darwin.tar.xz",
        "cargo-dist-x86_64-apple-darwin.tar.xz",
        "cargo-dist-x86_64-pc-windows-msvc.zip",
        "cargo-dist-x86_64-unknown-linux-gnu.tar.xz"
      ]
    }
  ],
  "artifacts": {
    "cargo-dist-aarch64-apple-darwin.tar.xz": {
      "name": "cargo-dist-aarch64-apple-darwin.tar.xz",
      "kind": "executable-zip",
      "target_triples": [
        "aarch64-apple-darwin"
      ],
      "assets": [
        {
          "name": "CHANGELOG.md",
          "path": "CHANGELOG.md",
          "kind": "changelog"
        },
        {
          "name": "LICENSE-APACHE",
          "path": "LICENSE-APACHE",
          "kind": "license"
        },
        {
          "name": "LICENSE-MIT",
          "path": "LICENSE-MIT",
          "kind": "license"
        },
        {
          "name": "README.md",
          "path": "README.md",
          "kind": "readme"
        },
        {
          "name": "cargo-dist",
          "path": "cargo-dist",
          "kind": "executable"
        }
      ]
    },
    "cargo-dist-installer.ps1": {
      "name": "cargo-dist-installer.ps1",
      "kind": "installer",
      "target_triples": [
        "x86_64-pc-windows-msvc"
      ],
      "install_hint": "irm https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.ps1 | iex",
      "description": "Install prebuilt binaries via powershell script"
    },
    "cargo-dist-installer.sh": {
      "name": "cargo-dist-installer.sh",
      "kind": "installer",
      "target_triples": [
        "aarch64-apple-darwin",
        "x86_64-apple-darwin",
        "x86_64-unknown-linux-gnu"
      ],
      "install_hint": "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh",
      "description": "Install prebuilt binaries via shell script"
    },
    "cargo-dist-x86_64-apple-darwin.tar.xz": {
      "name": "cargo-dist-x86_64-apple-darwin.tar.xz",
      "kind": "executable-zip",
      "target_triples": [
        "x86_64-apple-darwin"
      ],
      "assets": [
        {
          "name": "CHANGELOG.md",
          "path": "CHANGELOG.md",
          "kind": "changelog"
        },
        {
          "name": "LICENSE-APACHE",
          "path": "LICENSE-APACHE",
          "kind": "license"
        },
        {
          "name": "LICENSE-MIT",
          "path": "LICENSE-MIT",
          "kind": "license"
        },
        {
          "name": "README.md",
          "path": "README.md",
          "kind": "readme"
        },
        {
          "name": "cargo-dist",
          "path": "cargo-dist",
          "kind": "executable"
        }
      ]
    },
    "cargo-dist-x86_64-pc-windows-msvc.zip": {
      "name": "cargo-dist-x86_64-pc-windows-msvc.zip",
      "kind": "executable-zip",
      "target_triples": [
        "x86_64-pc-windows-msvc"
      ],
      "assets": [
        {
          "name": "CHANGELOG.md",
          "path": "CHANGELOG.md",
          "kind": "changelog"
        },
        {
          "name": "LICENSE-APACHE",
          "path": "LICENSE-APACHE",
          "kind": "license"
        },
        {
          "name": "LICENSE-MIT",
          "path": "LICENSE-MIT",
          "kind": "license"
        },
        {
          "name": "README.md",
          "path": "README.md",
          "kind": "readme"
        },
        {
          "name": "cargo-dist",
          "path": "cargo-dist.exe",
          "kind": "executable"
        }
      ]
    },
    "cargo-dist-x86_64-unknown-linux-gnu.tar.xz": {
      "name": "cargo-dist-x86_64-unknown-linux-gnu.tar.xz",
      "kind": "executable-zip",
      "target_triples": [
        "x86_64-unknown-linux-gnu"
      ],
      "assets": [
        {
          "name": "CHANGELOG.md",
          "path": "CHANGELOG.md",
          "kind": "changelog"
        },
        {
          "name": "LICENSE-APACHE",
          "path": "LICENSE-APACHE",
          "kind": "license"
        },
        {
          "name": "LICENSE-MIT",
          "path": "LICENSE-MIT",
          "kind": "license"
        },
        {
          "name": "README.md",
          "path": "README.md",
          "kind": "readme"
        },
        {
          "name": "cargo-dist",
          "path": "cargo-dist",
          "kind": "executable"
        }
      ]
    }
  }
}

@NobodyXu
Copy link
Member

From the dist-manifest.json, we only need to extract the following sections:

{
  "releases": [
    {
      "app_name": "cargo-dist",
      "app_version": "0.0.7",
      "artifacts": [
        "cargo-dist-installer.sh",
        "cargo-dist-installer.ps1",
        "cargo-dist-aarch64-apple-darwin.tar.xz",
        "cargo-dist-x86_64-apple-darwin.tar.xz",
        "cargo-dist-x86_64-pc-windows-msvc.zip",
        "cargo-dist-x86_64-unknown-linux-gnu.tar.xz"
      ]
    }
  ],
}

basically just:

#[derive(Debug, Deserialize)]
struct DistManifest {
    releases: Vec<DistManifestRelease>,
}

#[derive(Debug, Deserialize)]
struct DistManifestRelease {
    app_name: CompactString,
    app_version: CompactString,
    artifacts: Vec<CompactString>,
}

@passcod
Copy link
Member Author

passcod commented Jun 19, 2023

Sure, but to ensure compatibility, we can use the parsing crate that cargo dist makes available instead of defining the structs ourselves.

@NobodyXu
Copy link
Member

NobodyXu commented Sep 23, 2023

I look at what dist-manifest.json and cargo-dist is capable of, I think we should create a separate fetcher for it.

dist-manifest.json is not just an optimization for speeding up resolution, but it provides a different way to organize the release artifacts, they can be put in separate achieves instead of one for all.

@andrewdavidmackenzie
Copy link

In the PR you submitted for me (thanks), you say "dist-manifest.json is deprecated."

Is this proposed path for this issue (use dist-manifest.json) still valid?

@passcod
Copy link
Member Author

passcod commented Sep 26, 2023

its dist-manifest.json is deprecated.

The manifest format of the crate version you were using, specifically. dist-manifest.json in general (the latest version) is still good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants