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

Skip to content

Commit 11ca693

Browse files
committed
feat(windows): add product information to coder.exe
1 parent f017548 commit 11ca693

File tree

12 files changed

+141
-2
lines changed

12 files changed

+141
-2
lines changed

.github/workflows/release.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ jobs:
119119
AC_APIKEY_ISSUER_ID: ${{ secrets.AC_APIKEY_ISSUER_ID }}
120120
AC_APIKEY_ID: ${{ secrets.AC_APIKEY_ID }}
121121
AC_APIKEY_FILE: /tmp/apple_apikey.p8
122+
CODER_SIGN_WINDOWS: "0"
123+
AUTHENTICODE_CERTIFICATE_FILE: /tmp/windows_cert.pkcs12
124+
AUTHENTICODE_CERTIFICATE_PASSWORD_FILE: /tmp/windows_cert_password.txt
122125

123126
- name: Delete Apple Developer certificate and API key
124127
run: rm -f /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ site/out/
4444
*.lock.hcl
4545
.terraform/
4646

47+
**/*.syso
48+
4749
.vscode/*.log
4850
.vscode/launch.json
4951
**/*.swp

cmd/coder/coder.exe.ico

188 KB
Binary file not shown.

cmd/coder/coder.exe.manifest

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<assemblyIdentity
4+
type="win32"
5+
name="Coder.com.Coder"
6+
version="1.0.0.0"
7+
processorArchitecture="*"/>
8+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
9+
<security>
10+
<requestedPrivileges>
11+
<requestedExecutionLevel
12+
level="asInvoker"
13+
uiAccess="false"/>
14+
</requestedPrivileges>
15+
</security>
16+
</trustInfo>
17+
</assembly>

cmd/coder/versioninfo.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"FixedFileInfo":
3+
{
4+
"FileVersion": {
5+
"Major": 0,
6+
"Minor": 0,
7+
"Patch": 0,
8+
"Build": 0
9+
},
10+
"ProductVersion": {
11+
"Major": 0,
12+
"Minor": 0,
13+
"Patch": 0,
14+
"Build": 0
15+
},
16+
"FileFlagsMask": "3f",
17+
"FileFlags ": "00",
18+
"FileOS": "040004",
19+
"FileType": "01",
20+
"FileSubType": "00"
21+
},
22+
"StringFileInfo":
23+
{
24+
"Comments": "https://coder.com",
25+
"CompanyName": "Coder Technologies, Inc",
26+
"FileDescription": "Coder",
27+
"FileVersion": "",
28+
"InternalName": "coder",
29+
"LegalCopyright": "© Coder Technologies, Inc. All rights reserved.",
30+
"LegalTrademarks": "",
31+
"OriginalFilename": "coder.exe",
32+
"PrivateBuild": "",
33+
"ProductName": "Coder®",
34+
"ProductVersion": "",
35+
"SpecialBuild": ""
36+
},
37+
"VarFileInfo":
38+
{
39+
"Translation": {
40+
"LangID": "0409",
41+
"CharsetID": "04B0"
42+
}
43+
}
44+
}

docs/CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ Alternatively if you do not want to use nix then you'll need to install the need
6262
- on macOS, run `brew install pango`
6363
- [`pandoc`]()
6464
- on macOS, run `brew install pandocomatic`
65-
65+
- [`osslsigncode`]()
66+
- on macOS, run `brew install osslsigncode`
6667

6768
### Development workflow
6869

