-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
125 lines (111 loc) · 4.02 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
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
name: Compile AutoHotkey Script
author: CEnnis91
description: Compiles AutoHotkey scripts into EXEs using Ahk2Exe
branding:
icon: 'package'
color: 'blue'
inputs:
in:
description: The path and name of the script to compile.
required: true
out:
description: The path\name of the output .exe to be created. Default is the directory\base_name of the input file plus extension of .exe.
required: false
default: ''
icon:
description: The icon file to be used.
required: false
default: ''
cp:
description: Overrides the default codepage used to read script files.
required: false
default: ''
base:
description: The base file to be used (a .bin or .exe file).
required: false
default: 'Unicode 64-bit.bin'
compress:
description: Compress the exe? 0 = no, 1 = use MPRESS if present, 2 = use UPX if present.
required: false
default: ''
resourceid:
description: Assigns a non-standard resource ID to be used for the main script for compilations which use an .exe base file.
required: false
default: ''
outputs:
binary:
description: The compiled AutoHotkey binary
value: ${{ steps.compile.outputs.binary }}
directory:
description: The base directory of the installed AutoHotkey
value: ${{ steps.install.outputs.directory }}
version:
description: The version of the installed AutoHotkey
value: ${{ steps.install.outputs.version }}
runs:
using: composite
steps:
- name: Check Operating System
shell: bash
run: |
if [[ "$RUNNER_OS" != 'Windows' ]]; then
echo "::error ::${RUNNER_OS} is not supported, you must use Windows."
exit 1
fi
- name: Install Scoop with Extras
shell: pwsh
run: |
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
scoop bucket add extras
scoop bucket add versions
scoop install zip
Write-Output ('Path=' + $env:Path + ';' + $env:UserProfile + '\scoop\shims') >> $env:GITHUB_ENV
- name: Install AutoHotkey
id: install
shell: pwsh
run: |
scoop install autohotkey1.1
$ahk = (scoop which autohotkey)
$directory = (Resolve-Path (Split-Path -Path $ahk)).Path
$version = (scoop info autohotkey).Version
echo "::set-output name=directory::$directory"
echo "::set-output name=version::$version"
echo "::notice ::Successfully installed AutoHotkey ${version} from Scoop."
- name: Compile Script
id: compile
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$args = @()
$with = @{
'in' = "${{ inputs.in }}"; 'out' = "${{ inputs.out }}"; 'icon' = "${{ inputs.icon }}";
'cp' = "${{ inputs.cp }}"; 'base' = "${{ inputs.base }}"; 'compress' = "${{ inputs.compress }}";
'resourceid' = "${{ inputs.resourceid }}";
}
ForEach ($key in @($with.Keys)) {
If (![string]::IsNullOrEmpty($with["$key"])) {
$is_path = $true
Switch ($key) {
{ @('in', 'icon') -contains $_} {
$with["$key"] = Resolve-Path -Path $with["$key"]
}
{ @('base') -contains $_ } {
$with["$key"] = Resolve-Path -Path "${{ steps.install.outputs.directory }}\Compiler\$($with["$key"])"
}
{ @('out') -contains $_ } {
$with["$key"] = Join-Path $pwd $with["$key"]
New-Item $(Split-Path -Path $with["$key"]) -Force -ItemType Directory > $null
}
default { $is_path = $false }
}
If ($is_path) {
$args += "/$key '$($with["$key"])'"
} Else {
$args += "/$key $($with["$key"])"
}
}
}
Invoke-Expression "ahk2exe.exe $($args -join ' ')" | Out-String -OutVariable output
$binary = $output.Split([Environment]::NewLine).Where({ $_.contains('exe') })
echo "::set-output name=binary::$binary"
echo "::notice ::Successfully compiled as: ${binary}."