Address latest review feedback
This commit is contained in:
		
							parent
							
								
									998be8d08f
								
							
						
					
					
						commit
						6924f73ee0
					
				
							
								
								
									
										18
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								README.md
									
									
									
									
									
								
							| @ -72,22 +72,26 @@ jobs: | |||||||
|         server-id: github # Value of the distributionManagement/repository/id field of the pom.xml |         server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||||||
|         username: ${{ github.actor }} # username for server authentication |         username: ${{ github.actor }} # username for server authentication | ||||||
|         password: ${{ github.token }} # password or token for authentication |         password: ${{ github.token }} # password or token for authentication | ||||||
|  | 
 | ||||||
|     - name: Build with Maven |     - name: Build with Maven | ||||||
|       run: mvn -B package --file pom.xml |       run: mvn -B package --file pom.xml | ||||||
|  | 
 | ||||||
|     - name: Publish to GitHub Packages Apache Maven |     - name: Publish to GitHub Packages Apache Maven | ||||||
|       run: mvn deploy |       run: mvn deploy | ||||||
|  | 
 | ||||||
|     - name: Set up Apache Maven Central |     - name: Set up Apache Maven Central | ||||||
|       uses: actions/setup-java@v1 |       uses: actions/setup-java@v1 | ||||||
|       with: # running setup-java again overwrites the settings.xml |       with: # running setup-java again overwrites the settings.xml | ||||||
|         java-version: 1.8 |         java-version: 1.8 | ||||||
|         server-id: maven |         server-id: maven | ||||||
|         username: maven_username |         server-username: maven_username | ||||||
|         password: ${{ secrets.MAVEN_CENTRAL_TOKEN }} # password from secrets store |         server-password: ${{ secrets.MAVEN_CENTRAL_TOKEN }} # password from secrets store | ||||||
|  | 
 | ||||||
|     - name: Publish to Apache Maven Central |     - name: Publish to Apache Maven Central | ||||||
|       run: mvn deploy  |       run: mvn deploy  | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ***NOTE: The `settings.xml` file is created in the Actions $HOME directory. If you have an existing `settings.xml` file at that location, it will be overwritten***	 | ***NOTE: The `settings.xml` file is created in the Actions $HOME directory. If you have an existing `settings.xml` file at that location, it will be overwritten. See below for using the `settings-path` to change your `settings.xml` file location.***	 | ||||||
| 
 | 
 | ||||||
