-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
58 lines (54 loc) · 2.1 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
name: Version
author: TrueCommerce
description: A composite GitHub action used to calculate the next (or current in the case of releases) SemVer version number during a build.
inputs:
release-branch:
description: "The branch where release tags are added. Usually main or master. Default is master."
required: false
default: master
outputs:
semver:
description: "Format: {major}.{minor}.{patch}-{branch}.{commits}.{hash}"
value: ${{ steps.version.outputs.value }}
semverWithBuildMetadata:
description: "Format: {major}.{minor}.{patch}-{branch}.{commits}.{hash}+{metadata}"
value: "${{ steps.version.outputs.value }}+${{ steps.metadata.outputs.value }}"
semverMajor:
description: "Format: {major}"
value: ${{ steps.semver-utils.outputs.major }}
semverMajorMinor:
description: "Format: {major}.{minor}"
value: "${{ steps.semver-utils.outputs.major }}.${{ steps.semver-utils.outputs.minor }}"
semverMajorMinorPatch:
description: "Format: {major}.{minor}.{patch}"
value: "${{ steps.semver-utils.outputs.major }}.${{ steps.semver-utils.outputs.minor }}.${{ steps.semver-utils.outputs.patch }}"
runs:
using: "composite"
steps:
- if: github.event_name != 'release'
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- if: github.event_name != 'release'
id: git-version
uses: codacy/[email protected]
with:
release-branch: ${{ inputs.release-branch }}
major-identifier: '/semver:\s*(major|breaking)/'
minor-identifier: '/semver:\s*(minor|feature)/'
- id: version
uses: haya14busa/[email protected]
with:
cond: ${{ github.event_name == 'release' }}
if_true: ${{ github.ref_name }}
if_false: ${{ steps.git-version.outputs.version }}
- id: semver-utils
uses: madhead/semver-utils@latest
with:
version: ${{ steps.version.outputs.value }}
- id: metadata
uses: actions/[email protected]
with:
script: |
core.setOutput("value", context.runNumber.toString().padStart(4, 0));