parent
							
								
									945e912039
								
							
						
					
					
						commit
						96923a5a7f
					
				
					 2 changed files with 82 additions and 40 deletions
				
			
		
							
								
								
									
										21
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -36,6 +36,26 @@ async function downloadZig (version) {
 | 
				
			||||||
    win32: 'zip'
 | 
					    win32: 'zip'
 | 
				
			||||||
  }[os.platform()]
 | 
					  }[os.platform()]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (version.includes('+')) {
 | 
				
			||||||
 | 
					    // use exact commit hash
 | 
				
			||||||
 | 
					    const addrhost = {
 | 
				
			||||||
 | 
					      linux: 'linux-x86_64',
 | 
				
			||||||
 | 
					      darwin: 'macos-x86_64',
 | 
				
			||||||
 | 
					      win32: 'windows-x86_64'
 | 
				
			||||||
 | 
					    }[os.platform()]
 | 
				
			||||||
 | 
					    const downloadUrl = `https://ziglang.org/builds/zig-${addrhost}-${version}.${ext}`
 | 
				
			||||||
 | 
					    const variantName = `zig-${addrhost}-${version}`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const downloadPath = await cache.downloadTool(downloadUrl)
 | 
				
			||||||
 | 
					    const zigPath = ext === 'zip'
 | 
				
			||||||
 | 
					      ? await cache.extractZip(downloadPath)
 | 
				
			||||||
 | 
					      : await cache.extractTar(downloadPath, undefined, 'x')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const binPath = path.join(zigPath, variantName)
 | 
				
			||||||
 | 
					    const cachePath = await cache.cacheDir(binPath, 'zig', variantName)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return cachePath
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
    const index = await getJSON({ url: 'https://ziglang.org/download/index.json' })
 | 
					    const index = await getJSON({ url: 'https://ziglang.org/download/index.json' })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const availableVersions = Object.keys(index)
 | 
					    const availableVersions = Object.keys(index)
 | 
				
			||||||
| 
						 | 
					@ -60,6 +80,7 @@ async function downloadZig (version) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return cachePath
 | 
					    return cachePath
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function main () {
 | 
					async function main () {
 | 
				
			||||||
  const version = actions.getInput('version') || '0.5.0'
 | 
					  const version = actions.getInput('version') || '0.5.0'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										21
									
								
								index.js
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								index.js
									
										
									
									
									
								
							| 
						 | 
					@ -29,6 +29,26 @@ async function downloadZig (version) {
 | 
				
			||||||
    win32: 'zip'
 | 
					    win32: 'zip'
 | 
				
			||||||
  }[os.platform()]
 | 
					  }[os.platform()]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (version.includes('+')) {
 | 
				
			||||||
 | 
					    // use exact commit hash
 | 
				
			||||||
 | 
					    const addrhost = {
 | 
				
			||||||
 | 
					      linux: 'linux-x86_64',
 | 
				
			||||||
 | 
					      darwin: 'macos-x86_64',
 | 
				
			||||||
 | 
					      win32: 'windows-x86_64'
 | 
				
			||||||
 | 
					    }[os.platform()]
 | 
				
			||||||
 | 
					    const downloadUrl = `https://ziglang.org/builds/zig-${addrhost}-${version}.${ext}`
 | 
				
			||||||
 | 
					    const variantName = `zig-${addrhost}-${version}`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const downloadPath = await cache.downloadTool(downloadUrl)
 | 
				
			||||||
 | 
					    const zigPath = ext === 'zip'
 | 
				
			||||||
 | 
					      ? await cache.extractZip(downloadPath)
 | 
				
			||||||
 | 
					      : await cache.extractTar(downloadPath, undefined, 'x')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const binPath = path.join(zigPath, variantName)
 | 
				
			||||||
 | 
					    const cachePath = await cache.cacheDir(binPath, 'zig', variantName)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return cachePath
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
    const index = await getJSON({ url: 'https://ziglang.org/download/index.json' })
 | 
					    const index = await getJSON({ url: 'https://ziglang.org/download/index.json' })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const availableVersions = Object.keys(index)
 | 
					    const availableVersions = Object.keys(index)
 | 
				
			||||||
| 
						 | 
					@ -53,6 +73,7 @@ async function downloadZig (version) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return cachePath
 | 
					    return cachePath
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function main () {
 | 
					async function main () {
 | 
				
			||||||
  const version = actions.getInput('version') || '0.5.0'
 | 
					  const version = actions.getInput('version') || '0.5.0'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue