From ddc1251dc8fd32ab8dbc4340859e5eab9377eaf0 Mon Sep 17 00:00:00 2001 From: Alexis Jeandeau Date: Tue, 8 Jun 2021 21:24:36 +0900 Subject: [PATCH 1/7] Make the MPLAB X and XC8 versions parameters of the Action --- Dockerfile | 34 +++++------------------------- README.md | 15 ++++++++----- action.yml | 10 +++++++++ docker-action/Dockerfile | 32 ++++++++++++++++++++++++++++ build.sh => docker-action/build.sh | 2 +- entrypoint.sh | 18 ++++++++++++++++ 6 files changed, 76 insertions(+), 35 deletions(-) create mode 100644 docker-action/Dockerfile rename build.sh => docker-action/build.sh (68%) mode change 100755 => 100644 create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index c32cc31..074874c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,8 @@ -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 apk add --update --no-cache docker -# 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 - -ENTRYPOINT [ "/build.sh" ] +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index c824f79..d926fa5 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`. +### `mplab_x_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 + mplab_x_version: "5.45" + xc8_version: "2.20" ``` # Acknowledgements diff --git a/action.yml b/action.yml index 4ee80e7..c52c123 100644 --- a/action.yml +++ b/action.yml @@ -11,9 +11,19 @@ inputs: description: Configuration to build required: true default: default + mplab_x_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.mplab_x_version }} + - ${{ inputs.xc8_version }} - ${{ inputs.project }} - ${{ inputs.configuration }} diff --git a/docker-action/Dockerfile b/docker-action/Dockerfile new file mode 100644 index 0000000..c32cc31 --- /dev/null +++ b/docker-action/Dockerfile @@ -0,0 +1,32 @@ +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 + +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 100644 index 0000000..a046ffe --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh -l + +MPLAB_X_VERSION=$1 +XC8_VERSION=$2 +PROJECT=$3 +CONFIGURATION=$4 + +cd /docker-action +echo "Creating a docker image with MPLAB X version ${MPLAB_X_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 mplab_x_version="${MPLAB_X_VERSION}" \ + --build-arg xc8_version="${XC8_VERSION}" \ + . \ + && docker run docker-action From 57dff667d0ded54293c25f11f9feea285e38b8e8 Mon Sep 17 00:00:00 2001 From: Alexis Jeandeau Date: Tue, 8 Jun 2021 21:35:08 +0900 Subject: [PATCH 2/7] Make the entrypoint executable --- entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 From ecde8aebf7caf0f1ac7cce28df4bdd5cb36bac9a Mon Sep 17 00:00:00 2001 From: Alexis Jeandeau Date: Tue, 8 Jun 2021 21:37:45 +0900 Subject: [PATCH 3/7] mplab_x -> mplabx --- README.md | 4 ++-- action.yml | 4 ++-- entrypoint.sh | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d926fa5..0132a0d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This action will build a MPLAB X / XC8 project. The configuration of the project to build. Defaults to `default`. -### `mplab_x_version` +### `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`. @@ -49,7 +49,7 @@ jobs: with: project: firmware.X configuration: default - mplab_x_version: "5.45" + mplabx_version: "5.45" xc8_version: "2.20" ``` diff --git a/action.yml b/action.yml index c52c123..9d9ac6e 100644 --- a/action.yml +++ b/action.yml @@ -11,7 +11,7 @@ inputs: description: Configuration to build required: true default: default - mplab_x_version: + mplabx_version: description: Version of MPLAB X to use required: true default: "5.45" @@ -23,7 +23,7 @@ runs: using: docker image: Dockerfile args: - - ${{ inputs.mplab_x_version }} + - ${{ inputs.mplabx_version }} - ${{ inputs.xc8_version }} - ${{ inputs.project }} - ${{ inputs.configuration }} diff --git a/entrypoint.sh b/entrypoint.sh index a046ffe..232f461 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,18 +1,18 @@ #!/bin/sh -l -MPLAB_X_VERSION=$1 +MPLABX_VERSION=$1 XC8_VERSION=$2 PROJECT=$3 CONFIGURATION=$4 cd /docker-action -echo "Creating a docker image with MPLAB X version ${MPLAB_X_VERSION} and XC8 version ${XC8_VERSION}" +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 mplab_x_version="${MPLAB_X_VERSION}" \ - --build-arg xc8_version="${XC8_VERSION}" \ + --build-arg MPLABX_VERSION="${MPLABX_VERSION}" \ + --build-arg XC8_VERSION="${XC8_VERSION}" \ . \ && docker run docker-action From f203273b80a20948285cd7200f6cf6c769fa67eb Mon Sep 17 00:00:00 2001 From: Alexis Jeandeau Date: Tue, 8 Jun 2021 21:55:40 +0900 Subject: [PATCH 4/7] Make sure the entrypoints are executable --- Dockerfile | 2 ++ docker-action/Dockerfile | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 074874c..ea6d668 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM alpine:latest COPY docker-action /docker-action COPY entrypoint.sh /entrypoint.sh +RUN ["chmod", "+x", "/entrypoint.sh"] + RUN apk add --update --no-cache docker ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker-action/Dockerfile b/docker-action/Dockerfile index c32cc31..c8ed848 100644 --- a/docker-action/Dockerfile +++ b/docker-action/Dockerfile @@ -29,4 +29,6 @@ RUN wget -nv -O /tmp/mplabx "https://ww1.microchip.com/downloads/en/DeviceDoc/MP COPY build.sh /build.sh +RUN ["chmod", "+x", "/build.sh"] + ENTRYPOINT [ "/build.sh" ] From 89c92133094c718d7bf9fa24a0c107b121e045ea Mon Sep 17 00:00:00 2001 From: Alexis Jeandeau Date: Tue, 8 Jun 2021 22:02:01 +0900 Subject: [PATCH 5/7] Pass the project and configuration to docker run --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 232f461..b229d6e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -15,4 +15,4 @@ docker build \ --build-arg MPLABX_VERSION="${MPLABX_VERSION}" \ --build-arg XC8_VERSION="${XC8_VERSION}" \ . \ - && docker run docker-action + && docker run docker-action "${PROJECT}" "${CONFIGURATION}" From e8dbda80befa8ba42e140c4dac47e0665158bfbc Mon Sep 17 00:00:00 2001 From: Alexis Jeandeau Date: Tue, 8 Jun 2021 22:13:53 +0900 Subject: [PATCH 6/7] Mount the folder as a volume to be able to build the project --- entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index b229d6e..4c8758c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -15,4 +15,5 @@ docker build \ --build-arg MPLABX_VERSION="${MPLABX_VERSION}" \ --build-arg XC8_VERSION="${XC8_VERSION}" \ . \ - && docker run docker-action "${PROJECT}" "${CONFIGURATION}" + && cd .. \ + && docker run docker-action -v "$(pwd):/app" "/app/${PROJECT}" "${CONFIGURATION}" From 1a9b1c59cc4b0f3ea5636c90a0fe55122c40f694 Mon Sep 17 00:00:00 2001 From: Alexis Jeandeau Date: Tue, 8 Jun 2021 22:24:16 +0900 Subject: [PATCH 7/7] Fix the order of the arguments for docker run --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4c8758c..b329543 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,4 +16,4 @@ docker build \ --build-arg XC8_VERSION="${XC8_VERSION}" \ . \ && cd .. \ - && docker run docker-action -v "$(pwd):/app" "/app/${PROJECT}" "${CONFIGURATION}" + && docker run -v "$(pwd):/github/workspace" --workdir /github/workspace docker-action "${PROJECT}" "${CONFIGURATION}"