diff --git a/Dockerfile b/Dockerfile index c32cc31..ea6d668 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,10 @@ -FROM ubuntu:20.04 +FROM alpine:latest -ARG MPLABX_VERSION=5.45 -ARG XC8_VERSION=1.34 +COPY docker-action /docker-action +COPY entrypoint.sh /entrypoint.sh -# Install the dependencies -# See https://microchipdeveloper.com/install:mplabx-lin64 -RUN dpkg --add-architecture i386 && \ - apt-get update && \ - apt-get install -y libc6:i386 libx11-6:i386 libxext6:i386 libstdc++6:i386 libexpat1:i386 wget sudo make && \ - apt-get clean && \ - apt-get autoremove && \ - rm -rf /var/lib/apt/lists/* +RUN ["chmod", "+x", "/entrypoint.sh"] -# Download and install XC8 -RUN wget -nv -O /tmp/xc8 "https://ww1.microchip.com/downloads/en/DeviceDoc/xc8-v${XC8_VERSION}-full-install-linux-installer.run" && \ - chmod +x /tmp/xc8 && \ - /tmp/xc8 --mode unattended --unattendedmodeui none --netservername localhost --LicenseType FreeMode --prefix "/opt/microchip/xc8/v${XC8_VERSION}" && \ - rm /tmp/xc8 +RUN apk add --update --no-cache docker -# Download and install MPLAB X -RUN wget -nv -O /tmp/mplabx "https://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v${MPLABX_VERSION}-linux-installer.tar" &&\ - cd /tmp && \ - tar -xf mplabx && \ - rm mplabx && \ - mv "MPLABX-v${MPLABX_VERSION}-linux-installer.sh" mplabx && \ - sudo ./mplabx --nox11 -- --unattendedmodeui none --mode unattended --ipe 0 --collectInfo 0 --installdir /opt/mplabx --16bitmcu 0 --32bitmcu 0 --othermcu 0 && \ - rm mplabx - -COPY build.sh /build.sh - -ENTRYPOINT [ "/build.sh" ] +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index c824f79..0132a0d 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,6 @@ This action will build a MPLAB X / XC8 project. -It runs on Linux Ubuntu 20.04 and uses: - -* [MPLAB X](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide) v5.45 -* [XC8](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers) v1.34 - ## Inputs ### `project` @@ -17,6 +12,14 @@ It runs on Linux Ubuntu 20.04 and uses: The configuration of the project to build. Defaults to `default`. +### `mplabx_version` + +The version of [MPLAB X](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide) to use. Defaults to `5.45`. + +### `xc8_version` + +The version of the [XC8 compiler](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers) to use. Defaults to `1.34`. + ## Outputs None. @@ -46,6 +49,8 @@ jobs: with: project: firmware.X configuration: default + mplabx_version: "5.45" + xc8_version: "2.20" ``` # Acknowledgements diff --git a/action.yml b/action.yml index 4ee80e7..9d9ac6e 100644 --- a/action.yml +++ b/action.yml @@ -11,9 +11,19 @@ inputs: description: Configuration to build required: true default: default + mplabx_version: + description: Version of MPLAB X to use + required: true + default: "5.45" + xc8_version: + description: Version of the XC8 compiler to use + required: true + default: "1.34" runs: using: docker image: Dockerfile args: + - ${{ inputs.mplabx_version }} + - ${{ inputs.xc8_version }} - ${{ inputs.project }} - ${{ inputs.configuration }} diff --git a/docker-action/Dockerfile b/docker-action/Dockerfile new file mode 100644 index 0000000..c8ed848 --- /dev/null +++ b/docker-action/Dockerfile @@ -0,0 +1,34 @@ +FROM ubuntu:20.04 + +ARG MPLABX_VERSION=5.45 +ARG XC8_VERSION=1.34 + +# Install the dependencies +# See https://microchipdeveloper.com/install:mplabx-lin64 +RUN dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y libc6:i386 libx11-6:i386 libxext6:i386 libstdc++6:i386 libexpat1:i386 wget sudo make && \ + apt-get clean && \ + apt-get autoremove && \ + rm -rf /var/lib/apt/lists/* + +# Download and install XC8 +RUN wget -nv -O /tmp/xc8 "https://ww1.microchip.com/downloads/en/DeviceDoc/xc8-v${XC8_VERSION}-full-install-linux-installer.run" && \ + chmod +x /tmp/xc8 && \ + /tmp/xc8 --mode unattended --unattendedmodeui none --netservername localhost --LicenseType FreeMode --prefix "/opt/microchip/xc8/v${XC8_VERSION}" && \ + rm /tmp/xc8 + +# Download and install MPLAB X +RUN wget -nv -O /tmp/mplabx "https://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v${MPLABX_VERSION}-linux-installer.tar" &&\ + cd /tmp && \ + tar -xf mplabx && \ + rm mplabx && \ + mv "MPLABX-v${MPLABX_VERSION}-linux-installer.sh" mplabx && \ + sudo ./mplabx --nox11 -- --unattendedmodeui none --mode unattended --ipe 0 --collectInfo 0 --installdir /opt/mplabx --16bitmcu 0 --32bitmcu 0 --othermcu 0 && \ + rm mplabx + +COPY build.sh /build.sh + +RUN ["chmod", "+x", "/build.sh"] + +ENTRYPOINT [ "/build.sh" ] diff --git a/build.sh b/docker-action/build.sh old mode 100755 new mode 100644 similarity index 68% rename from build.sh rename to docker-action/build.sh index 58f5034..1987442 --- a/build.sh +++ b/docker-action/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo "Building project $1:$2 with MPLAB X v5.45 and XC8 v1.34" +echo "Building project $1:$2" set -x -e diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..b329543 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/sh -l + +MPLABX_VERSION=$1 +XC8_VERSION=$2 +PROJECT=$3 +CONFIGURATION=$4 + +cd /docker-action +echo "Creating a docker image with MPLAB X version ${MPLABX_VERSION} and XC8 version ${XC8_VERSION}" + +# Here we can make the construction of the image as customizable as we need +# and if we need parameterizable values it is a matter of sending them as inputs +docker build \ + -t docker-action \ + --build-arg MPLABX_VERSION="${MPLABX_VERSION}" \ + --build-arg XC8_VERSION="${XC8_VERSION}" \ + . \ + && cd .. \ + && docker run -v "$(pwd):/github/workspace" --workdir /github/workspace docker-action "${PROJECT}" "${CONFIGURATION}"