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

dist build --artifacts=global generate homebrew formula without sha256 checksum #1672

Open
j178 opened this issue Jan 6, 2025 · 1 comment

Comments

@j178
Copy link

j178 commented Jan 6, 2025

Version

cargo-dist v0.27.0

Description

Hi, I’m experiencing an issue with my GitHub Action in the build-global-artifacts step. This step uses the command dist build --tag=v0.0.8 --output-format=json --artifacts=global to generate a Homebrew formula, but it’s missing the sha256 checksum.

When I run dist build in other artifact modes, the formula is generated correctly.

Steps to reproduce

git clone [email protected]:j178/prefligit.git
dist build --tag=v0.0.8 --output-format=json --artifacts=global
dist build --tag=v0.0.8 --output-format=json --artifacts=global -v trace
dist build trace log
 INFO analyzing workspace:
 INFO exec "cargo" "-vV"
 INFO host target is aarch64-apple-darwin
 INFO exec "rustup" "-V"
 INFO exec "brew" "--version"
 INFO exec "git" "--version"
 INFO exec "omnibor" "--version"
 INFO exec "cargo" "auditable" "--version"
 INFO exec "cargo" "cyclonedx" "--version"
 INFO exec "cargo" "xwin" "--version"
 INFO exec "cargo-zigbuild" "--version"
 INFO exec cd "/Users/Jo/code/rust/prefligit" && "git" "rev-parse" "--show-toplevel"
 INFO exec cd "/Users/Jo/code/rust/prefligit" && "git" "rev-parse" "HEAD"
 INFO Found LICENSE at /Users/Jo/code/rust/prefligit/LICENSE
 INFO Found CHANGELOG at /Users/Jo/code/rust/prefligit/CHANGELOG.md
 INFO Found README at /Users/Jo/code/rust/prefligit/README.md
 INFO Found LICENSE at /Users/Jo/code/rust/prefligit/LICENSE
 INFO Found CHANGELOG at /Users/Jo/code/rust/prefligit/CHANGELOG.md
 INFO Found README at /Users/Jo/code/rust/prefligit/README.md
 INFO Found LICENSE at /Users/Jo/code/rust/prefligit/LICENSE
 INFO Found CHANGELOG at /Users/Jo/code/rust/prefligit/CHANGELOG.md
 INFO Found README at /Users/Jo/code/rust/prefligit/README.md
 INFO force-enabling precise-builds to handle your build features
 INFO exec "sw_vers" "-productVersion"
 INFO using all target-triples
 INFO selected triples: ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"]
 INFO 
 INFO selecting packages from workspace: 
 INFO   prefligit
 INFO     [bin] prefligit
 INFO 
 WARN found old manifest for the tag Some("v0.0.7"), ignoring it
 INFO added release prefligit
 INFO added variant prefligit-aarch64-apple-darwin
 INFO added binary prefligit-aarch64-apple-darwin-exe-prefligit
 INFO added variant prefligit-x86_64-apple-darwin
 INFO added binary prefligit-x86_64-apple-darwin-exe-prefligit
 INFO added variant prefligit-x86_64-pc-windows-msvc
 INFO added binary prefligit-x86_64-pc-windows-msvc-exe-prefligit
 INFO added variant prefligit-x86_64-unknown-linux-gnu
 INFO added binary prefligit-x86_64-unknown-linux-gnu-exe-prefligit
 INFO adding source tarball to release prefligit
 INFO successfully parsed changelog!
 INFO successfully generated github release body!
 INFO analyzing workspace:
 INFO exec "cargo" "-vV"
 INFO host target is aarch64-apple-darwin
 INFO exec "rustup" "-V"
 INFO exec "brew" "--version"
 INFO exec "git" "--version"
 INFO exec "omnibor" "--version"
 INFO exec "cargo" "auditable" "--version"
 INFO exec "cargo" "cyclonedx" "--version"
 INFO exec "cargo" "xwin" "--version"
 INFO exec "cargo-zigbuild" "--version"
 INFO exec cd "/Users/Jo/code/rust/prefligit" && "git" "rev-parse" "--show-toplevel"
 INFO exec cd "/Users/Jo/code/rust/prefligit" && "git" "rev-parse" "HEAD"
 INFO Found LICENSE at /Users/Jo/code/rust/prefligit/LICENSE
 INFO Found CHANGELOG at /Users/Jo/code/rust/prefligit/CHANGELOG.md
 INFO Found README at /Users/Jo/code/rust/prefligit/README.md
 INFO Found LICENSE at /Users/Jo/code/rust/prefligit/LICENSE
 INFO Found CHANGELOG at /Users/Jo/code/rust/prefligit/CHANGELOG.md
 INFO Found README at /Users/Jo/code/rust/prefligit/README.md
 INFO Found LICENSE at /Users/Jo/code/rust/prefligit/LICENSE
 INFO Found CHANGELOG at /Users/Jo/code/rust/prefligit/CHANGELOG.md
 INFO Found README at /Users/Jo/code/rust/prefligit/README.md
 INFO force-enabling precise-builds to handle your build features
 INFO exec "sw_vers" "-productVersion"
 INFO using all target-triples
 INFO selected triples: ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"]
 INFO 
 INFO selecting packages from workspace: 
 INFO   prefligit
 INFO     [bin] prefligit
 INFO 
 WARN found old manifest for the tag Some("v0.0.7"), ignoring it
 INFO added release prefligit
 INFO added variant prefligit-aarch64-apple-darwin
 INFO added binary prefligit-aarch64-apple-darwin-exe-prefligit
 INFO added variant prefligit-x86_64-apple-darwin
 INFO added binary prefligit-x86_64-apple-darwin-exe-prefligit
 INFO added variant prefligit-x86_64-pc-windows-msvc
 INFO added binary prefligit-x86_64-pc-windows-msvc-exe-prefligit
 INFO added variant prefligit-x86_64-unknown-linux-gnu
 INFO added binary prefligit-x86_64-unknown-linux-gnu-exe-prefligit
 INFO adding executable zip to release prefligit
 INFO adding source tarball to release prefligit
 INFO successfully parsed changelog!
 INFO successfully generated github release body!
 INFO analyzing workspace:
 INFO exec "cargo" "-vV"
 INFO host target is aarch64-apple-darwin
 INFO exec "rustup" "-V"
 INFO exec "brew" "--version"
 INFO exec "git" "--version"
 INFO exec "omnibor" "--version"
 INFO exec "cargo" "auditable" "--version"
 INFO exec "cargo" "cyclonedx" "--version"
 INFO exec "cargo" "xwin" "--version"
 INFO exec "cargo-zigbuild" "--version"
 INFO exec cd "/Users/Jo/code/rust/prefligit" && "git" "rev-parse" "--show-toplevel"
 INFO exec cd "/Users/Jo/code/rust/prefligit" && "git" "rev-parse" "HEAD"
 INFO Found LICENSE at /Users/Jo/code/rust/prefligit/LICENSE
 INFO Found CHANGELOG at /Users/Jo/code/rust/prefligit/CHANGELOG.md
 INFO Found README at /Users/Jo/code/rust/prefligit/README.md
 INFO Found LICENSE at /Users/Jo/code/rust/prefligit/LICENSE
 INFO Found CHANGELOG at /Users/Jo/code/rust/prefligit/CHANGELOG.md
 INFO Found README at /Users/Jo/code/rust/prefligit/README.md
 INFO Found LICENSE at /Users/Jo/code/rust/prefligit/LICENSE
 INFO Found CHANGELOG at /Users/Jo/code/rust/prefligit/CHANGELOG.md
 INFO Found README at /Users/Jo/code/rust/prefligit/README.md
 INFO force-enabling precise-builds to handle your build features
 INFO exec "sw_vers" "-productVersion"
 INFO using all target-triples
 INFO selected triples: ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"]
 INFO 
 INFO selecting packages from workspace: 
 INFO   prefligit
 INFO     [bin] prefligit
 INFO 
 WARN found old manifest for the tag Some("v0.0.7"), ignoring it
 INFO added release prefligit
 INFO added variant prefligit-aarch64-apple-darwin
 INFO added binary prefligit-aarch64-apple-darwin-exe-prefligit
 INFO added variant prefligit-x86_64-apple-darwin
 INFO added binary prefligit-x86_64-apple-darwin-exe-prefligit
 INFO added variant prefligit-x86_64-pc-windows-msvc
 INFO added binary prefligit-x86_64-pc-windows-msvc-exe-prefligit
 INFO added variant prefligit-x86_64-unknown-linux-gnu
 INFO added binary prefligit-x86_64-unknown-linux-gnu-exe-prefligit
 INFO adding source tarball to release prefligit
 INFO successfully parsed changelog!
 INFO successfully generated github release body!
