Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: sign coder binaries with GPG & serve from path /bin/ #18763

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,24 @@ jobs:
GCLOUD_ACCESS_TOKEN: ${{ steps.gcloud_auth.outputs.access_token }}
JSIGN_PATH: /tmp/jsign-6.0.jar

- name: Sign binaries with GPG
run: |
set -euo pipefail

for binary in ./build/coder_{darwin,linux,windows}*; do
if [[ -f "$binary" ]]; then
./scripts/sign_with_gpg.sh "$binary"
fi
done
env:
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.CODER_GPG_RELEASE_KEY_BASE64 }}

- name: Insert signatures
run: |
for sigfile in ./build/*.sig; do
mv "$sigfile" ./site/out/bin/
done

- name: Build Linux Docker images
id: build-docker
env:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,24 @@ jobs:
- name: Delete Windows EV Signing Cert
run: rm /tmp/ev_cert.pem

- name: Sign binaries with GPG
run: |
set -euo pipefail

for binary in ./build/coder_{darwin,linux,windows}*; do
if [[ -f "$binary" ]]; then
./scripts/sign_with_gpg.sh "$binary"
fi
done
env:
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.CODER_GPG_RELEASE_KEY_BASE64 }}

- name: Insert signatures
run: |
for sigfile in ./build/*.sig; do
mv "$sigfile" ./site/out/bin/
done

- name: Determine base image tag
id: image-base-tag
run: |
Expand Down
43 changes: 43 additions & 0 deletions scripts/sign_with_gpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/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.
#
# 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

requiredenvs CODER_GPG_RELEASE_KEY_BASE64

FILE_TO_SIGN="$1"

if [[ -z "$FILE_TO_SIGN" ]]; then
echo "Usage: $0 <file_to_sign>"
exit 1
fi

if [[ ! -f "$FILE_TO_SIGN" ]]; then
echo "File not found: $FILE_TO_SIGN"
exit 1
fi

# Import the private key.
echo "$CODER_GPG_RELEASE_KEY_BASE64" | base64 --decode | gpg --import 1>&2

# Sign the binary.
gpg --detach-sign --armor "$FILE_TO_SIGN" 1>&2

# Verify the signature.
gpg --verify "${FILE_TO_SIGN}.sig" "$FILE_TO_SIGN" 1>&2

if [[ $? -eq 0 ]]; then
echo "${FILE_TO_SIGN}.sig"
else
echo "Signature verification failed!" >&2
exit 1
fi
Loading