Repository navigation
61 lines (59 loc) · 2.45 KB
/
Copy pathrelease.yml
File metadata and controls
61 lines (59 loc) · 2.45 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
name: Release Actions
on:
release:
types: [published]
jobs:
upload-release-assets:
runs-on: ubuntu-latest
steps:
- name: Translate Repo Name For Build Tools filename_prefix
id: repo-name
env:
REPO: ${{ github.repository }}
run: |
echo "repo-name=$(echo "$REPO" | awk -F '/' '{ print tolower($2) }' | tr '_' '-')" >> "$GITHUB_OUTPUT"
- name: Set up Python 3
uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Versions
run: |
python3 --version
- uses: actions/checkout@v6
with:
submodules: true
- name: Fetch correct submodule shas
run: git submodule foreach 'git fetch --tags --depth 1 origin $sha1 && git checkout -q $sha1'
- name: Install deps
run: |
sudo apt-get install -y gettext gawk
pip install -r requirements.txt
- name: Build assets
env:
# Passed as environment, not spliced into the script by the expression.
FILENAME_PREFIX: ${{ steps.repo-name.outputs.repo-name }}
run: |
# Computed in the step that consumes it. Going via $GITHUB_OUTPUT and an
# expression would put a directory name into the next step as script text:
# a newline in it writes extra variables to $GITHUB_OUTPUT, and a quote or
# backtick escapes whatever quoting that step uses. Held in a shell
# variable it stays exactly one argument.
prefix=$(
ls -RUx |
gawk -F '\n' '{ match($1, /(drivers|helpers)\/(.+)\/(.+)\:/, arr) ; if (length(arr[0]) > 0 && match(arr[3], arr[2]) > 0) printf "%s, ", arr[3] }' |
gawk '{ print substr($0, 1, length($0) - 2) }'
)
# An empty list is never correct: build-tools splits on ", " and matches
# with startswith(), and "".startswith("") is True, so an empty prefix
# would silently make every folder -- docs/, tests/, ci/ -- a package.
if [ -z "$prefix" ]; then
echo "::error::no package folders matched under libraries/; refusing to build an empty bundle"
exit 1
fi
circuitpython-build-bundles --filename_prefix "$FILENAME_PREFIX" --library_location libraries --library_depth 2 --package_folder_prefix "$prefix"
- name: Upload Release Assets
uses: shogo82148/actions-upload-release-asset@v1
with:
asset_path: "bundles/*"
github_token: ${{ secrets.GITHUB_TOKEN }}
upload_url: ${{ github.event.release.upload_url }}