-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
157 lines (146 loc) · 7.04 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: 'Generate version'
description: |
A GitHub action for reading, bumping, generating, formatting applications versions in release pipelines.
author: 'Vadzim Hushchanskou'
branding:
icon: 'hash'
color: 'gray-dark'
inputs:
# Version sources
version-source:
description: |
A source of a CURRENT_VERSION, might be:
- file
- variable
required: true
default: 'variable'
version:
description: 'A version variable for version source'
required: false
version-file:
description: 'A path to a file with which holds a version'
required: false
version-file-extraction-pattern:
description: |
A RegEx to extract version from a version-source file. Should either match a full version, or return it as the
first group. E.G:
- '(?<=version=).+' - pattern match, e.g: 'version=5.0.3-SNAPSHOT' will extract matched string '5.0.3-SNAPSHOT'
- '"version":\s*"([^"]+)"' - group match, will extract the first group. e.g: '"version": "1.0.0",' to '1.0.0'
In case if there are groups in a pattern the first group will be extracted.
required: false
default: '.+'
# Release version
release-version-cut-snapshot:
description: 'Remove "SNAPSHOT" suffix from source version'
required: false
default: 'true'
release-version-cut-prerelease:
description: 'Remove prerelease part from source version'
required: false
default: 'false'
release-version-cut-build-metadata:
description: 'Remove build metadata suffix from source version'
required: false
default: 'true'
# Build metadata
release-version-generate-build-metadata:
description: 'Put build metadata (release date, commit sha, etc.) into result RELEASE_VERSION'
required: false
default: 'false'
release-version-build-metadata-pattern:
description: |
Format pattern for build metadata. EG: "build.{date[YYYY-MM-dd]}.{hash[0, 6]}". It is also possible not to
customize variable outputs omitting square braces ([]) or even not to use any variables. Supported variables:
- date[date_format]: a current date in UTC or time set in 'release-version-build-metadata-datetime' variable.
Supports formatting included in square braces ([]). The date format will be applied by "Moment.js". Default format
is ['YYYY-MM-DD'].
Library: https://momentjs.com/
- hash[begin_index_inclusive, end_index_exclusive]: a commit hash, which triggered this build. You can shorten
the hash by specifying begin and end characters indexes included in square braces ([]), separated by a comma.
Default begin, end values are: [0, 8].
required: false
default: 'build.{date}.{hash}'
release-version-build-metadata-datetime:
description: 'A time stamp in ISO format to put into a build metadata string, by default the action uses current time in UTC timezone'
required: false
# Next version
next-version-increment-major:
description: 'Increment major version in result NEXT_VERSION, resets all other versions to "0" and prerelease to "1" if found'
required: false
default: 'false'
next-version-increment-minor:
description: 'Increment minor version in result NEXT_VERSION, resets patch to "0" and prerelease to "1" if found'
required: false
default: 'false'
next-version-increment-patch:
description: 'Increment patch version in result NEXT_VERSION, resets prerelease to "1" if found'
required: false
default: 'false'
next-version-increment-prerelease:
description: 'Increment prerelease version in result NEXT_VERSION'
required: false
default: 'false'
# Next version additional params
next-version-cut-prerelease:
description: 'Remove prerelease part from source version'
required: false
default: 'false'
next-version-cut-build-metadata:
description: 'Remove build metadata suffix from source version'
required: false
default: 'true'
next-version-put-build-metadata:
description: 'Put build metadata (release date, commit sha, etc.) into result NEXT_VERSION. Will be the same as for RELEASE_VERSION'
required: false
default: 'false'
# Other stuff
data-extract:
required: false
default: 'false'
description: |
Enable data extraction mechanism.
Example:
data-extract: true
data-extract-name: 'first_variable'
data-extract-paths: '/path/to/file'
data-extract-patterns: '/(?<=variable.name=).+/i'
There are several use cases depending on RegEx format and flags:
* RegEx Match only - As on example, above. Variable name in 'data-extract-name' parameter will be used 'as is',
variable value will be set on matched text. Extraction will fail if 'data-extract-name' is not set.
* One group - Variable name in 'data-extract-name' parameter will be used 'as is', variable value will be set on
group value. Extraction will fail if 'data-extract-name' is not set.
* Two or more groups - If 'data-extract-name' value is set then the first group will be used as value, and other
groups will be ignored, if it's not set, then the first group will used as variable name and the second group
will be used as value.
* Multiple match (multiple RegEx, 'g' flag in RegEx is set, etc) - If 'data-extract-name' value is set the action
will extract all RegEx matches and export variables with underscore and variable index as suffix, except the
first one.
E.G.: first_variable -> FIRST_VARIABLE, FIRST_VARIABLE_1, etc; If 'data-extract-name' value is not set then
two groups in every RegEx is a requirement, the first group will used as variable name and the second group will
be used as value. If multiple files have the same variable names, output values will be overwritten with the
latter matches.
Variable name convert rules:
* Spaces and symbols '-', even multiple in a row, will be converted to single symbol '_';
* Other special characters except digits and letters will be cut off;
* The variable name will be converted to upper case.
data-extract-name:
required: false
description: |
Variable name to which extracted data will be placed, standard variable name conversion rules are also applied to
this field. If not set it will be extracted from RegEx groups. See usage use cases above.
data-extract-paths:
required: false
description: 'Semicolon (";") separated path list of files which to use to extract data'
data-extract-patterns:
required: false
description: 'Semicolon (";") separated RegEx pattern list wrapped with "/" symbols, with flags'
outputs:
CURRENT_VERSION:
description: 'A version grabbed from a variable or a file without any changes'
RELEASE_VERSION:
description: 'A version prepared for release tagging, usually with removed "SNAPSHOT" suffix and optionally with a build metadata'
NEXT_VERSION:
description: 'A version prepared for pushing into a repository instead of "CURRENT_VERSION" after release, usually incremented by 1'
runs:
using: 'node20'
main: 'build/index.js'