@@ -46,7 +46,7 @@ export class Install {
46
46
this . _standalone = opts ?. standalone ;
47
47
}
48
48
49
- public async download ( version : string , dest ?: string ) : Promise < string > {
49
+ public async download ( version : string ) : Promise < string > {
50
50
const release : GitHubRelease = await Install . getRelease ( version ) ;
51
51
const fversion = release . tag_name . replace ( / ^ v + | v + $ / g, '' ) ;
52
52
core . debug ( `Install.download version: ${ fversion } ` ) ;
@@ -62,15 +62,10 @@ export class Install {
62
62
}
63
63
core . debug ( `Install.download toolPath: ${ toolPath } ` ) ;
64
64
65
- dest = dest || ( ( await this . isStandalone ( ) ) ? this . context . tmpDir ( ) : Docker . configDir ) ;
66
- core . debug ( `Install.download dest: ${ dest } ` ) ;
67
- if ( await this . isStandalone ( ) ) {
68
- return this . setStandalone ( toolPath , dest ) ;
69
- }
70
- return this . setPlugin ( toolPath , dest ) ;
65
+ return toolPath ;
71
66
}
72
67
73
- public async build ( gitContext : string , dest ?: string ) : Promise < string > {
68
+ public async build ( gitContext : string ) : Promise < string > {
74
69
// eslint-disable-next-line prefer-const
75
70
let [ repo , ref ] = gitContext . split ( '#' ) ;
76
71
if ( ref . length == 0 ) {
@@ -103,12 +98,38 @@ export class Install {
103
98
} ) ;
104
99
}
105
100
101
+ return toolPath ;
102
+ }
103
+
104
+ public async installStandalone ( toolPath : string , dest ?: string ) : Promise < string > {
105
+ dest = dest || this . context . tmpDir ( ) ;
106
+ const toolBinPath = path . join ( toolPath , os . platform ( ) == 'win32' ? 'docker-buildx.exe' : 'docker-buildx' ) ;
107
+ const binDir = path . join ( dest , 'bin' ) ;
108
+ if ( ! fs . existsSync ( binDir ) ) {
109
+ fs . mkdirSync ( binDir , { recursive : true } ) ;
110
+ }
111
+ const filename : string = os . platform ( ) == 'win32' ? 'buildx.exe' : 'buildx' ;
112
+ const buildxPath : string = path . join ( binDir , filename ) ;
113
+ fs . copyFileSync ( toolBinPath , buildxPath ) ;
114
+ fs . chmodSync ( buildxPath , '0755' ) ;
115
+ core . addPath ( binDir ) ;
116
+ core . debug ( `Install.installStandalone buildxPath: ${ buildxPath } ` ) ;
117
+ return buildxPath ;
118
+ }
119
+
120
+ public async installPlugin ( toolPath : string , dest ?: string ) : Promise < string > {
106
121
dest = dest || Docker . configDir ;
107
- core . debug ( `Install.build dest: ${ dest } ` ) ;
108
- if ( await this . isStandalone ( ) ) {
109
- return this . setStandalone ( toolPath , dest ) ;
122
+ const toolBinPath = path . join ( toolPath , os . platform ( ) == 'win32' ? 'docker-buildx.exe' : 'docker-buildx' ) ;
123
+ const pluginsDir : string = path . join ( dest , 'cli-plugins' ) ;
124
+ if ( ! fs . existsSync ( pluginsDir ) ) {
125
+ fs . mkdirSync ( pluginsDir , { recursive : true } ) ;
110
126
}
111
- return this . setPlugin ( toolPath , dest ) ;
127
+ const filename : string = os . platform ( ) == 'win32' ? 'docker-buildx.exe' : 'docker-buildx' ;
128
+ const pluginPath : string = path . join ( pluginsDir , filename ) ;
129
+ fs . copyFileSync ( toolBinPath , pluginPath ) ;
130
+ fs . chmodSync ( pluginPath , '0755' ) ;
131
+ core . debug ( `Install.installPlugin pluginPath: ${ pluginPath } ` ) ;
132
+ return pluginPath ;
112
133
}
113
134
114
135
private async buildCommand ( gitContext : string , outputDir : string ) : Promise < { args : Array < string > ; command : string } > {
@@ -148,35 +169,6 @@ export class Install {
148
169
return standalone ;
149
170
}
150
171
151
- private async setStandalone ( toolPath : string , dest : string ) : Promise < string > {
152
- const toolBinPath = path . join ( toolPath , os . platform ( ) == 'win32' ? 'docker-buildx.exe' : 'docker-buildx' ) ;
153
- const binDir = path . join ( dest , 'bin' ) ;
154
- if ( ! fs . existsSync ( binDir ) ) {
155
- fs . mkdirSync ( binDir , { recursive : true } ) ;
156
- }
157
- const filename : string = os . platform ( ) == 'win32' ? 'buildx.exe' : 'buildx' ;
158
- const buildxPath : string = path . join ( binDir , filename ) ;
159
- fs . copyFileSync ( toolBinPath , buildxPath ) ;
160
- fs . chmodSync ( buildxPath , '0755' ) ;
161
- core . addPath ( binDir ) ;
162
- core . debug ( `Install.setStandalone buildxPath: ${ buildxPath } ` ) ;
163
- return buildxPath ;
164
- }
165
-
166
- private async setPlugin ( toolPath : string , dest : string ) : Promise < string > {
167
- const toolBinPath = path . join ( toolPath , os . platform ( ) == 'win32' ? 'docker-buildx.exe' : 'docker-buildx' ) ;
168
- const pluginsDir : string = path . join ( dest , 'cli-plugins' ) ;
169
- if ( ! fs . existsSync ( pluginsDir ) ) {
170
- fs . mkdirSync ( pluginsDir , { recursive : true } ) ;
171
- }
172
- const filename : string = os . platform ( ) == 'win32' ? 'docker-buildx.exe' : 'docker-buildx' ;
173
- const pluginPath : string = path . join ( pluginsDir , filename ) ;
174
- fs . copyFileSync ( toolBinPath , pluginPath ) ;
175
- fs . chmodSync ( pluginPath , '0755' ) ;
176
- core . debug ( `Install.setPlugin pluginPath: ${ pluginPath } ` ) ;
177
- return pluginPath ;
178
- }
179
-
180
172
private async fetchBinary ( version : string ) : Promise < string > {
181
173
const targetFile : string = os . platform ( ) == 'win32' ? 'docker-buildx.exe' : 'docker-buildx' ;
182
174
const downloadURL = util . format ( 'https://github.com/docker/buildx/releases/download/v%s/%s' , version , this . filename ( version ) ) ;
0 commit comments