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

Add checksums (SHA256) to GitHub releases for all files #29656

Open
o-l-a-v opened this issue Aug 6, 2024 · 7 comments
Open

Add checksums (SHA256) to GitHub releases for all files #29656

o-l-a-v opened this issue Aug 6, 2024 · 7 comments
Assignees
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request
Milestone

Comments

@o-l-a-v
Copy link

o-l-a-v commented Aug 6, 2024

Related command

Add checksums (SHA256) to releases for all files, be it files hosted on GitHub (MSI, source code), and files from azcliprod.blob.core.windows.net (ZIP, MSI etc.).

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Add a list to GitHub releases with SHA256, like Beaver Notes does:

Describe alternatives you've considered

None.

Additional context

None.

@microsoft-github-policy-service microsoft-github-policy-service bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Aug 6, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Aug 6, 2024

Thank you for opening this issue, we will look into it.

@yonzhan yonzhan added feature-request Azure CLI Team The command of the issue is owned by Azure CLI team labels Aug 6, 2024
@yonzhan yonzhan added this to the Backlog milestone Aug 6, 2024
@jiasli
Copy link
Member

jiasli commented Aug 7, 2024

Hi @o-l-a-v, I noticed https://github.com/Beaver-Notes/Beaver-Notes/releases/tag/3.5.0 puts SHA256s in the release description:

image

https://github.com/PowerShell/PowerShell/releases/tag/v7.4.4 uses a different format:

image

How does Scoop extract this information from plaintext?

@o-l-a-v
Copy link
Author

o-l-a-v commented Aug 7, 2024

I have a PR on Beaver Notes for Scoop that shows the info Scoop needs to fetch the SHA256 checksums:

Here's the manifest for pwsh, looks like it fetches SHA256 info from release info too:

Here's info on the Scoop app manifest:

Here's Scoop main manifest repos, see if you can find more examples there:


Edit: And I believe the logic for getting new versions is found inside here:

Which calls Invoke-AutoUpdate from here:

@jiasli
Copy link
Member

jiasli commented Aug 7, 2024

Thanks @o-l-a-v, but I think you misunderstand my question.

In other words, how is 6461dd3fda39fc65e30c7642f863b9e1dabe32885043094e1d8a79dffcef1dcb extracted from https://github.com/PowerShell/PowerShell/releases/tag/v7.4.4 to https://github.com/ScoopInstaller/Main/blob/75c4fa28f734a4849633a8bd920013bf7d93911a/bucket/pwsh.json#L16 ? Is this a manual process? Or is there a standard format? I would like to know which format you want us to use to provide the SHA256s.

BTW, I noticed Scoop computes the SHA256 of https://azcliprod.blob.core.windows.net/zip/azure-cli-2.63.0-x64.zip by itself: https://github.com/ScoopInstaller/Main/blob/75c4fa28f734a4849633a8bd920013bf7d93911a/bucket/azure-cli.json#L13

@o-l-a-v
Copy link
Author

o-l-a-v commented Aug 7, 2024

As the feature request states: Scoop can calculate SHA256 by downloading the artifact. But if checksum is already made available and Scoop is told were to look, it does not have to 1) download the artifact and 2) calculate hash.

Scoop has logic to autoupdate manifests. If we add hash ("autoupdate":{"hash": {}}) property to the manifest JSON, Scoop will try to find the checksums depending on the logic. So for Beaver-Notes https://github.com/ScoopInstaller/Extras/pull/13661/files:

{
    ...
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://github.com/Beaver-Notes/Beaver-Notes/releases/download/$version/Beaver-notes.$version.portable.exe#/dl.7z"
            },
            "arm64": {
                "url": "https://github.com/Beaver-Notes/Beaver-Notes/releases/download/$version/Beaver-notes.$version.portable.arm64.exe#/dl.7z"
            }
        },
        "hash": {
            "url": "https://github.com/Beaver-Notes/Beaver-Notes/releases/tag/$version",
            "regex": "$sha256.*?$basename"
        }
    }
}

And for pwsh https://github.com/ScoopInstaller/Main/blob/master/bucket/pwsh.json:

{
    ...
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://github.com/PowerShell/PowerShell/releases/download/v$version/PowerShell-$version-win-x64.zip"
            },
            "32bit": {
                "url": "https://github.com/PowerShell/PowerShell/releases/download/v$version/PowerShell-$version-win-x86.zip"
            },
            "arm64": {
                "url": "https://github.com/PowerShell/PowerShell/releases/download/v$version/PowerShell-$version-win-arm64.zip"
            }
        },
        "hash": {
            "url": "$baseurl/hashes.sha256"
        }
    }
}

@o-l-a-v
Copy link
Author

o-l-a-v commented Aug 7, 2024

There are som find_hash_in_x functions inside here:

You could probably also just add checksum files to the GitHub release instead of adding it as plain text, if you prefer that.

@jiasli
Copy link
Member

jiasli commented Aug 8, 2024

Thank you for the detailed explanation. find_hash_in_textfile looks a little bit fragile. I think creating a hashes.sha256 with sha256sum --binary * is a more formal and reliable implementation. We will consider this as a feature request.

BTW, we can reuse the code from https://github.com/PowerShell/PowerShell/blob/a1774fd9332925f7635e0832b64b2d158e3a3745/.pipelines/templates/release-githubtasks.yml#L88-L104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request
Projects
None yet
Development

No branches or pull requests

4 participants