forked from codacy/git-version
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
96 lines (92 loc) · 3.49 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
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
skip-prerelease:
description: "Skip prerelease part of the version. When true, release-branch and dev-branch are effectively ignored"
required: true
default: "false"
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
suffix:
description: "The suffix 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/linz/action-git-version/releases/latest | jq -r .assets[0].browser_download_url)"
else
download_url="https://github.com/linz/action-git-version/releases/download/${{ inputs.tool-version }}/git-version"
fi
sudo curl -Ls "$download_url" -o /usr/local/bin/git-version
sudo chmod +x /usr/local/bin/git-version
- id: previous-version
shell: bash
run: |
set -eo pipefail
PREVIOUS_VERSION=$(git-version \
--previous-version \
--release-branch "${{ inputs.release-branch }}" \
--dev-branch "${{ inputs.dev-branch }}" \
${{ inputs.skip-prerelease == 'true' && '--skip-prerelease' || '' }} \
--minor-identifier="${{ inputs.minor-identifier }}" \
--major-identifier="${{ inputs.major-identifier }}" \
--version-prefix "${{ inputs.prefix }}" \
--version-suffix "${{ inputs.suffix }}")
echo "previous-version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
echo "Previous Version: $PREVIOUS_VERSION"
- id: version
shell: bash
run: |
set -eo pipefail
VERSION=$(git-version \
--release-branch "${{ inputs.release-branch }}" \
--dev-branch "${{ inputs.dev-branch }}" \
${{ inputs.skip-prerelease == 'true' && '--skip-prerelease' || '' }} \
--skip-prerelease "${{ inputs.skip-prerelease }}" \
--minor-identifier="${{ inputs.minor-identifier }}" \
--major-identifier="${{ inputs.major-identifier }}" \
--log-paths="${{ inputs.log-paths }}" \
--version-prefix "${{ inputs.prefix }}" \
--version-suffix "${{ inputs.suffix }}")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "New Version: $VERSION"