| See the help docs on [Publishing a Package](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#publishing-a-package) for more information on the `pom.xml` file. | See the help docs on [Publishing a Package](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#publishing-a-package) for more information on the `pom.xml` file. | ||||||
| 
 | 
 | ||||||
| @ -114,7 +118,7 @@ jobs: | |||||||
|         PASSWORD: ${{ secrets.GITHUB_TOKEN }} |         PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ***NOTE: The `USERNAME` and `PASSWORD` need to correspond to the credentials environment variables used in the publishing section of your `build.gradle`..***	 | ***NOTE: The `USERNAME` and `PASSWORD` need to correspond to the credentials environment variables used in the publishing section of your `build.gradle`.***	 | ||||||
| 
 | 
 | ||||||
| See the help docs on [Publishing a Package with Gradle](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages#example-using-gradle-groovy-for-a-single-package-in-a-repository) for more information on the `build.gradle` configuration file. | See the help docs on [Publishing a Package with Gradle](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages#example-using-gradle-groovy-for-a-single-package-in-a-repository) for more information on the `build.gradle` configuration file. | ||||||
| 
 | 
 | ||||||
| @ -135,11 +139,13 @@ jobs: | |||||||
|       with: |       with: | ||||||
|         java-version: 1.8 |         java-version: 1.8 | ||||||
|         server-id: github # Value of the distributionManagement/repository/id field of the pom.xml |         server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||||||
|         username: ${{ github.actor }} # username for server authentication |         server-username: ${{ github.actor }} # username for server authentication | ||||||
|         password: ${{ github.token }} # password or token for authentication |         server-password: ${{ github.token }} # password or token for authentication | ||||||
|         settings-path: ${{ github.workspace }} # location for the settings.xml file |         settings-path: ${{ github.workspace }} # location for the settings.xml file | ||||||
|  | 
 | ||||||
|     - name: Build with Maven |     - name: Build with Maven | ||||||
|       run: mvn -B package --file pom.xml |       run: mvn -B package --file pom.xml | ||||||
|  | 
 | ||||||
|     - name: Publish to GitHub Packages Apache Maven |     - name: Publish to GitHub Packages Apache Maven | ||||||
|       run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml |       run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml | ||||||
| ``` | ``` | ||||||
|  | |||||||
| @ -23,10 +23,10 @@ inputs: | |||||||
|     description: 'ID of the distributionManagement repository in the pom.xml |     description: 'ID of the distributionManagement repository in the pom.xml | ||||||
|        file.' |        file.' | ||||||
|     required: false |     required: false | ||||||
|   username: |   server-username: | ||||||
|     description: 'Username for authentication to the Apache Maven repository.' |     description: 'Username for authentication to the Apache Maven repository.' | ||||||
|     required: false |     required: false | ||||||
|   password: |   server-password: | ||||||
|     description: 'Password or token for authentication to the Apache Maven |     description: 'Password or token for authentication to the Apache Maven | ||||||
|        repository.' |        repository.' | ||||||
|     required: false |     required: false | ||||||
|  | |||||||
							
								
								
									
										
											BIN
										
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -5,10 +5,11 @@ | |||||||
|   "description": "setup java action", |   "description": "setup java action", | ||||||
|   "main": "dist/index.js", |   "main": "dist/index.js", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "build": "tsc", |     "build": "ncc build src/setup-java.ts", | ||||||
|     "format": "prettier --write **/*.ts", |     "format": "prettier --write **/*.ts", | ||||||
|     "format-check": "prettier --check **/*.ts", |     "format-check": "prettier --check **/*.ts", | ||||||
|     "release": "ncc build lib/setup-java.js && git add -f dist/index.js", |     "prerelease": "npm run-script build", | ||||||
|  |     "release": "git add -f dist/index.js", | ||||||
|     "test": "jest" |     "test": "jest" | ||||||
|   }, |   }, | ||||||
|   "repository": { |   "repository": { | ||||||
|  | |||||||
							
								
								
									
										14
									
								
								src/auth.ts
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/auth.ts
									
									
									
									
									
								
							| @ -57,19 +57,15 @@ export function generate(id: string, username: string, password: string) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function write(directory: string, settings: string) { | async function write(directory: string, settings: string) { | ||||||
|   const options = {encoding: 'utf-8', flag: 'wx'}; // 'wx': Like 'w' but fails if path exists
 |  | ||||||
|   const location = path.join(directory, SETTINGS_FILE); |   const location = path.join(directory, SETTINGS_FILE); | ||||||
|   console.log(`writing ${location}`); |   if (fs.existsSync(location)) { | ||||||
|   try { |  | ||||||
|     return fs.writeFileSync(location, settings, options); |  | ||||||
|   } catch (e) { |  | ||||||
|     if (e.code == 'EEXIST') { |  | ||||||
|     console.warn(`overwriting existing file ${location}`); |     console.warn(`overwriting existing file ${location}`); | ||||||
|  |   } else { | ||||||
|  |     console.log(`writing ${location}`); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   return fs.writeFileSync(location, settings, { |   return fs.writeFileSync(location, settings, { | ||||||
|     encoding: 'utf-8', |     encoding: 'utf-8', | ||||||
|     flag: 'w' |     flag: 'w' | ||||||
|   }); |   }); | ||||||
| } | } | ||||||
|     throw e; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  | |||||||
| @ -19,11 +19,13 @@ async function run() { | |||||||
|     console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); |     console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); | ||||||
| 
 | 
 | ||||||
|     const id = core.getInput('server-id', {required: false}); |     const id = core.getInput('server-id', {required: false}); | ||||||
|     const username = core.getInput('username', {required: false}); |     const username = core.getInput('server-username', {required: false}); | ||||||
|     const password = core.getInput('password', {required: false}); |     const password = core.getInput('server-password', {required: false}); | ||||||
| 
 | 
 | ||||||
|     if (id && username && password) { |     if (id && username && password) { | ||||||
|       await auth.configAuthentication(id, username, password); |       await auth.configAuthentication(id, username, password); | ||||||
|  |     } else if (id || username || password) { | ||||||
|  |       console.warn('All 3 server-(id, username, and password) are required.'); | ||||||
|     } |     } | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     core.setFailed(error.message); |     core.setFailed(error.message); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user