dogfood/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ RUN apt-get update --quiet && apt-get install --yes \
124124
openjdk-11-jdk-headless \
125125
openssh-server \
126126
openssl \
127+
osslsigncode \
127128
pkg-config \
128129
python3 \
129130
python3-pip \

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
nodePackages.typescript
3333
nodePackages.typescript-language-server
3434
nodejs
35+
osslsigncode
3536
openssh
3637
openssl
3738
postgresql

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,8 @@ require (
302302
gopkg.in/yaml.v2 v2.4.0 // indirect
303303
howett.net/plist v1.0.0 // indirect
304304
)
305+
306+
require (
307+
github.com/akavel/rsrc v0.10.2 // indirect
308+
github.com/josephspurrier/goversioninfo v1.4.0 // indirect
309+
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki
170170
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
171171
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
172172
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
173+
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
174+
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
173175
github.com/akutz/memconn v0.1.0 h1:NawI0TORU4hcOMsMr11g7vwlCdkYeLKXBcxWu2W/P8A=
174176
github.com/akutz/memconn v0.1.0/go.mod h1:Jo8rI7m0NieZyLI5e2CDlRdRqRRB4S7Xp77ukDjH+Fw=
175177
github.com/alecthomas/chroma v0.9.4/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
@@ -1118,6 +1120,8 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx
11181120
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
11191121
github.com/jonboulle/clockwork v0.2.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
11201122
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
1123+
github.com/josephspurrier/goversioninfo v1.4.0 h1:Puhl12NSHUSALHSuzYwPYQkqa2E1+7SrtAPJorKK0C8=
1124+
github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY=
11211125
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
11221126
github.com/josharian/native v1.0.0 h1:Ts/E8zCSEsG17dUqv7joXJFybuMLjQfWE04tsBODTxk=
11231127
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=

scripts/build_go.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ os="${GOOS:-linux}"
3232
arch="${GOARCH:-amd64}"
3333
slim="${CODER_SLIM_BUILD:-0}"
3434
sign_darwin="${CODER_SIGN_DARWIN:-0}"
35+
sign_windows="${CODER_SIGN_WINDOWS:-0}"
3536
output_path=""
3637
agpl="${CODER_BUILD_AGPL:-0}"
3738

38-
args="$(getopt -o "" -l version:,os:,arch:,output:,slim,agpl,sign-darwin -- "$@")"
39+
args="$(getopt -o "" -l version:,os:,arch:,output:,slim,agpl,sign-darwin,sign-windows -- "$@")"
3940
eval set -- "$args"
4041
while true; do
4142
case "$1" in
@@ -68,6 +69,10 @@ while true; do
6869
sign_darwin=1
6970
shift
7071
;;
72+
--sign-windows)
73+
sign_windows=1
74+
shift
75+
;;
7176
--)
7277
shift
7378
break
@@ -93,6 +98,20 @@ if [[ "$sign_darwin" == 1 ]]; then
9398
requiredenvs AC_CERTIFICATE_FILE AC_CERTIFICATE_PASSWORD_FILE
9499
fi
95100

101+
if [[ "$sign_windows" == 1 ]]; then
102+
dependencies osslsigncode
103+
requiredenvs AUTHENTICODE_CERTIFICATE_FILE AUTHENTICODE_CERTIFICATE_PASSWORD_FILE
104+
fi
105+
106+
if [[ "$os" == "windows" ]]; then
107+
goversioninfo -platform-specific=true \
108+
-product-version=${version} \
109+
-icon=cmd/coder/coder.exe.ico \
110+
-manifest=cmd/coder/coder.exe.manifest \
111+
cmd/coder/versioninfo.json
112+
fi
113+
114+
96115
build_args=(
97116
-ldflags "-s -w -X 'github.com/coder/coder/buildinfo.tag=$version'"
98117
)
@@ -134,4 +153,8 @@ if [[ "$sign_darwin" == 1 ]] && [[ "$os" == "darwin" ]]; then
134153
execrelative ./sign_darwin.sh "$output_path" 1>&2
135154
fi
136155

156+
if [[ "$sign_windows" == 1 ]] && [[ "$os" == "windows" ]]; then
157+
execrelative ./sign_windows.sh "$output_path" 1>&2
158+
fi
159+
137160
echo "$output_path"

scripts/sign_windows.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
# This script signs the provided windows binary with a X.509 certificate and
5+
# it's associated private key.
6+
#
7+
# Usage: ./sign_windows.sh path/to/binary
8+
#
9+
# On success, the input file will be signed using the X.509 certificate.
10+
#
11+
# You can check if a binary is signed by running the following command:
12+
# osslsigncode verify path/to/binary
13+
#
14+
# Depends on the osslsigncode utility. Requires the following environment variables
15+
# to be set:
16+
# - $AUTHENTICODE_CERTIFICATE_FILE: The path to the X5.09 certificate file.
17+
# - $AUTHENTICODE_CERTIFICATE_PASSWORD_FILE: The path to the file containing the password
18+
# for the X5.09 certificate.
19+
20+
set -euo pipefail
21+
# shellcheck source=scripts/lib.sh
22+
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
23+
24+
# Check dependencies
25+
dependencies osslsigncode
26+
requiredenvs AUTHENTICODE_CERTIFICATE_FILE AUTHENTICODE_CERTIFICATE_PASSWORD_FILE
27+
28+
osslsigncode sign \
29+
-pkcs12 "$AUTHENTICODE_CERTIFICATE_FILE" \
30+
-readpass "$AUTHENTICODE_CERTIFICATE_PASSWORD_FILE" \
31+
-n "Coder" \
32+
-i "https://coder.com" \
33+
-t "http://timestamp.sectigo.com"
34+
-in "$@" \
35+
-out "$@" \
36+
1>&2
37+
38+
osslsigncodeosslsigncode verify "$@" 1>&2

0 commit comments

Comments
 (0)