Skip to content

Commit

Permalink
Add github release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Dec 22, 2020
1 parent 24a1968 commit bcffb3b
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 0 deletions.
107 changes: 107 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: release

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*"

jobs:
core-pre-release-from-tag:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Checkout ArduinoCore-API
uses: actions/checkout@v2
with:
repository: arduino/ArduinoCore-API
path: extras/ArduinoCore-API

- name: Check if API should be compiled in the core
id: checkapi
run: |
if [[ $(grep -r api platform.txt) ]]; then echo "::set-output name=IS_API::true"; fi
- name: Checkout latest tag of ArduinoCore-API and add it to the core
run: |
cd extras/ArduinoCore-API
git fetch --tags
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
cd ../..
mv "$GITHUB_WORKSPACE/extras/ArduinoCore-API/api" "$GITHUB_WORKSPACE/cores/arduino"
if: steps.checkapi.outputs.IS_API == 'true'

- name: Remove ArduinoCore-API
run: rm -r "$GITHUB_WORKSPACE/extras/ArduinoCore-API"

- name: Set env
run: echo "TAG_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Get repo name
run: echo "REPOSITORY_NAME=$(echo ${{ github.repository }} | cut -d "/" -f2-)" >> $GITHUB_ENV

- name: Package the new core
run: |
extras/pack.release.bash $TAG_VERSION $REPOSITORY_NAME
cd extras
mkdir staging
echo $PWD
mv ../*.json staging/
mv ../*.tar.bz2 staging/
cd ..
- name: Get architecture name
run: |
echo "ARCHITECTURE=$(cat extras/package_index.json.NewTag.template | jq ".packages[0].platforms[0].architecture" | sed 's/\"//g')" >> $GITHUB_ENV
- name: Upload package_*_index.json and *.tar.bz2 file to Arduino downloads servers
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 sync extras/staging/ s3://${{ secrets.ARDUINO_DOWNLOADS_BUCKET }}/packages/staging/ --exclude "*" --include *.json
aws s3 sync extras/staging/ s3://${{ secrets.ARDUINO_DOWNLOADS_BUCKET }}/cores/staging/ --exclude "*" --include *.tar.bz2
- name: Checkout Basic examples
uses: actions/checkout@v2
with:
repository: arduino/arduino-examples
path: extras/arduino-examples

- name: Install Arduino CLI
uses: arduino/setup-arduino-cli@v1.1.1
with:
version: "0.14.0"

- name: Download and verify new core
run: |
export PATH=$PATH:$PWD
arduino-cli version
cp extras/staging/package_${REPOSITORY_NAME}_${TAG_VERSION}_index.json .
export ARDUINO_DIRECTORIES_DATA=$PWD
export ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS=file://$PWD/package_${REPOSITORY_NAME}_${TAG_VERSION}_index.json
arduino-cli config init
arduino-cli config dump -v
arduino-cli core update-index -v
arduino-cli core install arduino:${ARCHITECTURE}@${TAG_VERSION}
INDEX=0
arduino-cli board listall --format=json > boardlist.json
N=$(jq '.boards | length' boardlist.json)
let N=N-1
echo $N
for INDEX in $(seq 0 1 $N); do arduino-cli compile --fqbn $(cat boardlist.json | jq ".boards[$INDEX].FQBN" | sed 's/\"//g') $PWD/extras/arduino-examples/examples/01.Basics/Blink; done
# See: https://github.com/rtCamp/action-slack-notify
- name: Slack notification of core pre-release
uses: rtCamp/action-slack-notify@v2.1.0
env:
SLACK_CHANNEL: core_releases
SLACK_COLOR: good
SLACK_USERNAME: ArduinoBot
SLACK_ICON: https://github.com/arduino.png?size=48
SLACK_TITLE: Arduino core pre-release
SLACK_MESSAGE: 'Version ${{ env.TAG_VERSION }} of core ${{ env.REPOSITORY_NAME }} is now available'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true
56 changes: 56 additions & 0 deletions extras/pack.release.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash -ex

# pack.*.bash - Bash script to help packaging samd core releases.
# Copyright (c) 2015 Arduino LLC. All right reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

# Version check removed because version string passed from jenkins was incorrect
VERSION_FROM_TAG=$1
CORE_NAME=$2
echo $VERSION_FROM_TAG
echo $CORE_NAME
VERSION=`grep version= platform.txt | sed 's/version=//g'`
echo $VERSION

if [ $VERSION != $VERSION_FROM_TAG ]; then
exit 0
fi

PWD=`pwd`
FOLDERNAME=`basename $PWD`
THIS_SCRIPT_NAME=`basename $0`
FILENAME=core-$CORE_NAME-$VERSION.tar.bz2
echo $FILENAME

rm -f *.tar.bz2
rm -f *.json

cd ..
tar --exclude=extras/** --exclude=.git* --exclude=.idea -cjhf $FILENAME $FOLDERNAME
cd -

mv ../$FILENAME .

CHKSUM=`sha256sum $FILENAME | awk '{ print $1 }'`
SIZE=`wc -c $FILENAME | awk '{ print $1 }'`

cat extras/package_index.json.NewTag.template |
# sed "s/%%BUILD_NUMBER%%/${BUILD_NUMBER}/" |
# sed "s/%%CURR_TIME%%/${CURR_TIME_SED}/" |
sed "s/%%VERSION%%/${VERSION}/" |
sed "s/%%FILENAME%%/${FILENAME}/" |
sed "s/%%CHECKSUM%%/${CHKSUM}/" |
sed "s/%%SIZE%%/${SIZE}/" > package_${CORE_NAME}_${VERSION}_index.json
60 changes: 60 additions & 0 deletions extras/package_index.json.NewTag.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"packages": [
{
"name": "arduino",
"maintainer": "Arduino Betatesting",
"websiteURL": "http://www.arduino.cc/",
"email": "packages@arduino.cc",
"help": {
"online": "http://www.arduino.cc/en/Reference/HomePage"
},
"platforms": [
{
"name": "Arduino mbed-enabled Boards - Pre-release",
"architecture": "mbed",
"version": "%%VERSION%%",
"category": "Contributed",
"url": "http://downloads.arduino.cc/cores/staging/%%FILENAME%%",
"archiveFileName": "%%FILENAME%%",
"checksum": "SHA-256:%%CHECKSUM%%",
"size": "%%SIZE%%",
"help": {
"online": "https://github.com/arduino/ArduinoCore-mbed/issues"
},
"boards": [
{
"name": "Arduino Portenta H7"
},
{
"name": "Arduino Nano 33 BLE"
}
],
"toolsDependencies": [
{
"packager": "arduino",
"name": "openocd",
"version": "0.10.0-arduino13"
},
{
"packager": "arduino",
"name": "arm-none-eabi-gcc",
"version": "7-2017q4"
},
{
"packager": "arduino",
"name": "bossac",
"version": "1.9.1-arduino2"
},
{
"packager": "arduino",
"version": "0.9.0-arduino2",
"name": "dfu-util"
}
]
}
],
"tools": [
]
}
]
}

0 comments on commit bcffb3b

Please sign in to comment.