mirror of
				https://github.com/actions-rs/toolchain.git
				synced 2025-10-31 03:03:53 +00:00 
			
		
		
		
	Release v1.0.0
This commit is contained in:
		
							parent
							
								
									c94551433b
								
							
						
					
					
						commit
						8e603f32c5
					
				
							
								
								
									
										11
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| root = true | ||||
| 
 | ||||
| [*] | ||||
| charset = utf-8 | ||||
| end_of_line = lf | ||||
| insert_final_newline = true | ||||
| max_line_length = 80 | ||||
| indent_size =  4 | ||||
| 
 | ||||
| [*.yml] | ||||
| indent_size = 2 | ||||
							
								
								
									
										14
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								README.md
									
									
									
									
									
								
							| @ -1,5 +1,6 @@ | ||||
| # `rustup toolchain` Action | ||||
| 
 | ||||
|  | ||||
| [](https://gitter.im/actions-rs/community) | ||||
| 
 | ||||
| This GitHub Action installs [Rust toolchain](https://github.com/rust-lang/rustup.rs#toolchain-specification). | ||||
| @ -20,7 +21,7 @@ jobs: | ||||
|     steps: | ||||
|       - uses: actions/checkout@master | ||||
|       - name: Install nightly | ||||
|         uses: actions-rs/toolchain@1 | ||||
|         uses: actions-rs/toolchain@v1 | ||||
|         with: | ||||
|             toolchain: nightly | ||||
|             override: true | ||||
| @ -34,7 +35,14 @@ jobs: | ||||
| * `default`: Set installed toolchain as default (executes `rustup toolchain default {TOOLCHAIN}`) | ||||
| * `override`: Set installed toolchain as an override for current directory | ||||
| 
 | ||||
| ## Components | ||||
| 
 | ||||
| If you are going to install `clippy`, `rustfmt` or any other [rustup component](https://rust-lang.github.io/rustup-components-history/), | ||||
| it might not be available in latest `nightly` build; | ||||
| check out the [`actions-rs/components-nightly`](https://github.com/actions-rs/components-nightly) Action, | ||||
| which makes this process much easier. | ||||
| 
 | ||||
| ## Notes | ||||
| 
 | ||||
| As `rustup` is not installed by default for macOS and Windows images at the moment (2019-09-13), | ||||
| this Action will try its best to install it before any other operations. | ||||
| As `rustup` is not installed by default for [macOS environments](https://help.github.com/en/articles/virtual-environments-for-github-actions) | ||||
| at the moment (2019-09-13), this Action will try its best to install it before any other operations. | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| name: 'rustup toolchain' | ||||
| name: 'rust-toolchain' | ||||
| description: 'Install the Rust toolchain' | ||||
| author: 'actions-rs team' | ||||
| branding: | ||||
|  | ||||
							
								
								
									
										2
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -1,6 +1,6 @@ | ||||
| { | ||||
|     "name": "rustup-toolchain", | ||||
|     "version": "0.1.0", | ||||
|     "name": "rust-toolchain", | ||||
|     "version": "1.0.0", | ||||
|     "private": false, | ||||
|     "description": "Install the Rust toolchain", | ||||
|     "main": "lib/main.js", | ||||
|  | ||||
							
								
								
									
										40
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								src/main.ts
									
									
									
									
									
								
							| @ -55,12 +55,12 @@ async function get_rustup(toolchain: string, target?: string): Promise<string> { | ||||
|         case 'darwin': | ||||
|         case 'linux':  // Should be installed already, but just in case
 | ||||
|             const rustupSh = await downloadRustInit('https://sh.rustup.rs', 'rustup-init.sh'); | ||||
|             await do_exec(rustupSh, args); | ||||
|             await exec.exec(rustupSh, args); | ||||
|             break; | ||||
| 
 | ||||
|         case 'win32': | ||||
|             const rustupExe = await downloadRustInit('http://win.rustup.rs', 'rustup-init.exe'); | ||||
|             await do_exec(rustupExe, args); | ||||
|             await exec.exec(rustupExe, args); | ||||
|             break; | ||||
| 
 | ||||
|         default: | ||||
| @ -72,39 +72,31 @@ async function get_rustup(toolchain: string, target?: string): Promise<string> { | ||||
|     return 'rustup'; | ||||
| } | ||||
| 
 | ||||
| async function do_exec(program: string, args: string[]): Promise<number> { | ||||
|     try { | ||||
|         return await exec.exec(program, args); | ||||
|     } catch (error) { | ||||
|         core.setFailed(error.message); | ||||
|         throw error; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| async function run() { | ||||
|     let opts; | ||||
|     try { | ||||
|         opts = args.toolchain_args(); | ||||
|     } catch (error) { | ||||
|         core.setFailed(error.message); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     const opts = args.toolchain_args(); | ||||
|     const rustup = await get_rustup(opts.name, opts.target); | ||||
| 
 | ||||
|     await do_exec(rustup, ['toolchain', 'install', opts.name]); | ||||
|     await exec.exec(rustup, ['toolchain', 'install', opts.name]); | ||||
| 
 | ||||
|     if (opts.default) { | ||||
|         await do_exec(rustup, ['default', opts.name]); | ||||
|         await exec.exec(rustup, ['default', opts.name]); | ||||
|     } | ||||
| 
 | ||||
|     if (opts.override) { | ||||
|         await do_exec(rustup, ['override', 'set', opts.name]); | ||||
|         await exec.exec(rustup, ['override', 'set', opts.name]); | ||||
|     } | ||||
| 
 | ||||
|     if (opts.target) { | ||||
|         await do_exec(rustup, ['target', 'add', '--toolchain', opts.name, opts.target]); | ||||
|         await exec.exec(rustup, ['target', 'add', '--toolchain', opts.name, opts.target]); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| run(); | ||||
| async function main() { | ||||
|     try { | ||||
|         await run(); | ||||
|     } catch (error) { | ||||
|         core.setFailed(error.message); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| main(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user