-
Notifications
You must be signed in to change notification settings - Fork 12
133 lines (125 loc) · 4.64 KB
/
installer.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
name: installer
on:
push:
branches:
- $default-branch
paths:
- build/*
- .github/*
pull_request:
paths:
- build/*
- .github/*
release:
defaults:
run:
shell: pwsh
env:
SCRIPT_URL: "https://raw.githubusercontent.com/QutEcoacoustics/audio-analysis/${{ github.sha }}/build/download_ap.ps1"
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test-script-host:
runs-on: ubuntu-latest
steps:
- name: ensure script host serves the script with "charset=utf-8"
run: |
curl -Ii "$env:SCRIPT_URL" | Write-Output -OutVariable "response"
$response | grep "charset=utf-8"
- name: ensure short url redirects to download script
# if this test ever fails, recreate short url and update the installing.md docs
run: |
curl -Ii "https://git.io/JtOo3" | Write-Output -OutVariable "response"
$response | grep "https://raw.githubusercontent.com/QutEcoacoustics/audio-analysis/.*/build/download_ap.ps1"
test-installer:
strategy:
fail-fast: false
matrix:
os:
# https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources
- windows-latest
- ubuntu-18.04
- ubuntu-20.04
# macos-11.0 is in private preview stage https://github.com/actions/virtual-environments/issues/2486
# - macos-11.0
- macos-10.15
include:
- os: windows-latest
alias_name: "AP.exe"
bin_dir: "~\\AP"
- os: ubuntu-18.04
alias_name: "AP"
bin_dir: "~/.local/bin"
- os: ubuntu-20.04
alias_name: "AP"
bin_dir: "~/.local/bin"
# - os: macos-11.0
# alias_name: "AP"
# bin_dir: "~/.local/bin"
- os: macos-10.15
alias_name: "AP"
bin_dir: "~/.local/bin"
# https://raw.githubusercontent.com/QutEcoacoustics/audio-analysis/5f08faa96d8f044fb278b68f1c7d577fe218e8a1/build/download_ap.ps1
runs-on: ${{ matrix.os }}
name: Test installer (${{ matrix.os }})
# This workflow tests if our "installer"
# script works.
# It needs to test:
# - remote download
# - install
# - adding to PATH
# - uninstall
# Need to use -Force on commands because CI is not interactive
# https://github.com/PowerShell/PowerShell/issues/3337
steps:
- name: Get info about action runner
run: $PSVersionTable
# must use -Force on CI to suppress interactive steps
# otherwise interactive steps will crash (e.g. when warning on install overwrite)
- name: Test installer (remote download)
uses: knicknic/os-specific-run@v1.0.3
with:
macos: >
pwsh -nop -c '$function:i=irm "$env:SCRIPT_URL";i -Force'
linux: >
pwsh -nop -c '$function:i=irm "$env:SCRIPT_URL";i -Force'
windows: >
pwsh -nop -ex B -c '$function:i=irm "$env:SCRIPT_URL";i -Force'
- name: Test installer (upgrade)
uses: knicknic/os-specific-run@v1.0.3
with:
macos: >
pwsh -nop -c '$function:i=irm "$env:SCRIPT_URL";i -Force -Prerelease'
linux: >
pwsh -nop -c '$function:i=irm "$env:SCRIPT_URL";i -Force -Prerelease'
windows: >
pwsh -nop -ex B -c '$function:i=irm "$env:SCRIPT_URL";i -Force -Prerelease'
- name: Update PATH
# Github actions doesn't persist changes to PATH during steps
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
run: >
echo "$env:AP_PATH" | Resolve-Path | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
env:
AP_PATH: ${{ matrix.bin_dir }}
- name: Check alias works
run: |
Get-ChildItem "$env:AP_PATH/$env:ALIAS_NAME"
AP --version
env:
AP_PATH: ${{ matrix.bin_dir }}
ALIAS_NAME: ${{ matrix.alias_name }}
- name: Test installer (uninstall)
uses: knicknic/os-specific-run@v1.0.3
with:
macos: >
pwsh -nop -c '$function:i=irm "$env:SCRIPT_URL";i -Force -Uninstall'
linux: >
pwsh -nop -c '$function:i=irm "$env:SCRIPT_URL";i -Force -Uninstall'
windows: >
pwsh -nop -ex B -c '$function:i=irm "$env:SCRIPT_URL";i -Force -Uninstall'
- name: Check alias no longer works
run: |
Get-Command AP -ErrorAction 'Continue'
if ($error[0] -match "The term 'AP' is not recognized") {
exit 0
}
exit 1