-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
140 lines (121 loc) · 4.38 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# SPDX-FileCopyrightText: The Dolt Installer GitHub Action Authors
# SPDX-License-Identifier: 0BSD
name: dolt-installer
author: sebhoss
description: Installs dolt and includes it in the PATH of a GitHub runner
branding:
icon: package
color: green
inputs:
version:
description: dolt release version to be installed
required: false
default: latest
install-directory:
description: Directory for the dolt binaries
required: false
default: '$HOME/.dolt'
runs:
using: composite
steps:
- shell: bash
run: |
#!/bin/bash
INSTALL_FOLDER="${{ inputs.install-directory }}"
VERSION="${{ inputs.version }}"
GITHUB_ORGA='https://github.com/dolthub/dolt'
DOWNLOAD_URL="${GITHUB_ORGA}/releases/download"
RELEASE_URL="${GITHUB_ORGA}/releases/latest"
JSON_HEADER='Accept: application/json'
BINARY_NAME='dolt'
case ${{ runner.os }} in
Linux)
case ${{ runner.arch }} in
X64)
operating_system='linux'
processor_architecture='amd64'
file_extension='tar.gz'
;;
ARM64)
operating_system='linux'
processor_architecture='arm64'
file_extension='tar.gz'
;;
*)
echo "unsupported architecture ${{ runner.os }}/${{ runner.arch }}"
exit 1
;;
esac
;;
macOS)
case ${{ runner.arch }} in
X64)
operating_system='darwin'
processor_architecture='amd64'
file_extension='tar.gz'
;;
ARM64)
operating_system='darwin'
processor_architecture='arm64'
file_extension='tar.gz'
;;
*)
echo "unsupported architecture ${{ runner.os }}/${{ runner.arch }}"
exit 1
;;
esac
;;
Windows)
case ${{ runner.arch }} in
X64)
operating_system='windows'
processor_architecture='amd64'
file_extension='zip'
;;
*)
echo "unsupported architecture ${{ runner.os }}/${{ runner.arch }}"
exit 1
;;
esac
;;
*)
echo "unsupported architecture ${{ runner.os }}/${{ runner.arch }}"
exit 1
;;
esac
ARCHIVE_NAME="${BINARY_NAME}-${operating_system}-${processor_architecture}.${file_extension}"
if [[ "${VERSION}" == 'latest' ]]; then
echo 'fetching latest release from github'
version_tag=$(curl --silent --location --header "${JSON_HEADER}" ${RELEASE_URL} | jq -r '.tag_name')
echo "latest version is ${version_tag}"
else
[[ "${VERSION}" == v* ]] && version_tag="${VERSION}"
[[ "${VERSION}" == v* ]] || version_tag="v${VERSION}"
fi
LATEST_BIN_LINK="${DOWNLOAD_URL}/${version_tag}/${ARCHIVE_NAME}"
echo "downloading binary from ${LATEST_BIN_LINK}"
DOWNLOAD_FOLDER=$(mktemp -d)
DOWNLOAD_BIN="${DOWNLOAD_FOLDER}/${ARCHIVE_NAME}"
echo "saving downloads in ${DOWNLOAD_FOLDER}"
curl --silent --location "${LATEST_BIN_LINK}" --output "${DOWNLOAD_BIN}"
echo 'latest binary downloaded'
echo "installing into ${INSTALL_FOLDER}"
mkdir -p "${INSTALL_FOLDER}"
case ${{ runner.os }} in
Windows)
7z e "${DOWNLOAD_BIN}" -o"${DOWNLOAD_FOLDER}"
mv "${DOWNLOAD_FOLDER}/${BINARY_NAME}.exe" "${INSTALL_FOLDER}/${BINARY_NAME}.exe"
;;
*)
tar xz --file="${DOWNLOAD_BIN}" --directory="${DOWNLOAD_FOLDER}" --strip-components=1
mv "${DOWNLOAD_FOLDER}/bin/${BINARY_NAME}" "${INSTALL_FOLDER}/${BINARY_NAME}"
;;
esac
rm -rf "${DOWNLOAD_FOLDER}"
echo "dolt version ${version_tag} installed"
- if: runner.os == 'Linux' || runner.os == 'macOS'
shell: bash
run: echo "${{ inputs.install-directory }}" >> $GITHUB_PATH
- if: runner.os == 'Windows'
shell: pwsh
run: echo "${{ inputs.install-directory }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append