Fix CORS request for the web installer #49
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
# | |
# Copyright 2022 Fred Dushin <fred@dushin.net> | |
# | |
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | |
# | |
name: esp32-mkimage | |
on: | |
push: | |
paths: | |
- '.github/workflows/esp32-mkimage.yaml' | |
pull_request: | |
paths: | |
- '.github/workflows/esp32-mkimage.yaml' | |
- 'src/**' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/master' && github.ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
container: espressif/idf:v${{ matrix.idf-version }} | |
strategy: | |
matrix: | |
idf-version: ["5.2"] | |
cc: ["clang-15"] | |
cxx: ["clang++-15"] | |
cflags: ["-O3"] | |
otp: ["26"] | |
elixir_version: ["1.16"] | |
compiler_pkgs: ["clang-15"] | |
soc: ["esp32c3"] | |
env: | |
CC: ${{ matrix.cc }} | |
CXX: ${{ matrix.cxx }} | |
CFLAGS: ${{ matrix.cflags }} | |
CXXFLAGS: ${{ matrix.cflags }} | |
ImageOS: "ubuntu22" | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ matrix.otp }} | |
elixir-version: ${{ matrix.elixir_version }} | |
rebar3-version: '3.23.0' | |
- name: "Install dependencies" | |
run: | | |
apt update -y | |
DEBIAN_FRONTEND=noninteractive apt install -y ${{ matrix.compiler_pkgs}} git cmake gperf zlib1g-dev | |
# needed for generating AtomVM version when running in a docker container | |
- name: "Configure Git" | |
run: | | |
git config --global --add safe.directory /__w/c3card/c3card | |
echo -n "git rev-parse: " | |
git rev-parse --short HEAD | |
# Builder info | |
- name: "System info" | |
run: | | |
echo "**uname:**" | |
uname -a | |
echo "**libc version:**" | |
ldd --version | |
echo "**C Compiler version:**" | |
$CC --version | |
$CXX --version | |
echo "**Linker version:**" | |
ld --version | |
echo "**CMake version:**" | |
cmake --version | |
echo "**OTP version:**" | |
cat $(dirname $(which erlc))/../releases/RELEASES || true | |
- name: "Clone AtomVM" | |
run: | | |
git clone https://github.com/atomvm/AtomVM | |
- name: "Build: create build dir" | |
run: mkdir build | |
- name: "Build: run cmake" | |
working-directory: build | |
run: | | |
cmake ../AtomVM | |
# git clone will use more recent timestamps than cached beam files | |
# touch them so we can benefit from the cache and avoid costly beam file rebuild. | |
find . -name '*.beam' -exec touch {} \; | |
- name: "Build erlang and Elixir libs" | |
working-directory: build/libs | |
run: | | |
LANG=en_US.UTF-8 make | |
- name: "Build the c3card firmware" | |
working-directory: . | |
run: | | |
rebar3 atomvm packbeam | |
- name: "Copy mkimage.config.in template" | |
working-directory: . | |
run: | | |
cp ./installer/mkimage.config.in ./AtomVM/src/platforms/esp32/tools/ | |
- name: "Use release defaults" | |
if: startsWith(github.ref, 'refs/tags/') | |
shell: bash | |
working-directory: ./AtomVM/src/platforms/esp32/ | |
run: | | |
cp sdkconfig.release-defaults sdkconfig.defaults | |
- name: "Clone required components" | |
shell: bash | |
working-directory: ./AtomVM/src/platforms/esp32/components/ | |
run: | | |
git clone https://github.com/atomvm/atomvm_neopixel | |
git clone https://github.com/atomvm/atomvm_mqtt_client | |
git clone --branch resource_nif https://github.com/arpunk/atomvm_adc | |
- name: "Build ${{ matrix.soc }} with idf.py" | |
shell: bash | |
working-directory: ./AtomVM/src/platforms/esp32/ | |
run: | | |
rm -rf build | |
. $IDF_PATH/export.sh | |
idf.py set-target ${{ matrix.soc }} | |
idf.py reconfigure | |
idf.py build | |
- name: "Create a ${{ matrix.soc }} image" | |
working-directory: ./AtomVM/src/platforms/esp32/build | |
run: | | |
./mkimage.sh | |
ls -l *.img | |
- name: "Upload ${{ matrix.soc }} artifacts" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: atomvm-c3card-${{ matrix.soc }}-image | |
path: ./AtomVM/src/platforms/esp32/build/atomvm-${{ matrix.soc }}.img | |
if-no-files-found: error | |
- name: "Rename and write sha256sum" | |
shell: bash | |
working-directory: ./AtomVM/src/platforms/esp32/build | |
run: | | |
ATOMVM_IMG="AtomVM-c3card-${{ matrix.soc }}-${{ github.ref_name }}.img" | |
mv atomvm-${{ matrix.soc }}.img "${ATOMVM_IMG}" | |
sha256sum "${ATOMVM_IMG}" > "${ATOMVM_IMG}.sha256" | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
fail_on_unmatched_files: true | |
files: | | |
./AtomVM/src/platforms/esp32/build/AtomVM-c3card-${{ matrix.soc }}-${{ github.ref_name }}.img | |
./AtomVM/src/platforms/esp32/build/AtomVM-c3card-${{ matrix.soc }}-${{ github.ref_name }}.img.sha256 | |
publish: | |
name: "Publish new firmware and website to GitHub Pages" | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: [build-and-release] | |
strategy: | |
matrix: | |
idf-version: ["5.2"] | |
cc: ["clang-15"] | |
cxx: ["clang++-15"] | |
cflags: ["-O3"] | |
otp: ["26"] | |
elixir_version: ["1.16"] | |
compiler_pkgs: ["clang-15"] | |
soc: ["esp32c3"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Setup Erlang | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: '26.2' | |
rebar3-version: '3.23.0' | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Generate documentation | |
run: | | |
rebar3 ex_doc | |
- uses: actions/download-artifact@v4 | |
with: | |
name: atomvm-c3card-${{ matrix.soc }}-image | |
path: output | |
- name: Create manifest.json | |
run: | | |
ATOMVM_IMG="AtomVM-${{ matrix.soc }}-${{ github.ref_name }}.img" | |
jq -n \ | |
--arg name "AtomVM-c3card-${{ matrix.soc }}-${{ github.ref_name }}" \ | |
--arg version "${{ github.run_number }}" \ | |
'{"name": $name, "version": $version, "files": [{"path": "AtomVM-c3card-${{ matrix.soc }}-${{ github.ref_name }}.img", "sha256": "$(cat ./output/AtomVM-c3card-${{ matrix.soc }}-${{ github.ref_name }}.img.sha256)"}]}' > doc/manifest.json | |
ls -R . | |
mv output/atomvm-${{ matrix.soc }}.img doc/"${ATOMVM_IMG}" | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: doc | |
- name: Deploy to Github Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |