-
Notifications
You must be signed in to change notification settings - Fork 45
/
action.yml
83 lines (79 loc) · 2.85 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
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:'
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 }}
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 }}" \
--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 }}" \
--version-prefix "${{ inputs.prefix }}")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "New Version: $VERSION"