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

feat: Windows Chocolatey package #80

Merged
merged 30 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d82790e
feat(chocolatey): Initial chocolatey package
wilsonwaters Dec 12, 2022
e92e21c
feat(chocolatey): initial working version
wilsonwaters Dec 13, 2022
ad2633a
fix: pyproject.toml version error
wilsonwaters Dec 13, 2022
1d48a24
fix(chocolatey): install script improvement
wilsonwaters Dec 13, 2022
b567d2b
feat(chocolatey): initial github actions
wilsonwaters Dec 13, 2022
93a79cf
feat(chocolatey): added a condition to publish on manual production r…
wilsonwaters Dec 13, 2022
6e48c0e
feat(chocolatey): added readme docs
wilsonwaters Dec 20, 2022
e8ce2c8
Don't assume pipx is on path
wilsonwaters Dec 20, 2022
9407bad
github action for chocolatey publish
wilsonwaters Dec 20, 2022
21a4536
testing github actions
wilsonwaters Dec 20, 2022
4126965
attempt to check branch name in release job
wilsonwaters Dec 20, 2022
a71593f
better way to get git branch name
wilsonwaters Dec 20, 2022
c9f8c8b
prevent pip audit error on copier package
wilsonwaters Dec 20, 2022
ef8e2b6
handle branch based versions
wilsonwaters Dec 20, 2022
4d0ffa6
temporarily speed up build process by skipping CI steps
wilsonwaters Dec 20, 2022
8b22a89
temporarily speed up build process by skipping CI steps
wilsonwaters Dec 20, 2022
872a493
fix chocolatey pack command
wilsonwaters Dec 20, 2022
eff5c22
remove dots from branch name
wilsonwaters Dec 20, 2022
25c4738
truncate special part of beta version
wilsonwaters Dec 20, 2022
8250358
fix secrets not being passed in to workflow
wilsonwaters Dec 20, 2022
f40609d
clean up
wilsonwaters Dec 20, 2022
8a92467
Merge branch 'main' into chocolatey-package
wilsonwaters Dec 20, 2022
baf75e3
update copier to special alpha release which works with Windows
wilsonwaters Jan 3, 2023
9efa805
feature: testing chocolatey release
wilsonwaters Jan 4, 2023
a4d6682
feature(chocolatey): added logo and docs URLs
wilsonwaters Jan 4, 2023
074620f
added logo
wilsonwaters Jan 4, 2023
310655e
Attempt to prevent version bump on manual branch release
wilsonwaters Jan 4, 2023
f5f0d33
Merge branch 'main' into chocolatey-package
wilsonwaters Jan 4, 2023
0697b75
remove CD action testing code
wilsonwaters Jan 4, 2023
ea49e5a
Merge branch 'chocolatey-package' of https://github.com/algorandfound…
wilsonwaters Jan 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.md"
python = "^3.10"
click = "^8.1.3"
httpx = "^0.23.1"
copier = "^7.0.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we switch to the fixed version of copier while we're waiting for copier-org/copier#890 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

copier = { git = "https://github.com/wilsonwaters/copier.git", branch="remove-iteration-utilities" }
questionary = "^1.10.0"

