Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the user to set the MPLAB X and XC8 version as parameters #3

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 6 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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.
Expand Down Expand Up @@ -46,6 +49,8 @@ jobs:
with:
project: firmware.X
configuration: default
mplabx_version: "5.45"
xc8_version: "2.20"
```

# Acknowledgements
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
34 changes: 34 additions & 0 deletions docker-action/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
2 changes: 1 addition & 1 deletion build.sh → docker-action/build.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -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

Expand Down
19 changes: 19 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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}"