building artifacts:
  source.tar.gz
  source.tar.gz.sha256
  prefligit-installer.sh
  prefligit-installer.ps1
  prefligit.rb
  sha256.sum

 INFO exec cd "/Users/Jo/code/rust/prefligit" && "git" "archive" "HEAD" "--format=tar.gz" "--prefix" "prefligit-0.0.8/" "--output" "/Users/Jo/code/rust/prefligit/target/distrib/source.tar.gz"
 INFO generating Sha256 for /Users/Jo/code/rust/prefligit/target/distrib/source.tar.gz
{
  "dist_version": "0.27.0",
  "announcement_tag": "v0.0.8",
  "announcement_tag_is_implicit": false,
  "announcement_is_prerelease": false,
  "announcement_title": "0.0.8",
  "announcement_changelog": "### Enhancements\n\n- Move home dir to `~/.cache/prefligit` ([#154](https://github.com/j178/prefligit/pull/154))\n- Implement trailing-whitespace in Rust ([#137](https://github.com/j178/prefligit/pull/137))\n- Limit hook install concurrency ([#145](https://github.com/j178/prefligit/pull/145))\n- Simplify language default version implementation ([#150](https://github.com/j178/prefligit/pull/150))\n- Support install uv from pypi ([#149](https://github.com/j178/prefligit/pull/149))\n- Add executing command to error message ([#141](https://github.com/j178/prefligit/pull/141))\n\n### Bug fixes\n\n- Use hook `args` in fast path ([#139](https://github.com/j178/prefligit/pull/139))\n\n### Other changes\n\n- Remove hook install_key ([#153](https://github.com/j178/prefligit/pull/153))\n- Remove pyvenv.cfg patch ([#156](https://github.com/j178/prefligit/pull/156))\n- Try to use D drive on Windows CI ([#157](https://github.com/j178/prefligit/pull/157))\n- Tweak trailing-whitespace-fixer ([#140](https://github.com/j178/prefligit/pull/140))\n- Upgrade dist to v0.27.0 ([#158](https://github.com/j178/prefligit/pull/158))\n- Uv install python into tools path ([#151](https://github.com/j178/prefligit/pull/151))",
  "announcement_github_body": "## Release Notes\n\n### Enhancements\n\n- Move home dir to `~/.cache/prefligit` ([#154](https://github.com/j178/prefligit/pull/154))\n- Implement trailing-whitespace in Rust ([#137](https://github.com/j178/prefligit/pull/137))\n- Limit hook install concurrency ([#145](https://github.com/j178/prefligit/pull/145))\n- Simplify language default version implementation ([#150](https://github.com/j178/prefligit/pull/150))\n- Support install uv from pypi ([#149](https://github.com/j178/prefligit/pull/149))\n- Add executing command to error message ([#141](https://github.com/j178/prefligit/pull/141))\n\n### Bug fixes\n\n- Use hook `args` in fast path ([#139](https://github.com/j178/prefligit/pull/139))\n\n### Other changes\n\n- Remove hook install_key ([#153](https://github.com/j178/prefligit/pull/153))\n- Remove pyvenv.cfg patch ([#156](https://github.com/j178/prefligit/pull/156))\n- Try to use D drive on Windows CI ([#157](https://github.com/j178/prefligit/pull/157))\n- Tweak trailing-whitespace-fixer ([#140](https://github.com/j178/prefligit/pull/140))\n- Upgrade dist to v0.27.0 ([#158](https://github.com/j178/prefligit/pull/158))\n- Uv install python into tools path ([#151](https://github.com/j178/prefligit/pull/151))\n\n## Install prefligit 0.0.8\n\n### Install prebuilt binaries via shell script\n\n```sh\ncurl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prefligit/releases/download/v0.0.8/prefligit-installer.sh | sh\n```\n\n### Install prebuilt binaries via powershell script\n\n```sh\npowershell -ExecutionPolicy ByPass -c \"irm https://github.com/j178/prefligit/releases/download/v0.0.8/prefligit-installer.ps1 | iex\"\n```\n\n### Install prebuilt binaries via Homebrew\n\n```sh\nbrew install j178/tap/prefligit\n```\n\n",
  "releases": [
    {
      "app_name": "prefligit",
      "app_version": "0.0.8",
      "env": {
        "install_dir_env_var": "PREFLIGIT_INSTALL_DIR",
        "unmanaged_dir_env_var": "PREFLIGIT_UNMANAGED_INSTALL",
        "disable_update_env_var": "PREFLIGIT_DISABLE_UPDATE",
        "no_modify_path_env_var": "PREFLIGIT_NO_MODIFY_PATH",
        "github_base_url_env_var": "PREFLIGIT_INSTALLER_GITHUB_BASE_URL",
        "ghe_base_url_env_var": "PREFLIGIT_INSTALLER_GHE_BASE_URL"
      },
      "display_name": "prefligit",
      "display": true,
      "artifacts": [
        "source.tar.gz",
        "source.tar.gz.sha256",
        "prefligit-installer.sh",
        "prefligit-installer.ps1",
        "prefligit.rb",
        "sha256.sum"
      ],
      "hosting": {
        "github": {
          "artifact_base_url": "https://github.com",
          "artifact_download_path": "/j178/prefligit/releases/download/v0.0.8",
          "owner": "j178",
          "repo": "prefligit"
        }
      }
    }
  ],
  "artifacts": {
    "prefligit-installer.ps1": {
      "name": "prefligit-installer.ps1",
      "kind": "installer",
      "target_triples": [
        "aarch64-pc-windows-msvc",
        "x86_64-pc-windows-gnu",
        "x86_64-pc-windows-msvc"
      ],
      "path": "/Users/Jo/code/rust/prefligit/target/distrib/prefligit-installer.ps1",
      "install_hint": "powershell -ExecutionPolicy ByPass -c \"irm https://github.com/j178/prefligit/releases/download/v0.0.8/prefligit-installer.ps1 | iex\"",
      "description": "Install prebuilt binaries via powershell script"
    },
    "prefligit-installer.sh": {
      "name": "prefligit-installer.sh",
      "kind": "installer",
      "target_triples": [
        "aarch64-apple-darwin",
        "x86_64-apple-darwin",
        "x86_64-pc-windows-gnu",
        "x86_64-unknown-linux-gnu"
      ],
      "path": "/Users/Jo/code/rust/prefligit/target/distrib/prefligit-installer.sh",
      "install_hint": "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prefligit/releases/download/v0.0.8/prefligit-installer.sh | sh",
      "description": "Install prebuilt binaries via shell script"
    },
    "prefligit.rb": {
      "name": "prefligit.rb",
      "kind": "installer",
      "target_triples": [
        "aarch64-apple-darwin",
        "x86_64-apple-darwin",
        "x86_64-pc-windows-gnu",
        "x86_64-unknown-linux-gnu"
      ],
      "path": "/Users/Jo/code/rust/prefligit/target/distrib/prefligit.rb",
      "install_hint": "brew install j178/tap/prefligit",
      "description": "Install prebuilt binaries via Homebrew"
    },
    "sha256.sum": {
      "name": "sha256.sum",
      "kind": "unified-checksum",
      "path": "/Users/Jo/code/rust/prefligit/target/distrib/sha256.sum"
    },
    "source.tar.gz": {
      "name": "source.tar.gz",
      "kind": "source-tarball",
      "path": "/Users/Jo/code/rust/prefligit/target/distrib/source.tar.gz",
      "checksum": "source.tar.gz.sha256",
      "checksums": {
        "sha256": "602928716904f379e89bcfed80f5ac5e47e0a2117994498adcab2325888e05d6"
      }
    },
    "source.tar.gz.sha256": {
      "name": "source.tar.gz.sha256",
      "kind": "checksum",
      "path": "/Users/Jo/code/rust/prefligit/target/distrib/source.tar.gz.sha256"
    }
  },
  "systems": {
    "build:global:": {
      "id": "build:global:",
      "cargo_version_line": "cargo 1.83.0 (5ffbef321 2024-10-29)",
      "build_environment": {
        "macos": {
          "os_version": "14.7.1"
        }
      }
    }
  },
  "publish_prereleases": false,
  "force_latest": false,
  "ci": {
    "github": {
      "artifacts_matrix": {
        "include": [
          {
            "runner": "macos-13",
            "host": "x86_64-apple-darwin",
            "install_dist": {
              "shell": "sh",
              "run": "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.27.0/cargo-dist-installer.sh | sh"
            },
            "dist_args": "--artifacts=local --target=aarch64-apple-darwin",
            "targets": [
              "aarch64-apple-darwin"
            ],
            "cache_provider": "github"
          },
          {
            "runner": "macos-13",
            "host": "x86_64-apple-darwin",
            "install_dist": {
              "shell": "sh",
              "run": "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.27.0/cargo-dist-installer.sh | sh"
            },
            "dist_args": "--artifacts=local --target=x86_64-apple-darwin",
            "targets": [
              "x86_64-apple-darwin"
            ],
            "cache_provider": "github"
          },
          {
            "runner": "windows-2019",
            "host": "x86_64-pc-windows-msvc",
            "install_dist": {
              "shell": "pwsh",
              "run": "irm https://github.com/axodotdev/cargo-dist/releases/download/v0.27.0/cargo-dist-installer.ps1 | iex"
            },
            "dist_args": "--artifacts=local --target=x86_64-pc-windows-msvc",
            "targets": [
              "x86_64-pc-windows-msvc"
            ],
            "cache_provider": "github"
          },
          {
            "runner": "ubuntu-20.04",
            "host": "x86_64-unknown-linux-gnu",
            "install_dist": {
              "shell": "sh",
              "run": "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.27.0/cargo-dist-installer.sh | sh"
            },
            "dist_args": "--artifacts=local --target=x86_64-unknown-linux-gnu",
            "targets": [
              "x86_64-unknown-linux-gnu"
            ],
            "cache_provider": "github"
          }
        ]
      },
      "pr_run_mode": "plan"
    }
  },
  "linkage": [],
  "upload_files": [
    "/Users/Jo/code/rust/prefligit/target/distrib/source.tar.gz",
    "/Users/Jo/code/rust/prefligit/target/distrib/source.tar.gz.sha256",
    "/Users/Jo/code/rust/prefligit/target/distrib/prefligit-installer.sh",
    "/Users/Jo/code/rust/prefligit/target/distrib/prefligit-installer.ps1",
    "/Users/Jo/code/rust/prefligit/target/distrib/prefligit.rb",
    "/Users/Jo/code/rust/prefligit/target/distrib/sha256.sum"
  ]
}
The generated `prefligit.rb`
class Prefligit < Formula
  desc "pre-commit implemented in Rust"
  homepage "https://github.com/j178/prefligit"
  version "0.0.8"
  if OS.mac?
    if Hardware::CPU.arm?
      url "https://github.com/j178/prefligit/releases/download/v0.0.8/prefligit-aarch64-apple-darwin.tar.gz"
    end
    if Hardware::CPU.intel?
      url "https://github.com/j178/prefligit/releases/download/v0.0.8/prefligit-x86_64-apple-darwin.tar.gz"
    end
  end
  if OS.linux?
    if Hardware::CPU.intel?
      url "https://github.com/j178/prefligit/releases/download/v0.0.8/prefligit-x86_64-unknown-linux-gnu.tar.gz"
    end
  end

  BINARY_ALIASES = {
    "aarch64-apple-darwin": {},
    "x86_64-apple-darwin": {},
    "x86_64-pc-windows-gnu": {},
    "x86_64-unknown-linux-gnu": {}
  }

  def target_triple
    cpu = Hardware::CPU.arm? ? "aarch64" : "x86_64"
    os = OS.mac? ? "apple-darwin" : "unknown-linux-gnu"

    "#{cpu}-#{os}"
  end

  def install_binary_aliases!
    BINARY_ALIASES[target_triple.to_sym].each do |source, dests|
      dests.each do |dest|
        bin.install_symlink bin/source.to_s => dest
      end
    end
  end

  def install
    if OS.mac? && Hardware::CPU.arm?
      bin.install "prefligit"
    end
    if OS.mac? && Hardware::CPU.intel?
      bin.install "prefligit"
    end
    if OS.linux? && Hardware::CPU.intel?
      bin.install "prefligit"
    end

    install_binary_aliases!

    # Homebrew will automatically install these, so we don't need to do that
    doc_files = Dir["README.*", "readme.*", "LICENSE", "LICENSE.*", "CHANGELOG.*"]
    leftover_contents = Dir["*"] - doc_files

    # Install any leftover files in pkgshare; these are probably config or
    # sample files.
    pkgshare.install(*leftover_contents) unless leftover_contents.empty?
  end
end
@mistydemeo
Copy link
Contributor

Sorry for the inconvenience! At the moment, this is an expected result of the custom build step you're using. dist ordinarily calculates the local artifact checksums during the build step, then persists that data for use in later runs. In this case, since that logic was all skipped during your custom build step, the Homebrew and shell installers don't have checksum data to use during the global build step.

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

No branches or pull requests

2 participants