[tool.poetry.group.dev.dependencies]
Expand Down
32 changes: 32 additions & 0 deletions scripts/chocolatey/algokit/algokit.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>algokit</id>
<version></version> <!-- note, no semantic version 2.0 support. So beta.17 needs to be beta17 https://github.com/chocolatey/choco/issues/1610 -->
<packageSourceUrl>https://github.com/algorandfoundation/algokit-cli/blob/main/scripts/chocolatey</packageSourceUrl>
<owners>wilsonwaters</owners>
<title>algokit</title>
<authors>Algorand Foundation</authors>
<projectUrl>https://www.algorand.foundation/developers</projectUrl>
<!-- <iconUrl>http://rawcdn.githack.com/__REPLACE_YOUR_REPO__/master/icons/algokit.png</iconUrl> -->
<licenseUrl>https://github.com/algorandfoundation/algokit-cli/blob/main/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/algorandfoundation/algokit-cli</projectSourceUrl>
<!-- <docsUrl>At what url are the software docs located?</docsUrl> -->
<bugTrackerUrl>https://github.com/algorandfoundation/algokit-cli/issues</bugTrackerUrl>
<tags>algokit algorand developers python typescript hello-world smart-contract beaker</tags>
<summary>The Algorand AlgoKit CLI is the one-stop shop tool for developers building on the Algorand network.</summary>
<description><![CDATA[AlgoKit gets developers of all levels up and running with a familiar, fun and productive development environment in minutes.
The goal of AlgoKit is to help developers build and launch secure, automated production-ready applications rapidly.
]]></description>
<!-- <releaseNotes>__REPLACE_OR_REMOVE__MarkDown_Okay</releaseNotes> -->
<dependencies>
<dependency id="python3" version="3.10" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting. It means that if you already have python installed globally then god knows what this will do (worth testing?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Python version hell.

For me, it installed a new version and added it at the beginning of my path.

Everything still worked, but yea, that might annoy people who already have a specific version of python installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for some chocolatey packages it will try to determine if it's already been installed manually and "take over". But doesn't seem to do this for python (fortunately?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we depend on >=3.10.0 here instead?

</dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
<file src="..\..\..\dist\algokit*.whl" target="tools" />
</files>
</package>
21 changes: 21 additions & 0 deletions scripts/chocolatey/algokit/tools/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Algorand Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 10 additions & 0 deletions scripts/chocolatey/algokit/tools/VERIFICATION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.

Official algokit releases can be found on the Githib project page
https://github.com/algorandfoundation/algokit-cli/releases/
A checksum can be generated from corresponding .whl file and compared with the checksum
specified in the chocolatey release.

Algorand Foundation are the authors of this software and maintainers of the Chocolatey package.
43 changes: 43 additions & 0 deletions scripts/chocolatey/algokit/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

# run refreshenv to ensure python is on path. If it was just installed
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
else {
Write-Output "couldn't find chocolatey profile script"
}
RefreshEnv.cmd

# ensure pipx is installed
python -m pip --disable-pip-version-check install --user pipx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assume python will work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If python has been installed successfully as a dependency, then I can't see why not? Do you think I should do a test and print a useful error message (rather than a slightly obscure "command not found" error).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the logic here, but this makes our package not idempotent due to also requiring pipe for uninstall. Can we make pipx a dependency instead? This would mirror our home-brew package, and pipx is actually an (optional) runtime dependency (for installing poetry if not already installed during bootstrap)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no pipx package for chocolatey.

if ($LASTEXITCODE -ne 0) {
Throw "Error installing pipx"
}

# work out the wheel name and make sure there wasn't a packaging error
$wheelFileName = Get-ChildItem -File -Filter $env:ChocolateyPackageName*.whl $toolsDir
if ($wheelFileName.count -ne 1) {
Throw "Packaging error. nupkg contained $($wheelFile.count) wheel files"
}

# determine if the package is already installed. In which case, uninstall it first
# Note - pipx upgrade does not work with local files
$pipxListOutput = pipx list
wilsonwaters marked this conversation as resolved.
Show resolved Hide resolved
if ($LASTEXITCODE -ne 0) {
Throw "Error searching for existing packages"
}
if ($pipxListOutput -match "algokit.*") {
wilsonwaters marked this conversation as resolved.
Show resolved Hide resolved
pipx uninstall $env:ChocolateyPackageName
if ($LASTEXITCODE -ne 0) {
Throw "Error removing existing version"
}
}

# install the bundled wheel file.
# For some reason pipx outputs normal messages to stderr, which causes choco to complain. Redirect stderr to stdout and rely on return value for errors
pipx install $wheelFileName[0].FullName 2>&1
if ($LASTEXITCODE -ne 0) {
Throw "Error installing $($wheelFileName[0].FullName)"
}
16 changes: 16 additions & 0 deletions scripts/chocolatey/algokit/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ensure pipx is installed. Just in case someone has removed it manually
python -m pip --disable-pip-version-check install --user pipx
if ($LASTEXITCODE -ne 0) {
Throw "Error configuring pipx for uninstalling"
}

# zap it
pipx uninstall $env:ChocolateyPackageName | Tee-Object -Variable cmdOutput
wilsonwaters marked this conversation as resolved.
Show resolved Hide resolved
if ($LASTEXITCODE -ne 0) {
if ($cmdOutput -match "Nothing to uninstall" ) {
Write-Output "$($env:ChocolateyPackageName) already uninstalled by pipx. Ignoring"
}
else {
Throw "Error running pipx uninstall $($env:ChocolateyPackageName)"
}
}