@@ -18,31 +18,15 @@ import "log"
1818import "os"
1919import "os/exec"
2020import "path/filepath"
21+ import "runtime"
2122import "strings"
2223import "time"
23- import _ "embed"
2424
25- //go:embed certificates/quick-lint-js.cer
26- var AppleCodesignCertificate []byte
27-
28- //go:embed certificates/DigiCertAssuredIDRootCA_comb.crt.pem
29- var DigiCertCertificate []byte
30-
31- //go:embed certificates/DigiCertTrustedRootG4.crt
32- var DigiCertCertificate2 []byte
33-
34- //go:embed apple/quick-lint-js.csreq
35- var AppleCodeSigningRequirements []byte
36-
37- //go:embed certificates/quick-lint-js.gpg.key
38- var QLJSGPGKey []byte
25+ // Path to the 'dist' directory containing this file (sign-release.go).
26+ var DistPath string
3927
4028type SigningStuff struct {
41- Certificate []byte
42- TimestampCertificate []byte
43- TimestampCertificate2 []byte
44- GPGKey []byte
45- RelicConfigPath string
29+ RelicConfigPath string
4630}
4731
4832// Key: SHA256 hash of original file
@@ -59,11 +43,6 @@ func main() {
5943
6044 defer RemoveTempDirs ()
6145
62- signingStuff .Certificate = AppleCodesignCertificate
63- signingStuff .TimestampCertificate = DigiCertCertificate
64- signingStuff .TimestampCertificate2 = DigiCertCertificate2
65- signingStuff .GPGKey = QLJSGPGKey
66-
6746 flag .StringVar (& signingStuff .RelicConfigPath , "RelicConfig" , "" , "" )
6847 flag .Parse ()
6948 if flag .NArg () != 2 {
@@ -76,6 +55,12 @@ func main() {
7655 log .Fatal (err )
7756 }
7857
58+ _ , scriptPath , _ , ok := runtime .Caller (0 )
59+ if ! ok {
60+ panic ("could not determine path of .go file" )
61+ }
62+ DistPath = filepath .Dir (scriptPath )
63+
7964 sourceDir := flag .Args ()[0 ]
8065 destinationDir := flag .Args ()[1 ]
8166
@@ -797,11 +782,7 @@ func RelicFile(inFilePath string, outFilePath string, signingType RelicSigningTy
797782 }
798783 switch signingType {
799784 case RelicSignApple :
800- requirementsPath , err := MakeTempFileWithContent (AppleCodeSigningRequirements )
801- if err != nil {
802- return err
803- }
804- signCommand = append (signCommand , "--requirements" , requirementsPath )
785+ signCommand = append (signCommand , "--requirements" , filepath .Join (DistPath , "apple/quick-lint-js.csreq" ))
805786 signCommand = append (signCommand , "--bundle-id" , "quick-lint-js" )
806787 signCommand = append (signCommand , "--key" , "windows_key" )
807788 case RelicSignPGP :
@@ -883,27 +864,11 @@ func RelicVerifyDetachedFile(filePath string, detachedSignaturePath string) erro
883864}
884865
885866func GetRelicVerifyCertOptions () ([]string , error ) {
886- certificateFile , err := MakeTempFileWithContent (signingStuff .Certificate )
887- if err != nil {
888- return nil , err
889- }
890- timestampCertificateFile , err := MakeTempFileWithContent (signingStuff .TimestampCertificate )
891- if err != nil {
892- return nil , err
893- }
894- timestampCertificate2File , err := MakeTempFileWithContent (signingStuff .TimestampCertificate2 )
895- if err != nil {
896- return nil , err
897- }
898- gpgCertificateFile , err := MakeTempFileWithContent (signingStuff .GPGKey )
899- if err != nil {
900- return nil , err
901- }
902867 return []string {
903- "--cert" , certificateFile ,
904- "--cert" , timestampCertificateFile ,
905- "--cert" , timestampCertificate2File ,
906- "--cert" , gpgCertificateFile ,
868+ "--cert" , filepath . Join ( DistPath , "certificates/quick-lint-js.cer" ) ,
869+ "--cert" , filepath . Join ( DistPath , "certificates/DigiCertAssuredIDRootCA_comb.crt.pem" ) ,
870+ "--cert" , filepath . Join ( DistPath , "certificates/DigiCertTrustedRootG4.crt" ) ,
871+ "--cert" , filepath . Join ( DistPath , "certificates/quick-lint-js.gpg.key" ) ,
907872 }, nil
908873}
909874
0 commit comments