Skip to content

Commit f53aef0

Browse files
tyethclaude
andcommitted
release: compute the prefix in the step that uses it, and sync action versions
The previous commit guarded the symptom. The structure was the problem: the prefix went out through $GITHUB_OUTPUT and came back as a ${{ }} expression, which GitHub splices into the next run: block as script text before any shell parses it. That hop is worse than what it replaced. The original 'echo prefix=$( ... )' used an unquoted command substitution, so word splitting collapsed newlines into spaces and only ever one line reached $GITHUB_OUTPUT. Assigning to a variable and echoing it quoted preserves them: a directory name containing a newline writes extra variables into $GITHUB_OUTPUT, which then chain into the next step. Measured: old form 1 line, new form 3. So drop the hop. The prefix is computed in the Build assets step and passed as "$prefix" -- real shell quoting this time, since bash does the expansion rather than the templating engine. filename_prefix comes in through env for the same reason. No expression is now spliced into any run: block, and the character allowlist added in the previous commit is no longer load-bearing, so it goes. Also takes upstream's actions/checkout@v6 and actions/setup-python@v6, which is what the Node 20 deprecation notice on our runs was about. The upstream AWS S3 upload step is deliberately not adopted: it targets Adafruit's bucket. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 33c7c06 commit f53aef0

2 files changed

Lines changed: 17 additions & 22 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Set up Python 3
10-
uses: actions/setup-python@v4
10+
uses: actions/setup-python@v6
1111
with:
1212
python-version: 3.x
1313
- name: Versions
1414
run: |
1515
python3 --version
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v6
1717
with:
1818
submodules: true
1919
- name: Fetch correct submodule shas

.github/workflows/release.yml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,18 @@ jobs:
1010
steps:
1111
- name: Translate Repo Name For Build Tools filename_prefix
1212
id: repo-name
13+
env:
14+
REPO: ${{ github.repository }}
1315
run: |
14-
echo "repo-name=$(
15-
echo ${{ github.repository }} |
16-
awk -F '\/' '{ print tolower($2) }' |
17-
tr '_' '-'
18-
)" >> $GITHUB_OUTPUT
16+
echo "repo-name=$(echo "$REPO" | awk -F '/' '{ print tolower($2) }' | tr '_' '-')" >> "$GITHUB_OUTPUT"
1917
- name: Set up Python 3
20-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v6
2119
with:
2220
python-version: 3.x
2321
- name: Versions
2422
run: |
2523
python3 --version
26-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v6
2725
with:
2826
submodules: true
2927
- name: Fetch correct submodule shas
@@ -32,9 +30,16 @@ jobs:
3230
run: |
3331
sudo apt-get install -y gettext gawk
3432
pip install -r requirements.txt
35-
- name: Package Folder Prefix For circuitpython-build-tools (Community Bundle Specific)
36-
id: pkg-folder
33+
- name: Build assets
34+
env:
35+
# Passed as environment, not spliced into the script by the expression.
36+
FILENAME_PREFIX: ${{ steps.repo-name.outputs.repo-name }}
3737
run: |
38+
# Computed in the step that consumes it. Going via $GITHUB_OUTPUT and an
39+
# expression would put a directory name into the next step as script text:
40+
# a newline in it writes extra variables to $GITHUB_OUTPUT, and a quote or
41+
# backtick escapes whatever quoting that step uses. Held in a shell
42+
# variable it stays exactly one argument.
3843
prefix=$(
3944
ls -RUx |
4045
gawk -F '\n' '{ match($1, /(drivers|helpers)\/(.+)\/(.+)\:/, arr) ; if (length(arr[0]) > 0 && match(arr[3], arr[2]) > 0) printf "%s, ", arr[3] }' |
@@ -47,17 +52,7 @@ jobs:
4752
echo "::error::no package folders matched under libraries/; refusing to build an empty bundle"
4853
exit 1
4954
fi
50-
# ${{ }} splices this into the later run: block as text, before any shell
51-
# sees it, so the quotes there cannot contain a folder name carrying a
52-
# quote or a backtick. Allow only what a module name can be.
53-
case "$prefix" in
54-
*[!A-Za-z0-9_, -]*)
55-
echo "::error::unexpected character in package folder list: $prefix"
56-
exit 1 ;;
57-
esac
58-
echo "prefix=$prefix" >> "$GITHUB_OUTPUT"
59-
- name: Build assets
60-
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location libraries --library_depth 2 --package_folder_prefix "${{ steps.pkg-folder.outputs.prefix }}"
55+
circuitpython-build-bundles --filename_prefix "$FILENAME_PREFIX" --library_location libraries --library_depth 2 --package_folder_prefix "$prefix"
6156
- name: Upload Release Assets
6257
uses: shogo82148/actions-upload-release-asset@v1
6358
with:

0 commit comments

Comments
 (0)