-
Notifications
You must be signed in to change notification settings - Fork 936
feat: sign coder binaries with the release key using GPG #18774
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
jdomeracki-coder
wants to merge
5
commits into
main
Choose a base branch
from
jdomeracki-coder/gpg-signing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+82
−19
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e80259c
feat: sign coder binaries with the release key using GPG
jdomeracki-coder ddd2ada
chore: add comments and invoke the sign_with_gpg.sh script from publi…
jdomeracki-coder 55c67d6
fix: set CODER_GPG_RELEASE_KEY_BASE64 in build & releaes steps
jdomeracki-coder 6241bac
fix: use error instead of echo
jdomeracki-coder d47b7d3
fix: remove redirect to stderr
jdomeracki-coder 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,6 +252,10 @@ $(CODER_ALL_BINARIES): go.mod go.sum \ | |
fi | ||
|
||
cp "$@" "./site/out/bin/coder-$$os-$$arch$$dot_ext" | ||
|
||
if [[ "$${CODER_SIGN_GPG:-0}" == "1" ]]; then | ||
cp "[email protected]" "./site/out/bin/coder-$$os-$$arch$$dot_ext.asc" | ||
fi | ||
fi | ||
|
||
# This task builds Coder Desktop dylibs | ||
|
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,59 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script signs a given binary using GPG. | ||
# It expects the binary to be signed as the first argument. | ||
# | ||
# Usage: ./sign_with_gpg.sh path/to/binary | ||
# | ||
# On success, the input file will be signed using the GPG key and the signature output file will moved to /site/out/bin/ (happens in the Makefile) | ||
# | ||
# Depends on the GPG utility. Requires the following environment variables to be set: | ||
# - $CODER_GPG_RELEASE_KEY_BASE64: The base64 encoded private key to use. | ||
|
||
set -euo pipefail | ||
# shellcheck source=scripts/lib.sh | ||
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" | ||
|
||
requiredenvs CODER_GPG_RELEASE_KEY_BASE64 | ||
|
||
FILE_TO_SIGN="$1" | ||
|
||
if [[ -z "$FILE_TO_SIGN" ]]; then | ||
error "Usage: $0 <file_to_sign>" | ||
fi | ||
|
||
if [[ ! -f "$FILE_TO_SIGN" ]]; then | ||
error "File not found: $FILE_TO_SIGN" | ||
fi | ||
|
||
# Import the GPG key. | ||
old_gnupg_home="${GNUPGHOME:-}" | ||
gnupg_home_temp="$(mktemp -d)" | ||
export GNUPGHOME="$gnupg_home_temp" | ||
|
||
# Ensure GPG uses the temporary directory | ||
echo "$CODER_GPG_RELEASE_KEY_BASE64" | base64 -d | gpg --homedir "$gnupg_home_temp" --import 1>&2 | ||
|
||
# Sign the binary. This generates a file in the same directory and | ||
# with the same name as the binary but ending in ".asc". | ||
# | ||
# We pipe `true` into `gpg` so that it never tries to be interactive (i.e. | ||
# ask for a passphrase). The key we import above is not password protected. | ||
true | gpg --homedir "$gnupg_home_temp" --detach-sign --armor "$FILE_TO_SIGN" 1>&2 | ||
|
||
# Verify the signature and capture the exit status | ||
gpg --homedir "$gnupg_home_temp" --verify "${FILE_TO_SIGN}.asc" "$FILE_TO_SIGN" 1>&2 | ||
verification_result=$? | ||
|
||
# Clean up the temporary GPG home | ||
rm -rf "$gnupg_home_temp" | ||
unset GNUPGHOME | ||
if [[ "$old_gnupg_home" != "" ]]; then | ||
export GNUPGHOME="$old_gnupg_home" | ||
fi | ||
|
||
if [[ $verification_result -eq 0 ]]; then | ||
echo "${FILE_TO_SIGN}.asc" | ||
else | ||
error "Signature verification failed!" | ||
fi |
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.