Skip to content

Commit ed9f021

Browse files
authored
feat: implement remote package signing (#24196)
1 parent a7a6e92 commit ed9f021

File tree

2 files changed

+42
-28
lines changed

2 files changed

+42
-28
lines changed

.circleci/config.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ workflows:
164164
- build-package-linux-amd64
165165
- changelog:
166166
<<: *any_filter
167+
- sign-packages:
168+
<<: *release_filter
169+
requires:
170+
- build-package-linux-amd64
171+
- build-package-linux-arm64
172+
- build-package-darwin-amd64
173+
- build-package-windows-amd64
167174
- s3-publish-packages:
168175
<<: *release_filter
169176
requires:
@@ -172,6 +179,7 @@ workflows:
172179
- build-package-linux-amd64
173180
- build-package-linux-arm64
174181
- build-package-windows-amd64
182+
- sign-packages
175183
- s3-publish-changelog:
176184
<<: *release_filter
177185
publish-type: release
@@ -517,8 +525,42 @@ jobs:
517525
- artifacts
518526
- store_artifacts:
519527
path: /artifacts
528+
520529
destination: artifacts
521530

531+
sign-packages:
532+
circleci_ip_ranges: true
533+
docker:
534+
- image: quay.io/influxdb/rsign:latest
535+
auth:
536+
username: $QUAY_RSIGN_USERNAME
537+
password: $QUAY_RSIGN_PASSWORD
538+
steps:
539+
- add_ssh_keys:
540+
fingerprints:
541+
- fc:7b:6e:a6:38:7c:63:5a:13:be:cb:bb:fa:33:b3:3c
542+
- attach_workspace:
543+
at: /tmp/workspace
544+
- run: |
545+
for target in /tmp/workspace/artifacts/*
546+
do
547+
case "${target}"
548+
in
549+
# rsign is shipped on Alpine Linux which uses "busybox ash" instead
550+
# of bash. ash is somewhat more posix compliant and is missing some
551+
# extensions and niceties from bash.
552+
*.deb|*.rpm|*.tar.gz|*.zip)
553+
rsign "${target}"
554+
;;
555+
esac
556+
done
557+
- persist_to_workspace:
558+
root: /tmp/workspace
559+
paths:
560+
- artifacts
561+
- store_artifacts:
562+
path: /tmp/workspace/artifacts
563+
522564
s3-publish-packages:
523565
docker:
524566
- image: ubuntu:latest

.circleci/scripts/build-package

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -135,33 +135,5 @@ build_package_linux()
135135
run_fpm rpm
136136
}
137137

138-
sign_artifacts()
139-
{
140-
# If this is not a release version, don't sign the artifacts. This
141-
# prevents unathorized PRs and branches from being signed with our
142-
# signing key.
143-
if [[ ! ${RELEASE:-} ]]
144-
then
145-
return 0
146-
fi
147-
148-
# CircleCI mangles environment variables with newlines. This key contians
149-
# escaped newlines. For `gpg` to import the key, it requires `echo -e` to
150-
# expand the escape sequences.
151-
gpg --batch --import <<<"$(echo -e "${GPG_PRIVATE_KEY}")"
152-
153-
# TODO(bnpfeife): replace with code signing server
154-
for target in /artifacts/*
155-
do
156-
gpg \
157-
--batch \
158-
--pinentry-mode=loopback \
159-
--passphrase "${PASSPHRASE}" \
160-
--detach-sign \
161-
--armor "${target}"
162-
done
163-
}
164-
165138
build_archive
166139
build_package_linux
167-
sign_artifacts

0 commit comments

Comments
 (0)