-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
81 lines (73 loc) · 2.23 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
name: 'pasfmt'
description: 'Check formatting of Delphi files using pasfmt'
author: 'integrated-application-development'
branding:
icon: 'check'
color: 'black'
inputs:
args:
description: 'Arguments that will be passed to pasfmt.'
required: false
default: '--mode check .'
release-name:
description: 'Name of the pasfmt release to use. (Examples: latest, v0.4.0-rc1)'
required: false
default: 'latest'
working-directory:
description: 'Directory to run pasfmt in.'
required: false
default: '.'
runs:
using: "composite"
steps:
- name: Set up pasfmt
shell: bash
env:
GH_TOKEN: ${{ github.token }}
PASFMT_VERSION: ${{ inputs.release-name }}
run: |
if [ "$PASFMT_VERSION" = "latest" ]; then
PASFMT_VERSION=""
fi
INSTALL_PATH="$HOME/pasfmt"
ARCHIVE_NAME="$INSTALL_PATH/archive"
rm -rf "$INSTALL_PATH"
mkdir -p "$INSTALL_PATH"
PLATFORM=$(uname -s)
case "$PLATFORM" in
*_NT*)
ARCHIVE_PATTERN="*-windows-*.zip"
;;
Linux)
ARCHIVE_PATTERN="*-linux-*.tar.gz"
;;
*)
echo "::error::Unsupported platform: $PLATFORM" >&2
exit 1
;;
esac
gh release download $PASFMT_VERSION -R integrated-application-development/pasfmt -p "$ARCHIVE_PATTERN" --output "$ARCHIVE_NAME"
case "$PLATFORM" in
*_NT*)
unzip -j "$ARCHIVE_NAME" -d "$INSTALL_PATH"
;;
Linux)
tar -xzf "$ARCHIVE_NAME" --strip-components 1 -C "$INSTALL_PATH"
;;
esac
chmod +x "$INSTALL_PATH/pasfmt"
echo "$INSTALL_PATH" >> $GITHUB_PATH
- name: Run pasfmt
shell: bash
env:
WORKING_DIR: ${{ inputs.working-directory }}
ARGS: ${{ inputs.args }}
run: |
if [ ! -d "$WORKING_DIR" ]; then
echo "::error::The specified working directory '$WORKING_DIR' does not exist." >&2
exit 1
fi
cd "$WORKING_DIR"
# split args but don't expand globs
args=($ARGS)
pasfmt "${args[@]}"