mirror of
				https://github.com/ButlerLogic/action-autotag.git
				synced 2025-10-31 07:16:25 +07:00 
			
		
		
		
	feat: restrict version to tag
This commit is contained in:
		 Tomasz Pluskiewicz
					Tomasz Pluskiewicz
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							ade8d2e19b
						
					
				
				
					commit
					96636b210d
				
			
							
								
								
									
										15
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								README.md
									
									
									
									
									
								
							| @ -225,6 +225,21 @@ Useful for projects where the version number may be output by a previous action. | ||||
|     version: "${{ steps.previous_step.outputs.version }}" | ||||
| ``` | ||||
|  | ||||
| ### minVersion | ||||
|  | ||||
| Set the minimum version which would be used to create a tag.  | ||||
|  | ||||
| The default value (`0.0.1`) prevents a `0.0.0` from being created. This can also be used when introducing Autotag to a repository which has already tagged. | ||||
|  | ||||
| For example, if the version `0.1.0` would already have been published, set the `minVersion` to the next patch to preent a duplicate tag. | ||||
|  | ||||
| ```yaml | ||||
| - uses: butlerlogic/action-autotag@1.0.0 | ||||
|   with: | ||||
|     GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||||
|     minVersion: "0.1.1" | ||||
| ``` | ||||
|  | ||||
| ## Developer Notes | ||||
|  | ||||
| If you are building an action that runs after this one, be aware this action produces several [outputs](https://help.github.com/en/articles/metadata-syntax-for-github-actions#outputs): | ||||
|  | ||||
| @ -31,6 +31,10 @@ inputs: | ||||
|   version: | ||||
|     description: Explicitly set the version here instead of automatically detecting from `package.json`. Useful for non-JavaScript projects where version may be output by a previous action. | ||||
|     required: false | ||||
|   minVersion: | ||||
|     description: Minimum version required to create a tag. By default it will prevent a version `0.0.0` to be tagged. Also useful when introducing Autotag to an existing repo, to start auto-tagging from a specific version | ||||
|     required: false | ||||
|     default: '0.0.1' | ||||
|   regex_pattern: | ||||
|     description: An optional attribute containing the regular expression used to extract the version number. | ||||
|     required: false | ||||
|  | ||||
| @ -48,6 +48,12 @@ async function run () { | ||||
|     if (!version) { | ||||
|       throw new Error(`No version identified${msg}`) | ||||
|     } | ||||
|      | ||||
|     const minVersion = core.getInput('minVersion', { required: false }) | ||||
|     if (version < minVersion) { | ||||
|       core.warning(`Version "${version}" is lower than minimum "${minVersion}"`) | ||||
|       return | ||||
|     } | ||||
|  | ||||
|     core.warning(`Recognized "${version}"${msg}`) | ||||
|     core.setOutput('version', version) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user