Add note about too many punchbag DigiROMs (#182) #402
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Merge libs and compile CircuitPython files | |
on: | |
push: | |
pull_request: | |
release: | |
types: [published] | |
jobs: | |
merge_and_compile: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
platform: [nina, picow] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Write version_info | |
run: | | |
echo "# Added by build CI:" >> version_info.py | |
echo "version = '$(git describe --tags --always)'" >> version_info.py | |
echo "variant = '${{ matrix.platform }}'" >> version_info.py | |
- name: Install required packages | |
run: sudo apt-get update && sudo apt-get -y install python3 python3-pip | |
- name: JSON to variables | |
uses: antifree/json-to-variables@v1.0.1 | |
with: | |
filename: 'sources.json' | |
prefix: sources | |
- name: Download mpy-cross | |
env: | |
PLATFORM: ${{ matrix.platform }} | |
run: | | |
ver=$(eval echo "\$sources_circuitpython_${PLATFORM}") | |
echo "CircuitPython version: ${ver}" | |
curl "https://adafruit-circuit-python.s3.amazonaws.com/bin/mpy-cross/linux-amd64/mpy-cross-linux-amd64-${ver}.static" > mpy-cross | |
chmod +x mpy-cross | |
./mpy-cross --version | |
- name: Download and extract sources | |
env: | |
PLATFORM: ${{ matrix.platform }} | |
run: | | |
for key in dmcomm_python adafruit_bundle; do | |
value=$(eval echo "\$sources_$key") | |
echo "Downloading and extracting $key..." | |
wget $value -O sources_$key.zip | |
unzip -q sources_$key.zip -d sources_$key | |
echo "$key successfully downloaded and extracted." | |
done | |
key="circuitpython_minimqtt" | |
value=$(eval echo "\$sources_${key}_${PLATFORM}") | |
echo "Platform: $PLATFORM" | |
echo "Downloading and extracting $key for $PLATFORM..." | |
wget $value -O sources_${PLATFORM}_${key}.zip | |
unzip -q sources_${PLATFORM}_${key}.zip -d sources_${PLATFORM}_${key} | |
echo "$key for $PLATFORM successfully downloaded and extracted." | |
- name: Merge libs | |
env: | |
PLATFORM: ${{ matrix.platform }} | |
run: | | |
cp -r sources_dmcomm_python/*/lib/* lib/ | |
cp -r sources_adafruit_bundle/*/lib/adafruit_bus_device lib/ | |
cp -r sources_adafruit_bundle/*/lib/adafruit_display_text lib/ | |
cp -r sources_adafruit_bundle/*/lib/adafruit_displayio_ssd1306.mpy lib/ | |
cp -r sources_adafruit_bundle/*/lib/adafruit_requests.mpy lib/ | |
cp -r sources_adafruit_bundle/*/lib/adafruit_esp32spi lib/ | |
cp -r sources_${PLATFORM}_circuitpython_minimqtt/*/lib/* lib/ | |
- name: Compile CircuitPython files to .mpy files | |
run: | | |
for file in $(find ./lib -type f -name "*.py"); do | |
if [ -s $file ]; then | |
echo "Compiling $file..." | |
./mpy-cross $file | |
else | |
echo "Skipping $file because it is empty." | |
fi | |
done | |
- name: Delete original .py files in lib/ folder, except for empty ones | |
run: | | |
find ./lib -type f -name "*.py" | while read file; do | |
if [ -s $file ]; then | |
echo "Deleting $file because it is not empty." | |
rm $file | |
else | |
echo "Skipping $file because it is empty." | |
fi | |
done | |
- name: Concatenate Licenses | |
run: | | |
echo -e "\n\n\ndmcomm-python" >> LICENSE.txt | |
echo "https://github.com/dmcomm/dmcomm-python" >> LICENSE.txt | |
curl https://raw.githubusercontent.com/dmcomm/dmcomm-python/main/LICENSE.txt >> LICENSE.txt | |
echo -e "\n\n\nAdafruit_CircuitPython_Bundle" >> LICENSE.txt | |
echo "https://github.com/adafruit/Adafruit_CircuitPython_Bundle" >> LICENSE.txt | |
curl https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/LICENSE >> LICENSE.txt | |
echo -e "\n\n\nAdafruit_CircuitPython_MiniMQTT" >> LICENSE.txt | |
echo "https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT" >> LICENSE.txt | |
curl https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_MiniMQTT/main/LICENSE >> LICENSE.txt | |
- name: Remove unnecessary files | |
run: | | |
rm -rf sources_dmcomm_python sources_adafruit_bundle sources_nina_circuitpython_minimqtt sources_picow_circuitpython_minimqtt *.zip .git .github .gitignore .pylintrc mpy-cross | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: wificom_libs_merged_${{ matrix.platform }}.zip | |
path: . | |
- name: Create archive | |
env: | |
PLATFORM: ${{ matrix.platform }} | |
run: | | |
zip -r release.zip * | |
if [[ $GITHUB_REF =~ refs/tags/.* ]]; then | |
filename="wificom-lib_$(echo $GITHUB_REF | awk -F/ '{print $3}')_${PLATFORM}.zip" | |
else | |
filename="wificom-lib_${GITHUB_SHA}_${PLATFORM}.zip" | |
fi | |
mv release.zip $filename | |
echo "FILENAME=$filename" >> $GITHUB_ENV | |
shell: /usr/bin/bash -e {0} | |
- name: Configure AWS credentials | |
if: github.event_name == 'push' | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Upload to Amazon S3 | |
if: github.event_name == 'push' | |
run: | | |
aws s3 cp ${{ env.FILENAME }} s3://wificom-lib/archives/${{ env.FILENAME }} | |
- name: Attach to release | |
if: github.event_name == 'release' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ${{ env.FILENAME }} |