-
Notifications
You must be signed in to change notification settings - Fork 21
Bundle go-search-replace next to vip-next #3027
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
Open
mokagio
wants to merge
6
commits into
ainfra-3030-refine-the-vip-cli-signing-implementation-from-3013
from
mokagio/bundle-go-search-replace
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c74a882
Fetch go-search-replace with curl and MANIFEST
mokagio 5d3b6ab
Pack signed vip-next with go-search-replace
mokagio 6a52e6b
Honor BIN_BASE in pack-release tarball names
mokagio 8a5e599
Drop stale TAG= from vendor-search-replace docs
mokagio b107e85
Align MANIFEST upgrade notes with Makefile
mokagio 02f676a
Remove trailing newlines
mokagio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| # Fetch go-search-replace for each goos/goarch argument, verify against | ||
| # third_party/go-search-replace/MANIFEST, install under that tree. | ||
| # Usage: fetch-search-replace.sh darwin/arm64 darwin/amd64 | ||
| # No args: this host's GOOS/GOARCH. | ||
|
|
||
| GSR_DIR=third_party/go-search-replace | ||
| GSR_REPO=Automattic/go-search-replace | ||
|
|
||
| sha256() { | ||
| if command -v shasum >/dev/null 2>&1; then | ||
| shasum -a 256 "$1" | awk '{ print $1 }' | ||
| else | ||
| sha256sum "$1" | awk '{ print $1 }' | ||
| fi | ||
| } | ||
|
|
||
| tag="$(awk '$1=="TAG"{print $2}' "${GSR_DIR}/MANIFEST")" | ||
| [ -n "${tag}" ] || { echo "no TAG in ${GSR_DIR}/MANIFEST" >&2; exit 1; } | ||
|
|
||
| if [ "$#" -eq 0 ]; then | ||
| set -- "$(go env GOOS)/$(go env GOARCH)" | ||
| fi | ||
|
|
||
| tmp="$(mktemp -d)" | ||
| trap 'rm -rf "${tmp}"' EXIT | ||
|
|
||
| for t in "$@"; do | ||
| os="${t%%/*}" | ||
| arch="${t##*/}" | ||
| want="$(awk -v k="${t}" '$1==k{print $2}' "${GSR_DIR}/MANIFEST")" | ||
| if [ -z "${want}" ]; then | ||
| echo "ERROR: ${t} is not pinned in ${GSR_DIR}/MANIFEST" >&2 | ||
| exit 1 | ||
| fi | ||
| name="go-search-replace_${os}_${arch}" | ||
| if [ "${os}" = windows ]; then | ||
| name="${name}.exe" | ||
| fi | ||
| url="https://github.com/${GSR_REPO}/releases/download/${tag}/${name}.gz" | ||
| echo " fetching ${name} (${tag})" | ||
| if ! curl -fsSL "${url}" -o "${tmp}/${name}.gz"; then | ||
| echo "ERROR: could not download ${url}" >&2 | ||
| exit 1 | ||
| fi | ||
| gunzip -f "${tmp}/${name}.gz" | ||
| got="$(sha256 "${tmp}/${name}")" | ||
| if [ "${got}" != "${want}" ]; then | ||
| echo "ERROR: checksum mismatch for ${t}" >&2 | ||
| echo " expected (from upstream SLSA provenance): ${want}" >&2 | ||
| echo " got: ${got}" >&2 | ||
| echo " Refusing to install. Do not bypass this." >&2 | ||
| exit 1 | ||
| fi | ||
| out="${GSR_DIR}/${os}-${arch}" | ||
| mkdir -p "${out}" | ||
| d="${out}/go-search-replace" | ||
| if [ "${os}" = windows ]; then | ||
| d="${d}.exe" | ||
| fi | ||
| mv "${tmp}/${name}" "${d}" | ||
| chmod +x "${d}" | ||
| echo " verified + installed ${d}" | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| # Pack vip-next + go-search-replace into dist/${BIN_BASE}-<os>-<arch>.tar.gz | ||
| # Usage: pack-release.sh <goos> <goarch> <vip-next-path> <helper-path> | ||
|
|
||
| : "${BIN_BASE:=vip-next}" | ||
|
|
||
| os="${1:?}" | ||
| arch="${2:?}" | ||
| bin="${3:?}" | ||
| helper="${4:?}" | ||
|
|
||
| stage="$(mktemp -d)" | ||
| trap 'rm -rf "${stage}"' EXIT | ||
|
|
||
| if [ "${os}" = windows ]; then | ||
| cp "${bin}" "${stage}/vip-next.exe" | ||
| cp "${helper}" "${stage}/go-search-replace.exe" | ||
| chmod +x "${stage}/vip-next.exe" "${stage}/go-search-replace.exe" | ||
| tar -czf "dist/${BIN_BASE}-windows-${arch}.tar.gz" -C "${stage}" vip-next.exe go-search-replace.exe | ||
| else | ||
| cp "${bin}" "${stage}/vip-next" | ||
| cp "${helper}" "${stage}/go-search-replace" | ||
| chmod +x "${stage}/vip-next" "${stage}/go-search-replace" | ||
| tar -czf "dist/${BIN_BASE}-${os}-${arch}.tar.gz" -C "${stage}" vip-next go-search-replace | ||
| fi | ||
|
mokagio marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.