-
Notifications
You must be signed in to change notification settings - Fork 372
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
Release separated archives for each platform (#697) #699
Conversation
Welcome @zigarn! |
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/assign @corneliusweig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on! This is a welcome improvement.
Please take a look at my comments.
@@ -80,7 +80,7 @@ jobs: | |||
uses: svenstaro/upload-release-action@v2 | |||
with: | |||
repo_token: ${{ secrets.GITHUB_TOKEN }} | |||
file: out/krew.* | |||
file: out/krew* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file: out/krew* | |
file: out/krew-* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would exclude the krew.exe[.sha256]
and krew.yaml
docs/RELEASING_KREW.md
Outdated
KREW_ROOT="$(mktemp -d --tmpdir krew-XXXXXXXXXX)" KREW_OS=darwin \ | ||
$krew install --manifest=out/krew.yaml --archive=out/krew.tar.gz && \ | ||
$krew install --manifest=out/krew.yaml --archive=out/krew-darwin_amd64.tar.gz && \ | ||
KREW_ROOT="$(mktemp -d --tmpdir krew-XXXXXXXXXX)" KREW_OS=linux \ | ||
$krew install --manifest=out/krew.yaml --archive=out/krew.tar.gz && \ | ||
$krew install --manifest=out/krew.yaml --archive=out/krew-linux_amd64.tar.gz && \ | ||
KREW_ROOT="$(mktemp -d --tmpdir krew-XXXXXXXXXX)" KREW_OS=windows \ | ||
$krew install --manifest=out/krew.yaml --archive=out/krew.tar.gz | ||
$krew install --manifest=out/krew.yaml --archive=out/krew-windows_amd64.tar.gz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please do something like this instead:
for osarch in darwin_amd64 darwin_arm64 linux_amd64 linux_arm linux_arm64 windows_amd64; do
KREW_ROOT="$(mktemp -d --tmpdir krew-XXXXXXXXXX)" KREW_OS="${osarch%_*}" \
$krew install --manifest=out/krew.yaml --archive="out/krew-${osarch}.tar.gz"
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it but didn't know if not everything was tested on purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! It was on purpose to not mix architectures. Will add KREW_ARCH
.
KREWNAME="krew-${OS}_${ARCH}" && | ||
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREWNAME}.tar.gz" && | ||
tar zxvf "${KREWNAME}.tar.gz" && | ||
./"${KREWNAME}" install --manifest-url https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.yaml --archive ./${KREWNAME}.tar.gz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./"${KREWNAME}" install --manifest-url https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.yaml --archive ./${KREWNAME}.tar.gz | |
./"${KREWNAME}" install krew |
The --manifest
and --archive
options are only for testing. When a plugin is installed like this, it will be in a detached state where it is not updated when new versions are published on krew-index
. So we do need to download twice here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arf, too bad.
Maybe would be possible to allow --archive
without --manifest[-url]
to use local archive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That does not work either, I'm afraid. It should not be a big deal though. Installation is only done once, and you are already cutting down the download size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it works, by removing the lines doing the check in cmd/krew/cmd/install.go and compiling.
diff --git i/cmd/krew/cmd/install.go w/cmd/krew/cmd/install.go
index a574346..ac4b265 100644
--- i/cmd/krew/cmd/install.go
+++ w/cmd/krew/cmd/install.go
@@ -96,10 +96,6 @@ Remarks:
return errors.New("must specify either specify either plugin names (via positional arguments or STDIN), or --manifest/--manifest-url; not both")
}
- if *archiveFileOverride != "" && *manifest == "" && *manifestURL == "" {
- return errors.New("--archive can be specified only with --manifest or --manifest-url")
- }
-
var install []pluginEntry
for _, name := range pluginNames {
indexName, pluginName := pathutil.CanonicalPluginName(name)
$ curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.tar.gz"
$ ./out/bin/krew-linux_amd64 install krew --archive ./krew.tar.gz
Adding "default" plugin index from https://github.com/kubernetes-sigs/krew-index.git.
Updated the local copy of plugin index.
Installing plugin: krew
Installed plugin: krew
\
| Use this plugin:
| kubectl krew
| Documentation:
| https://krew.sigs.k8s.io/
| Caveats:
| \
| | krew is now installed! To start using kubectl plugins, you need to add
| | krew's installation directory to your PATH:
| |
| | * macOS/Linux:
| | - Add the following to your ~/.bashrc or ~/.zshrc:
| | export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
| | - Restart your shell.
| |
| | * Windows: Add %USERPROFILE%\.krew\bin to your PATH environment variable
| |
| | To list krew commands and to get help, run:
| | $ kubectl krew
| | For a full list of available plugins, run:
| | $ kubectl krew search
| |
| | You can find documentation at
| | https://krew.sigs.k8s.io/docs/user-guide/quickstart/.
| /
/
$ tail ~/.krew/receipts/krew.yaml
matchLabels:
arch: amd64
os: windows
sha256: a26deea175f70264260d59a4e061778a892f8a8e301ac261660dd7d24c551c99
uri: https://github.com/kubernetes-sigs/krew/releases/download/v0.4.1/krew.tar.gz
shortDescription: Package manager for kubectl plugins.
version: v0.4.1
status:
source:
name: default
Source is not 'detached'.
And I can confirm tat there is no download of archive through the install.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we reserved those arguments specifically for local testing so they are used for installing "detached" plugins. I’m not sure if it's worth changing that just to prevent downloading a small tarball once more.
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.tar.gz" && | ||
tar zxvf krew.tar.gz && | ||
KREW=./krew-"${OS}_${ARCH}" && | ||
"$KREW" install krew | ||
KREWNAME="krew-${OS}_${ARCH}" && | ||
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREWNAME}.tar.gz" && | ||
tar zxvf "${KREWNAME}.tar.gz" && | ||
./"${KREWNAME}" install --manifest-url https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.yaml --archive ./${KREWNAME}.tar.gz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in this file will affect the installation instructions seen by users for the current release. However, these instructions only become effective, once we craft a new release with the other changes within this PR. So the doc updates must go into a different PR that will be merged after the next release.
So please extract this into a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted in #700
Previous comments on it have been applied.
hack/make-release-artifacts.sh
Outdated
( | ||
cd "${archive_dir}" | ||
# consistent timestamps for files in archive dir to ensure consistent checksums | ||
TZ=UTC touch -amt "0001010000" ./* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine this could make trouble on Mac/BSD, because the man says
-a change only the access time
-m change only the modification time
So I'm worried they take the only too seriously. If you can check it works then great.
However, we can still make the change, because nowadays the release is only done by GH actions and they run on Linux where I have verified that the result is the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc start with:
Update the access and modification times of each FILE to the current time.
So I guess the only means that this option will change this one only compared to both.
And at the end, using both options is same as using none...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D good catch
hack/make-release-artifacts.sh
Outdated
archive_dir="$(mktemp -d)" | ||
cp "$f" "${archive_dir}" | ||
cp -- "${SCRIPTDIR}/../LICENSE" "${archive_dir}" | ||
archive="$(basename "$f" .exe).tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's extract this into a variable, because it is reused a few times.
archive="$(basename "$f" .exe).tar.gz" | |
name=$(basename "$f" .exe) | |
archive="${name}.tar.gz" |
hack/make-release-artifacts.sh
Outdated
checksum_cmd="sha256sum" | ||
fi | ||
# prepare krew manifest sed | ||
checksum_sed="${checksum_sed};s/KREW_$(basename "$f" .exe | sed 's/krew-\(.*\)/\U\1/')_CHECKSUM/${checksum}/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make the intent clearer by using tr
here:
checksum_sed="${checksum_sed};s/KREW_$(basename "$f" .exe | sed 's/krew-\(.*\)/\U\1/')_CHECKSUM/${checksum}/" | |
checksum_sed="${checksum_sed};s/$(tr "[[:lower:]-]" "[[:upper:]_]" <<< ${name} | |
)_CHECKSUM/${checksum}/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ah, I did hesitate between both.
hack/make-release-artifacts.sh
Outdated
@@ -75,6 +76,6 @@ if [[ ! "${git_describe}" =~ v.* ]]; then | |||
fi | |||
krew_version="${TAG_NAME:-$git_describe}" | |||
cp ./hack/krew.yaml ./out/krew.yaml | |||
sed -i "s/KREW_TAR_CHECKSUM/${tar_checksum}/g" ./out/krew.yaml | |||
sed -i "${checksum_sed}" ./out/krew.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sed -i "${checksum_sed}" ./out/krew.yaml | |
sed "${checksum_sed}" ./hack/krew.yaml > ./out/krew.yaml |
And remove the cp ./hack/krew.yaml ./out/krew.yaml
in the previous line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did also integrated the next sed in it.
Co-authored-by: Cornelius Weig <corneliusweig@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works flawlessly, thanks! The only thing that I could not verify is that our release automation uploads the right files. It looks right though.
/lgtm
/approve
/hold
In case @ahmetb wants to take a look too.
KREW_ROOT="$(mktemp -d --tmpdir krew-XXXXXXXXXX)" KREW_OS=windows \ | ||
$krew install --manifest=out/krew.yaml --archive=out/krew.tar.gz | ||
for osarch in darwin_amd64 darwin_arm64 linux_amd64 linux_arm linux_arm64 windows_amd64; do | ||
KREW_ROOT="$(mktemp -d --tmpdir krew-XXXXXXXXXX)" KREW_OS="${osarch%_*}" KREW_ARCH="${osarch#*_}" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) I didn't even think of setting KREW_ARCH
. Great that we do now!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: corneliusweig, zigarn The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
/remove-lifecycle stale |
/hold cancel |
@corneliusweig, it has to wait for a release anyway, so no reason to be impatient. |
Fixes #697
In install instructions, use
--archive
(and therefore--manifest-url
) to not download again the tarball when launchingkrew install
command.