Skip to content

Commit

Permalink
Merge pull request #2 from pimoroni/actions
Browse files Browse the repository at this point in the history
Set up GitHub Actions
  • Loading branch information
Gadgetoid authored Jan 25, 2021
2 parents 7f5a0c2 + 923de33 commit 883d233
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 8 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: CMake

on:
push:
pull_request:
release:
types: [created]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
name: ${{matrix.name}}
strategy:
matrix:
include:
- os: ubuntu-20.04
name: Linux
cache-key: linux
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install'
apt-packages: clang-tidy gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib

runs-on: ${{matrix.os}}

env:
PICO_SDK_PATH: $GITHUB_WORKSPACE/pico-sdk
PIMORONI_PICO_LIBS: $GITHUB_WORKSPACE/pimoroni-pico
RELEASE_FILE: ${{github.event.repository.name}}-${{github.event.release.tag_name}}

steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
path: project

# Checkout the Pimoroni Pico Libraries
- name: Checkout Pimoroni Pico Libraries
uses: actions/checkout@v2
with:
repository: pimoroni/pimoroni-pico
path: pimoroni-pico

# Checkout the Pico SDK
- name: Checkout Pico SDK
uses: actions/checkout@v2
with:
repository: raspberrypi/pico-sdk
path: pico-sdk
submodules: true

# Link the Pico SDK via pico_sdk_import.cmake
- name: Link the Pico SDK to our proejct
shell: bash
working-directory: ${{github.workspace}}/project
run: |
rm -f pico_sdk_import.cmake
ln -s ../pico-sdk/external/pico_sdk_import.cmake pico_sdk_import.cmake
# Linux deps
- name: Install deps
if: runner.os == 'Linux'
run: |
sudo apt update && sudo apt install ${{matrix.apt-packages}}
- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE/project -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCPACK_PACKAGE_FILE_NAME=${{env.RELEASE_FILE}} ${{matrix.cmake-args}}

- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
cmake --build . --config $BUILD_TYPE -j 2
- name: Build Release Packages
if: github.event_name == 'release'
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
cmake --build . --config $BUILD_TYPE --target package -j 2
- name: Upload .zip
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
asset_path: ${{runner.workspace}}/build/${{env.RELEASE_FILE}}.zip
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{env.RELEASE_FILE}}.zip
asset_content_type: application/zip

- name: Upload .tar.gz
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
asset_path: ${{runner.workspace}}/build/${{env.RELEASE_FILE}}.tar.gz
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{env.RELEASE_FILE}}.tar.gz
asset_content_type: application/octet-stream
25 changes: 18 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
cmake_minimum_required(VERSION 3.12)

# Change your executable name to something creative!
set(NAME pico-boilerplate) # <-- Name your project/executable here!

# Make sure you symlink this file into the project directory
# eg: ln -s ../pico-sdk/external/pico_sdk_import.cmake .
include(pico_sdk_import.cmake)

# Change your executable name to something creative!
set(EXECUTABLE_NAME pico-boilerplate) # <-- Name your project/executable here!

# Gooey boilerplate
project(pico-boilerplate C CXX ASM)
project(${NAME} C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# Initialize the SDK
pico_sdk_init()

# Add your source files
add_executable(pico-boilerplate
add_executable(${NAME}
main.cpp # <-- Add source files here!
)

Expand All @@ -26,9 +26,20 @@ include(../pimoroni-pico/libraries/pico_explorer/pico_explorer.cmake)
# include(../pimoroni-pico/libraries/pico_display/pico_display.cmake)

# Don't forget to link the libraries you need!
target_link_libraries(pico-boilerplate
target_link_libraries(${NAME}
pico_explorer # <-- List libraries here!
)

# create map/bin/hex file etc.
pico_add_extra_outputs(pico-boilerplate)
pico_add_extra_outputs(${NAME})

# Set up files for the release packages
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${NAME}.uf2
${CMAKE_CURRENT_LIST_DIR}/README.md
DESTINATION .
)

set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_GENERATOR "ZIP" "TGZ")
include(CPack)
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main() {
pico_explorer.set_pen(255, 0, 0);

while(true) {
pico_explorer.pixel(point(0, 0));
pico_explorer.pixel(Point(0, 0));
// now we've done our drawing let's update the screen
pico_explorer.update();
}
Expand Down

0 comments on commit 883d233

Please sign in to comment.