-
Notifications
You must be signed in to change notification settings - Fork 8
/
action.yaml
64 lines (64 loc) · 2.59 KB
/
action.yaml
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
name: 'Git describe semver'
description: ''
inputs:
version:
description: 'Which git-describe-semver release should be used?'
default: 'latest'
dir:
description: 'Git worktree directory (defaults to current directory)'
default: '.'
fallback:
description: 'Fallback to given tag name if no tag is available'
default: 'v0.0.0'
drop-prefix:
description: 'Drop any present prefix (like "v") from the output'
default: 'false'
prerelease-prefix:
description: 'Adds a dash-separated prefix to the prerelease part'
default: 'dev'
prerelease-suffix:
description: 'Adds a dash-separated suffix to the prerelease part'
default: ''
prerelease-timestamped:
description: 'Use timestamp instead of commit count for prerelease'
default: 'false'
next-release:
description: 'Bump current version to next release (choices: "major", "minor", "patch")'
default: ''
outputs:
version:
description: 'Version output from git-describe-semver'
value: ${{ steps.git-describe-semver.outputs.version }}
runs:
using: 'composite'
steps:
- if: inputs.version == 'latest'
run: |
cd /tmp
URL=$(curl -fsSL https://api.github.com/repos/choffmeister/git-describe-semver/releases/latest | jq -r '.assets[] | select(.name|test("linux_amd64\\.tar\\.gz$")) | .browser_download_url')
curl -fsSL "$URL" | tar xz
mv git-describe-semver /usr/local/bin
shell: bash
- if: inputs.version != 'latest'
run: |
cd /tmp
VERSION="$(echo ${{ inputs.version }} | sed 's#^v##')"
URL="https://github.com/choffmeister/git-describe-semver/releases/download/v${VERSION}/git-describe-semver_${VERSION}_linux_amd64.tar.gz"
curl -fsSL "$URL" | tar xz
mv git-describe-semver /usr/local/bin
shell: bash
- id: git-describe-semver
run: |
git-describe-semver \
${{ format('--dir="{0}"', inputs.dir) }} \
${{ format('--fallback="{0}"', inputs.fallback) }} \
${{ inputs.drop-prefix == 'true' && format('--drop-prefix') || '' }} \
${{ format('--prerelease-prefix="{0}"', inputs.prerelease-prefix) }} \
${{ format('--prerelease-suffix="{0}"', inputs.prerelease-suffix) }} \
${{ inputs.inputs.prerelease-timestamped == 'true' && format('--prerelease-timestamped') || '' }} \
${{ inputs.next-release != '' && format('--next-release="{0}"', inputs.next-release) || '' }} \
--format="version=<version>" \
$GITHUB_OUTPUT
shell: bash
- run: echo ${{ steps.git-describe-semver.outputs.version }}
shell: bash