-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
155 lines (142 loc) · 6.87 KB
/
action.yml
File metadata and controls
155 lines (142 loc) · 6.87 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: 'ESP Packaged Programmer'
description: 'Package esptool and the binaries into an executable'
inputs:
zipfile-id:
description: 'Artifact ID for the Zipfile to download. Zipfile should contain firmware.bin, bootloader.bin, partition-table.bin, and flasher_args.json. May optionally contain filesystem binaries and associated -flash_args files. NOTE: only one of zipfile-id or zipfile-name should be set. The structure of the zip should be the same as the build folder within the esp-idf build - so it should have the tree: build/, build/bootloader/, build/partition_table/'
required: false
default: ''
zipfile-name:
description: 'Name of the zipfile artifact that was packaged and uploaded. Zipfile should contain firmware.bin, bootloader.bin, partition-table.bin, and flasher_args.json. May optionally contain filesystem binaries and associated -flash_args files. NOTE: only one of zipfile-id or zipfile-name should be set. The structure of the zip should be the same as the build folder within the esp-idf build - so it should have the tree: build/, build/bootloader/, build/partition_table/'
required: false
default: ''
programmer-name:
description: 'Base name of the programmer executable. Will have version tag (e.g. v1.0.0 or commit hash if no tags) and OS suffix (e.g. windows, linux, macos) appended.'
required: false
default: 'programmer'
exclude-file-globs:
description: 'File globs to exclude from the build folder. This is a comma-separated list of filenames or globs. For example: "*.elf,*.pdb,app-flash_args". Defaults to "*.elf".'
required: false
default: '*.elf'
outputs:
artifact-name:
description: "Name of the programmer artifact that was packaged and uploaded"
value: ${{ steps.output.outputs.artifact-name }}
runs:
using: "composite"
steps:
- name: Ensure that one of zipfile-id or zipfile-name is set
if: ${{ inputs.zipfile-id == '' && inputs.zipfile-name == '' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Either zipfile-id or zipfile-name must be set"
exit 1
- name: Ensure that only zipfile-id or zipfile-name is set, not both
if: ${{ inputs.zipfile-id != '' && inputs.zipfile-name != '' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Only one of zipfile-id or zipfile-name can be set"
exit 1
- name: Check Runner OS
if: ${{ runner.os != 'Linux' && runner.os != 'Windows' && runner.os != 'macOS'}}
shell: bash
run: |
echo "::error title=⛔ error hint::Support Linux, Windows, and macOS Only"
exit 1
- name: Clone the parent repo (to get the version)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get the version
shell: bash
run: |
echo "Trying to get the version from the parent repo"
# Get the version of the parent repo
version=$(git describe --tags --dirty || git rev-parse --short HEAD)
echo "Got version: ${version}"
# Set the version as an output variable
echo "version_str=$version" >> $GITHUB_ENV
- name: Setup XCode
if: ${{ runner.os == 'macOS' }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Set up Python
uses: actions/setup-python@v5
id: id_python_310
with:
python-version: '3.10'
- name: Download the zipfile artifact
uses: actions/download-artifact@v4
id: download_zipfile
with:
name: ${{ inputs.zipfile-name }}
artifact-ids: ${{ inputs.zipfile-id }}
path: ${{ github.action_path }}/build
# this is needed to ensure downloading by id doesn't add an additional
# folder
merge-multiple: true
- name: Remove any unneeded files from the build folder
shell: bash
if: ${{ inputs.exclude-file-globs != '' }}
working-directory: ${{ github.action_path }}
run: |
# for each of the file globs in the exclude-file-globs input, remove the
# files from the build folder
IFS=',' read -ra globs <<< "${{ inputs.exclude-file-globs }}"
for glob in "${globs[@]}"; do
# remove the leading and trailing spaces
glob=$(echo "$glob" | xargs)
echo "Cleaning up files matching pattern: $glob"
# remove the files from the build folder
find build -name "$glob" -exec rm -rf {} \;
done
# Build if windows
- name: PyInstaller
if: ${{ runner.os == 'Windows'}}
working-directory: ${{ github.action_path }}
shell: pwsh
run: |
# setup the python environment
${{ steps.id_python_310.outputs.python-path }} -m pip install -r requirements.txt
# we need to clone v4.7.0 of esptool into the repo to ensure all of its data is properly packaged
git clone --depth 1 --branch v4.7.0 https://github.com/espressif/esptool
# now build the installer
${{ steps.id_python_310.outputs.python-path }} -m PyInstaller --clean programmer.spec
# now actually make the artifact
$artifact_name="${{ inputs.programmer-name }}_${{ env.version_str }}_windows.exe"
mv dist/programmer.exe ${artifact_name}
"artifactName=${artifact_name}" | Out-File -FilePath $env:GITHUB_ENV -Append
# Build if Linux or macOS
- name: PyInstaller
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
working-directory: ${{ github.action_path }}
shell: bash
run: |
# save the runner OS to a variable in lower case
os_name=$(echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]')
# setup the python environment
${{ steps.id_python_310.outputs.python-path }} -m pip install -r requirements.txt
# we need to clone v4.7.0 of esptool into the repo to ensure all of its data is properly packaged
git clone --depth 1 --branch v4.7.0 https://github.com/espressif/esptool
# now build the installer
${{ steps.id_python_310.outputs.python-path }} -m PyInstaller --clean programmer.spec
# now actually make the artifact
artifact_name="${{ inputs.programmer-name }}_${{ env.version_str }}_${os_name}.bin"
mv dist/programmer $artifact_name
echo "artifactName=$artifact_name" >> "$GITHUB_ENV"
# Set the ouput
- name: Set the action output
id: output
shell: bash
run: echo "artifact-name=${{ env.artifactName }}" >> $GITHUB_OUTPUT
# now actually upload the artifacts
- uses: actions/upload-artifact@v4
with:
name: ${{ env.artifactName }}
path: ${{ github.action_path }}/${{ env.artifactName }}
# attach the files to the release (if there is one)
- name: Attach files to release
uses: softprops/action-gh-release@v2
if: ${{ github.event.release && github.event.action == 'published' }}
with:
files: ${{ github.action_path }}/${{ env.artifactName }}