Skip to content

Commit f200932

Browse files
committed
Give the action some outputs
Give the action some outputs, so the scallywag build action doesn't have to guess/hardcode those internal values. (Note that locating output values relies on the id assigned to a step, a point which the official documentation could stand to be clearer on)
1 parent 52b4c10 commit f200932

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,43 @@ jobs:
301301

302302
- name: Run test shell script
303303
run: C:\cygwin\bin\bash.exe /cygwin-install-action-test.sh
304+
305+
outputs-test:
306+
runs-on: windows-latest
307+
308+
name: 'Test outputs'
309+
310+
steps:
311+
- run: git config --global core.autocrlf input
312+
313+
- uses: actions/checkout@v4
314+
315+
- name: Install Cygwin
316+
id: cygwin-install
317+
uses: ./
318+
319+
- name: Verify Outputs
320+
run: |
321+
echo "setup executable is at: ${SETUP}"
322+
echo "cygwin install root directory is: ${ROOT}"
323+
echo "cygwin package cache directory is: ${CACHE}"
324+
325+
if [[ "${SETUP}" != "D:\setup.exe" ]]; then
326+
echo "unexpected value for 'setup' output"
327+
exit 1
328+
fi
329+
330+
if [[ "${ROOT}" != "D:\cygwin" ]]; then
331+
echo "unexpected value for 'root' output"
332+
exit 1
333+
fi
334+
335+
if [[ "${CACHE}" != "D:\cygwin-packages" ]]; then
336+
echo "unexpected value for 'package-cache' output"
337+
exit 1
338+
fi
339+
shell: bash -o igncr '{0}'
340+
env:
341+
SETUP: ${{ steps.cygwin-install.outputs.setup }}
342+
ROOT: ${{ steps.cygwin-install.outputs.root }}
343+
CACHE: ${{ steps.cygwin-install.outputs.package-cache }}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ These options are very unlikely to be useful except in some very isolated
108108
circumstances, such as using the [Cygwin Time
109109
Machine](http://www.crouchingtigerhiddenfruitbat.org/Cygwin/timemachine.html).
110110

111+
Outputs
112+
-------
113+
114+
| Output | Description
115+
| ------------- | -----------------------------------------
116+
| package-cache | Package cache directory
117+
| root | Root directory of the Cygwin installation (equal to the install-dir input)
118+
| setup | Cygwin setup executable pathname
119+
120+
Footnotes
121+
---------
122+
111123
[1] The
112124
[Workflow documentation](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference)
113125
suggests you should also use bash options `-eo pipefail`, omitted here for clarity

action.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,22 @@ inputs:
4646
required: false
4747
default: ''
4848

49+
outputs:
50+
setup:
51+
description: Pathname of the Cygwin setup executable
52+
value: ${{ steps.cygwin-install-action.outputs.setup }}
53+
root:
54+
description: Root directory of Cygwin installation (equal to install-dir input)
55+
value: ${{ steps.cygwin-install-action.outputs.root }}
56+
package-cache:
57+
description: Package cache directory
58+
value: ${{ steps.cygwin-install-action.outputs.package-cache }}
59+
4960
runs:
5061
using: "composite"
5162
steps:
52-
- run: |
63+
- id: cygwin-install-action
64+
run: |
5365
$ErrorActionPreference = 'Stop'
5466
$platform = '${{ inputs.platform }}'
5567
$platform = $platform -replace '^(x64|amd64)$', 'x86_64'
@@ -143,14 +155,16 @@ runs:
143155
$installDir = '${{ inputs.install-dir }}'
144156
}
145157
158+
$packageDir = "$vol\cygwin-packages"
159+
146160
$packages = '${{ inputs.packages }}'
147161
$pkg_list = $packages.Split('', [System.StringSplitOptions]::RemoveEmptyEntries)
148162
$pkg_list = $pkg_list | % { $_.Trim() }
149163
$pkg_list = $pkg_list | % { $_.Trim(',') }
150164
151165
$args = @(
152166
'-qnO',
153-
'-l', "$vol\cygwin-packages",
167+
'-l', "$packageDir",
154168
'-R', "$installDir"
155169
)
156170
@@ -212,6 +226,12 @@ runs:
212226
213227
# run login shell to copy skeleton profile files
214228
& "$installDir\bin\bash.exe" --login
229+
230+
# set outputs
231+
echo "setup=$setupExe" >> $env:GITHUB_OUTPUT
232+
echo "root=$installDir" >> $env:GITHUB_OUTPUT
233+
echo "package-cache=$packageDir" >> $env:GITHUB_OUTPUT
234+
215235
shell: powershell
216236

217237
branding:

0 commit comments

Comments
 (0)