Skip to content

Commit 2e33eaf

Browse files
authored
Merge pull request #37 from HardNorth/develop
Release
2 parents 3a10d96 + 52c4505 commit 2e33eaf

9 files changed

Lines changed: 734 additions & 608 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
env:
1212
VERSION_FILE: package.json
13+
ADDITIONAL_VERSION_FILE: package-lock.json
1314
VERSION_EXTRACT_PATTERN: '"version": "([^"]+)",'
1415
VERSION_REPLACE_PATTERN: '"version": "\1",'
1516
GH_USER_NAME: github.actor
@@ -39,7 +40,7 @@ jobs:
3940
node-version: 12.x
4041

4142
- name: Generate versions
42-
uses: HardNorth/github-version-generate@v1.1.1
43+
uses: HardNorth/github-version-generate@v1.1.2
4344
with:
4445
version-source: file
4546
version-file: ${{ env.VERSION_FILE }}
@@ -133,8 +134,12 @@ jobs:
133134
export CURRENT_VERSION_VALUE=`echo '${{ env.CURRENT_VERSION }}' | sed -E 's/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/'`
134135
export NEXT_VERSION_VALUE=`echo '${{ env.NEXT_VERSION }}' | sed -E 's/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/'`
135136
sed "s/${CURRENT_VERSION_VALUE}/${NEXT_VERSION_VALUE}/g" ${{ env.VERSION_FILE }} > ${{ env.VERSION_FILE }}${{ env.TMP_SUFFIX }}
137+
sed "s/${CURRENT_VERSION_VALUE}/${NEXT_VERSION_VALUE}/g" ${{ env.ADDITIONAL_VERSION_FILE }} > ${{ env.ADDITIONAL_VERSION_FILE }}${{ env.TMP_SUFFIX }}
136138
rm ${{ env.VERSION_FILE }}
137139
mv ${{ env.VERSION_FILE }}${{ env.TMP_SUFFIX }} ${{ env.VERSION_FILE }}
140+
rm ${{ env.ADDITIONAL_VERSION_FILE }}
141+
mv ${{ env.ADDITIONAL_VERSION_FILE }}${{ env.TMP_SUFFIX }} ${{ env.ADDITIONAL_VERSION_FILE }}
138142
git add ${{ env.VERSION_FILE }}
143+
git add ${{ env.ADDITIONAL_VERSION_FILE }}
139144
git commit -m "Version update"
140145
git push

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Added
5+
- [Issue #24](https://github.com/HardNorth/github-version-generate/issues/24) Data extraction, by @HardNorth
6+
- [Issue #31](https://github.com/HardNorth/github-version-generate/issues/31) Major, Minor, Patch, Prerelease, Buildmetadata fragments export, by @HardNorth
7+
- [Issue #34](https://github.com/HardNorth/github-version-generate/issues/34) `NEXT_RELEASE_VERSION` variable export, by @HardNorth
8+
### Changed
9+
- Minor version updated on `1.2`
10+
- Some security fixes, by @dependabot
411

512
## [1.1.2]
613
### Changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Version generation for GitHub Actions
2-
![CI Build](https://github.com/HardNorth/github-version-generate/workflows/CI%20Build/badge.svg?branch=master)
2+
[![CI Build](https://github.com/HardNorth/github-version-generate/actions/workflows/ci.yml/badge.svg)](https://github.com/HardNorth/github-version-generate/actions/workflows/ci.yml)
33
[![License](https://img.shields.io/badge/License-Apache%202.0-brightgreen.svg)](https://opensource.org/licenses/Apache-2.0)
44

55

README_TEMPLATE.md

Lines changed: 131 additions & 58 deletions
Large diffs are not rendered by default.

action.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ inputs:
4444
description: 'Remove build metadata suffix from source version'
4545
required: false
4646
default: 'true'
47+
4748
# Build metadata
4849
release-version-generate-build-metadata:
4950
description: 'Put build metadata (release date, commit sha, etc.) into result RELEASE_VERSION'
@@ -66,7 +67,6 @@ inputs:
6667
description: 'A time stamp in ISO format to put into a build metadata string, by default the action uses current time in UTC timezone'
6768
required: false
6869

69-
7070
# Next version
7171
next-version-increment-major:
7272
description: 'Increment major version in result NEXT_VERSION, resets all other versions to "0" and prerelease to "1" if found'
@@ -99,6 +99,51 @@ inputs:
9999
required: false
100100
default: 'false'
101101

102+
# Other stuff
103+
data-extract:
104+
required: false
105+
default: 'false'
106+
description: |
107+
Enable data extraction mechanism.
108+
109+
Example:
110+
data-extract: true
111+
data-extract-name: 'first_variable'
112+
data-extract-paths: '/path/to/file'
113+
data-extract-patterns: '/(?<=variable.name=).+/i'
114+
115+
There are several use cases depending on RegEx format and flags:
116+
* RegEx Match only - As on example, above. Variable name in 'data-extract-name' parameter will be used 'as is',
117+
variable value will be set on matched text. Extraction will fail if 'data-extract-name' is not set.
118+
* One group - Variable name in 'data-extract-name' parameter will be used 'as is', variable value will be set on
119+
group value. Extraction will fail if 'data-extract-name' is not set.
120+
* Two or more groups - If 'data-extract-name' value is set then the first group will be used as value, and other
121+
groups will be ignored, if it's not set, then the first group will used as variable name and the second group
122+
will be used as value.
123+
* Multiple match (multiple RegEx, 'g' flag in RegEx is set, etc) - If 'data-extract-name' value is set the action
124+
will extract all RegEx matches and export variables with underscore and variable index as suffix, except the
125+
first one.
126+
E.G.: first_variable -> FIRST_VARIABLE, FIRST_VARIABLE_1, etc; If 'data-extract-name' value is not set then
127+
two groups in every RegEx is a requirement, the first group will used as variable name and the second group will
128+
be used as value. If multiple files have the same variable names, output values will be overwritten with the
129+
latter matches.
130+
131+
Variable name convert rules:
132+
* Spaces and symbols '-', even multiple in a row, will be converted to single symbol '_';
133+
* Other special characters except digits and letters will be cut off;
134+
* The variable name will be converted to upper case.
135+
data-extract-name:
136+
required: false
137+
description: |
138+
Variable name to which extracted data will be placed, standard variable name conversion rules are also applied to
139+
this field. If not set it will be extracted from RegEx groups. See usage use cases above.
140+
data-extract-paths:
141+
required: false
142+
description: 'Semicolon (";") separated path list of files which to use to extract data'
143+
data-extract-patterns:
144+
required: false
145+
description: 'Semicolon (";") separated RegEx pattern list wrapped with "/" symbols, with flags'
146+
102147
outputs:
103148
CURRENT_VERSION:
104149
description: 'A version grabbed from a variable or a file without any changes'

0 commit comments

Comments
 (0)