-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
61 lines (54 loc) · 1.87 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
name: "Setup git-mkver"
description: "It downloads and installs git-mkver"
branding:
icon: "settings"
color: "purple"
inputs:
version:
description: "The git-mkver version to install"
required: false
default: "latest"
runs:
using: "composite"
steps:
- run: |
if [[ "$VERSION" == "latest" ]]; then
VERSION=$(curl -s https://api.github.com/repos/idc101/git-mkver/releases/latest | jq -r '.tag_name |= (sub("v";"")) | .tag_name')
fi
GIT_MKVER_DIR_LINUX="$HOME/.git-mkver"
RELEASES_DOWNLOAD_BASE_URL="https://github.com/idc101/git-mkver/releases/download/v$VERSION"
clean() {
if [[ "$RUNNER_OS" == "Windows" ]]; then
rm -rf /c/Windows/System32/git-mkver.exe
else
rm -rf $GIT_MKVER_DIR_LINUX
fi
}
download_and_unzip() {
ASSET_NAME="$1"
DST_DIRECTORY="$2"
curl -LO "$RELEASES_DOWNLOAD_BASE_URL/$ASSET_NAME"
unzip "$ASSET_NAME" -d "$DST_DIRECTORY"
rm "$ASSET_NAME"
}
clean
if [[ "$RUNNER_OS" == "Windows" ]]; then
download_and_unzip "git-mkver-windows-amd64-$VERSION.zip" /c/Windows/System32
else
if [[ "$VERSION" < "1.3.0" ]]; then
curl -L "$RELEASES_DOWNLOAD_BASE_URL/git-mkver-linux-amd64-$VERSION.tar.gz" | tar xvz
mkdir -p $GIT_MKVER_DIR_LINUX/bin
mv git-mkver "$GIT_MKVER_DIR_LINUX/bin"
chmod +x "$GIT_MKVER_DIR_LINUX/bin/git-mkver"
else
download_and_unzip "git-mkver-$VERSION.zip" .
rm -rf $GIT_MKVER_DIR_LINUX
mv "git-mkver-$VERSION" "$GIT_MKVER_DIR_LINUX"
fi
fi
env:
VERSION: ${{ inputs.version }}
shell: bash
- run: echo "${HOME}/.git-mkver/bin" >> $GITHUB_PATH
if: ${{ runner.os != 'Windows' }}
shell: bash