-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathaction.yml
More file actions
96 lines (92 loc) · 3.57 KB
/
action.yml
File metadata and controls
96 lines (92 loc) · 3.57 KB
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
name: Git Version
author: "Codacy"
description: 'Semver versioning based on the git history and commit messages of your repository.'
branding:
icon: 'git-branch'
color: 'gray-dark'
inputs:
tool-version:
description: 'The version of the tool to be ran'
required: true
default: latest
release-branch:
description: 'The name of the release branch'
required: true
default: master
dev-branch:
description: 'The name of the dev branch'
required: true
default: dev
minor-identifier:
description: 'The string or regex to identify a minor release commit'
required: true
default: 'feature:'
major-identifier:
description: 'The string or regex to identify a major release commit'
required: true
default: 'breaking:'
skip-prerelease:
description: 'Skip prerelease part of the version. When true, release-branch and dev-branch are effectively ignored'
required: true
default: 'false'
prefix:
description: 'The prefix to use in the version'
required: false
log-paths:
description: 'The paths to be used to calculate changes (comma-separated)'
required: false
default: ./
outputs:
version:
description: 'The value of the new pre-calculated tag'
value: ${{ steps.version.outputs.version }}
non-prefixed-version:
description: 'The value of the new pre-calculated tag without the prefix'
value: ${{ steps.version.outputs.non-prefixed-version }}
previous-version:
description: 'Contains the value of previous tag, before calculating a new one'
value: ${{ steps.previous-version.outputs.previous-version }}
runs:
using: "composite"
steps:
- shell: bash
run: |
set -eo pipefail
if [ "${{ inputs.tool-version }}" = "latest" ]; then
download_url="$(curl -Ls https://api.github.com/repos/codacy/git-version/releases/latest | jq -r .assets[0].browser_download_url)"
else
download_url="https://github.com/codacy/git-version/releases/download/${{ inputs.tool-version }}/git-version"
fi
curl -Ls "$download_url" > /usr/local/bin/git-version
chmod +x /usr/local/bin/git-version
- id: previous-version
shell: bash
run: |
set -eo pipefail
export PREVIOUS_VERSION=$(git-version \
--previous-version \
--release-branch "${{ inputs.release-branch }}" \
--dev-branch "${{ inputs.dev-branch }}" \
--minor-identifier="${{ inputs.minor-identifier }}" \
--major-identifier="${{ inputs.major-identifier }}" \
${{ inputs.skip-prerelease == 'true' && '--skip-prerelease' || '' }} \
--version-prefix "${{ inputs.prefix }}")
echo "previous-version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
echo "Previous Version: $PREVIOUS_VERSION"
- id: version
shell: bash
run: |
set -eo pipefail
export VERSION=$(git-version \
--release-branch "${{ inputs.release-branch }}" \
--dev-branch "${{ inputs.dev-branch }}" \
--minor-identifier="${{ inputs.minor-identifier }}" \
--major-identifier="${{ inputs.major-identifier }}" \
--log-paths="${{ inputs.log-paths }}" \
${{ inputs.skip-prerelease == 'true' && '--skip-prerelease' || '' }} \
--version-prefix "${{ inputs.prefix }}")
prefix="${{ inputs.prefix }}"
non_prefixed_version=${VERSION#"$prefix"}
echo "non-prefixed-version=$non_prefixed_version" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "New Version: $VERSION"