-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
131 lines (121 loc) · 4.21 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
---
name: 'Compile open firmware solution'
description: |
Compile a selected firmware solution like coreboot, EDKII, OpenBMC and more
author: '9elements'
inputs:
config:
description: |
Path to the JSON configuration file.
required: true
target:
description: |
The firmware recipe to build. Use ID from JSON configuration file.
required: true
recursive:
description: |
Build target recursively, with all of its dependencies.
required: false
default: 'false'
compile:
description: |
Compile the action from source instead of downloading pre-compiled binary from releases.
required: false
default: 'false'
runs:
using: 'composite'
steps:
- id: version
shell: bash
run: echo "version=v0.10.2" >> "${GITHUB_OUTPUT}"
- id: arch
# This ARCH is used to fetch correct executable of firmware-action
# GoReleaser uses 'x86_64' instead of 'amd64'
shell: bash
run: |
if [ ${{ runner.arch }} = "X64" ]; then
echo "arch=x86_64" >> "${GITHUB_OUTPUT}"
elif [ ${{ runner.arch }} = "amd64" ]; then
echo "arch=x86_64" >> "${GITHUB_OUTPUT}"
elif [ ${{ runner.arch }} = "X86" ]; then
echo "arch=i386" >> "${GITHUB_OUTPUT}"
elif [ ${{ runner.arch }} = "ARM64" ]; then
echo "arch=arm64" >> "${GITHUB_OUTPUT}"
else
echo "arch=${{ runner.arch }}" >> "${GITHUB_OUTPUT}"
fi
- id: os
shell: bash
run: |
if [ ${{ runner.os }} = "macOS" ]; then
echo "os=Darwin" >> "${GITHUB_OUTPUT}"
else
echo "os=${{ runner.os }}" >> "${GITHUB_OUTPUT}"
fi
# Because MacOS is named Darwin in golang releaser
- id: ext
shell: bash
run: |
if [ ${{ runner.os }} = "Windows" ]; then
echo "ext=zip" >> "${GITHUB_OUTPUT}"
else
echo "ext=tar.gz" >> "${GITHUB_OUTPUT}"
fi
# Both Linux and MacOS use 'tar.gz'
- id: filename
shell: bash
run: |
echo "filename=firmware-action_${{ steps.os.outputs.os }}_${{ steps.arch.outputs.arch }}.${{ steps.ext.outputs.ext }}" >> "${GITHUB_OUTPUT}"
- id: url
shell: bash
run: |
echo "url=https://github.com/9elements/firmware-action/releases/download/${{ steps.version.outputs.version }}/${{ steps.filename.outputs.filename }}" >> "${GITHUB_OUTPUT}"
- name: setup_go
if: ${{ inputs.compile == 'true' }}
uses: actions/setup-go@v5
with:
go-version: stable
- id: fetch_unix
if: ${{ ( runner.os == 'Linux' || runner.os == 'macOS' ) && inputs.compile == 'false' }}
shell: bash
run: |
curl -L -o "${{ steps.filename.outputs.filename }}" "${{ steps.url.outputs.url }}"
tar -xvzf "${{ steps.filename.outputs.filename }}"
chmod +x firmware-action
# chmod should not be necessary, but just to be safe
- name: compile_unix
if: ${{ ( runner.os == 'Linux' || runner.os == 'macOS' ) && inputs.compile == 'true' }}
shell: bash
working-directory: ./action
run: |
go build -ldflags="-s -w" -o ../firmware-action
- id: fetch_windows
if: ${{ runner.os == 'Windows' && inputs.compile == 'false' }}
shell: pwsh
run: |
Invoke-WebRequest -Uri "${{ steps.url.outputs.url }}" -OutFile "${{ steps.filename.outputs.filename }}"
Expand-Archive -Path "${{ steps.filename.outputs.filename }}" -DestinationPath .\
- name: compile_windows
if: ${{ runner.os == 'Windows' && inputs.compile == 'true' }}
shell: pwsh
working-directory: ./action
run: |
go build -ldflags="-s -w" -o ../firmware-action.exe
- name: run_unix
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
shell: bash
run: |
./firmware-action
env:
INPUT_CONFIG: ${{ inputs.config }}
INPUT_TARGET: ${{ inputs.target }}
INPUT_RECURSIVE: ${{ inputs.recursive }}
- name: run_windows
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
.\firmware-action.exe
env:
INPUT_CONFIG: ${{ inputs.config }}
INPUT_TARGET: ${{ inputs.target }}
INPUT_RECURSIVE: ${{ inputs.recursive }}