Skip to content

Commit 7e18cf3

Browse files
authored
Fix build folder tree packaging and add exclude-file-glob input (#4)
* print build directory before and after modification to ensure it is correct * test using collect-system-data-files * revert back to original * fix action and how it manages the provided files. add feature to exclude files * readme: udpate * update to 1.0.4
1 parent 841632d commit 7e18cf3

File tree

3 files changed

+55
-13
lines changed

3 files changed

+55
-13
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ For an example repository which uses this action, please see
1616
- [Required Build Artifacts](#required-build-artifacts)
1717
- [Optional Build Artifacts](#optional-build-artifacts)
1818
- [Using this action](#using-this-action)
19+
- [Inputs](#inputs)
1920

2021
<!-- markdown-toc end -->
2122

@@ -43,7 +44,7 @@ use.
4344
os: [windows-latest, macos-latest, ubuntu-latest]
4445
runs-on: ${{ matrix.os }}
4546
steps:
46-
- uses: esp-cpp/esp-packaged-programmer-action@v1.0.2
47+
- uses: esp-cpp/esp-packaged-programmer-action@v1.0.4
4748
with:
4849
zipfile-name: 'your-build-artifacts'
4950
programmer-name: 'your_programmer_name'
@@ -135,9 +136,38 @@ jobs:
135136
os: [windows-latest, macos-latest, ubuntu-latest]
136137
runs-on: ${{ matrix.os }}
137138
steps:
138-
- uses: esp-cpp/esp-packaged-programmer-action@v1.0.2
139+
- uses: esp-cpp/esp-packaged-programmer-action@v1.0.4
139140
with:
140141
zipfile-id: ${{ needs.build.outputs.zipfile-id }}
141142
programmer-name: 'your_programmer_name'
143+
exclude-file-globs: '*.elf, app-flash_args, bootloader-flash_args, partition-table-flash_args'
142144
```
143145

146+
### Inputs
147+
148+
```yaml
149+
- uses: esp-cpp/download-artifact@v1.0.4
150+
with:
151+
# The ID of the artifact to download.
152+
# Mutually exclusive with `zipfile-name`.
153+
# The artifact should be a zip that contains the files and folder
154+
# structure of the build output. Can be created by passing relevant
155+
# files to the actions/upload-artifact@v4 action.
156+
zipfile-id:
157+
158+
# The name of the artifact to download.
159+
# Mutually exclusive with `zipfile-name`.
160+
# The artifact should be a zip that contains the files and folder
161+
# structure of the build output. Can be created by passing relevant
162+
# files to the actions/upload-artifact@v4 action.
163+
zipfile-name:
164+
165+
# The base name of the programmer executable.
166+
# Will have version tag (e.g. v1.0.0 or commit hash if no tags) and
167+
# OS suffix (e.g. windows, macos, linux) added to it.
168+
programmer-name:
169+
170+
# Comma-separated list of file names or globs which are present in
171+
# the zipfile but which should be excluded from the packaging.
172+
exclude-file-globs:
173+
```

action.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ name: 'ESP Packaged Programmer'
22
description: 'Package esptool and the binaries into an executable'
33
inputs:
44
zipfile-id:
5-
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.'
5+
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/'
66
required: false
77
default: ''
88
zipfile-name:
9-
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.'
9+
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/'
1010
required: false
1111
default: ''
1212
programmer-name:
1313
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.'
1414
required: false
1515
default: 'programmer'
16+
exclude-file-globs:
17+
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".'
18+
required: false
19+
default: '*.elf'
1620
outputs:
1721
artifact-name:
1822
description: "Name of the programmer artifact that was packaged and uploaded"
@@ -76,17 +80,21 @@ runs:
7680
artifact-ids: ${{ inputs.zipfile-id }}
7781
path: ${{ github.action_path }}/build
7882

79-
- name: Move the artifacts to the build directory
83+
- name: Remove any unneeded files from the build folder
8084
shell: bash
85+
if: ${{ inputs.exclude-file-globs != '' }}
8186
working-directory: ${{ github.action_path }}
8287
run: |
83-
# we don't control the name of the unpacked archive (folder) that's
84-
# within build/ so simply move everything within that subfolder into
85-
# build/
86-
find build -maxdepth 2 -mindepth 2 -exec mv {} build/. \;
87-
# also, we don't want any elf files if they were uploaded (which they
88-
# sometimes are for debug purposes), so delete them
89-
find build -name "*.elf" -type f -delete
88+
# for each of the file globs in the exclude-file-globs input, remove the
89+
# files from the build folder
90+
IFS=',' read -ra globs <<< "${{ inputs.exclude-file-globs }}"
91+
for glob in "${globs[@]}"; do
92+
# remove the leading and trailing spaces
93+
glob=$(echo "$glob" | xargs)
94+
echo "Cleaning up files matching pattern: $glob"
95+
# remove the files from the build folder
96+
find build -name "$glob" -exec rm -rf {} \;
97+
done
9098
9199
# Build if windows
92100
- name: PyInstaller

programmer.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# -*- mode: python ; coding: utf-8 -*-
22

3+
from PyInstaller.utils.hooks import collect_system_data_files
4+
35
block_cipher = None
46

57
# needed for programming
68
added_datas = [
9+
('build', 'build'),
710
('esptool/flasher_stub/*.c', './flasher_stub/'),
811
('esptool/flasher_stub/*.py', './flasher_stub/'),
912
('esptool/flasher_stub/ld/*.ld', './flasher_stub/ld/'),
@@ -39,14 +42,15 @@ a = Analysis(['programmer.py'],
3942
win_private_assemblies=False,
4043
cipher=block_cipher,
4144
noarchive=False)
45+
4246
pyz = PYZ(a.pure, a.zipped_data,
4347
cipher=block_cipher)
4448

4549
exe = EXE(pyz,
4650
a.scripts,
4751
a.binaries,
4852
a.zipfiles,
49-
a.datas + Tree('build', 'build'),
53+
a.datas,
5054
name='programmer',
5155
debug=False,
5256
bootloader_ignore_signals=False,

0 commit comments

Comments
 (0)