Unverified Commit ed96d2a1 authored by Me No Dev's avatar Me No Dev Committed by GitHub

Use Github Actions for release (#3309)

* move scripts and tone down travis

* Update and rename main.yml to push.yml

* Create release.yml
parent caa391ab
......@@ -28,11 +28,14 @@ elif [ "$CHUNK_INDEX" -eq "$CHUNKS_CNT" ]; then
BUILD_PIO=1
fi
echo "Updating submodules ..."
git -C "$GITHUB_WORKSPACE" submodule update --init --recursive > /dev/null 2>&1
if [ "$BUILD_PIO" -eq 0 ]; then
# ArduinoIDE Test
FQBN="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app"
source ./tools/ci/install-arduino-ide.sh
source ./tools/ci/install-arduino-core-esp32.sh
source ./.github/scripts/install-arduino-ide.sh
source ./.github/scripts/install-arduino-core-esp32.sh
if [ "$OS_IS_WINDOWS" == "1" ]; then
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/BLE/examples/BLE_server/BLE_server.ino" && \
......@@ -48,14 +51,14 @@ if [ "$BUILD_PIO" -eq 0 ]; then
else
# CMake Test
if [ "$CHUNK_INDEX" -eq 0 ]; then
bash "$ARDUINO_ESP32_PATH/tools/ci/check-cmakelists.sh"
bash "$ARDUINO_ESP32_PATH/.github/scripts/check-cmakelists.sh"
if [ $? -ne 0 ]; then exit 1; fi
fi
build_sketches "$FQBN" "$ARDUINO_ESP32_PATH/libraries" "$CHUNK_INDEX" "$CHUNKS_CNT"
fi
else
# PlatformIO Test
source ./tools/ci/install-platformio-esp32.sh
source ./.github/scripts/install-platformio-esp32.sh
BOARD="esp32dev"
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient/WiFiClient.ino" && \
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
......
This diff is collapsed.
......@@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build Sketches
run: bash ./tools/ci/on-push.sh ${{ matrix.chunk }} 15
run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} 15
# Windows and MacOS
build-arduino-win-mac:
......@@ -33,7 +33,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build Sketches
run: bash ./tools/ci/on-push.sh
run: bash ./.github/scripts/on-push.sh
# PlatformIO on Windows, Ubuntu and Mac
build-platformio:
......@@ -46,4 +46,4 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build Sketches
run: bash ./tools/ci/on-push.sh 1 1 #equal and non-zero to trigger PIO
run: bash ./.github/scripts/on-push.sh 1 1 #equal and non-zero to trigger PIO
name: ESP32 Arduino Release
on:
release:
types: published
jobs:
build:
name: Publish Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Build Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bash ./.github/scripts/on-release.sh
......@@ -21,42 +21,27 @@ jobs:
- name: "Build Arduino 0"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/tools/ci/on-push.sh 0 4
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 0 10
- name: "Build Arduino 1"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/tools/ci/on-push.sh 1 4
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 1 10
- name: "Build Arduino 2"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/tools/ci/on-push.sh 2 4
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 2 10
- name: "Build Arduino 3"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/tools/ci/on-push.sh 3 4
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 3 10
- name: "Build PlatformIO"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/tools/ci/on-push.sh 4 4
- name: "Package & Deploy"
if: tag IS present
stage: deploy
env:
- secure: "l/4Dt+KQ/mACtGAHDUsPr66fUte840PZoQ4xpPikqWZI0uARu4l+Ym7+sHinnT6fBqrj8AJeBYGz4nFa8NK4LutZn9mSD40w+sxl0wSV4oHV8rzKe3Cd8+sMG3+o33yWoikMNjSvqa73Q0rm+SgrlInNdZbuAyixL+a2alaWSnGPm4F2xwUGj+S33TOy5P/Xp77CYtCV5S8vzyk/eEdNhoF0GYePJVdfuzCOUjXMyT5OWxORkzzQ7Hnn/Ka/RDfV8Si4HgujLQBrK5q6iPnNBFqBSqilYBepSMn4opnOBpIm0SCgePz7XQEFC83buA7GUcnCnfg38bf+dCwHaODf1d1PmqVRYt2QmfinexXtM4afAtL0iBUDtvrfnXHzwW9w82VeZhpbJSVh9DUQvB0IlsZeCz9J9PUBAi3N+SMX+9l+BomYwRUlPuKY+Ef2JKk9q6mxtUkky5R0daAlVxEhpVdQks1rT+T+NMoDMemxQ3SKEiqAHh6EgHecruszffmZ71uLX9MpERpew0qN+UFiafws+jkTjx+3yF9yut0Hf9sMbeAYzzkGzRqJTUEBJ6B29Cql8M0yRXCNN/8wuuTHhG8esstozga4ZQoIVrq7mEAgup376PTcNfr1+imbbWVQ7lJdYIuDe6OS5V3OX6np11vgK/DbhfyzvQv9Z1zAGnM="
- REMOTE_URL=https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG
script: bash $TRAVIS_BUILD_DIR/tools/ci/build-release.sh -a$ESP32_GITHUB_TOKEN
before_deploy: git submodule update --init
deploy:
- provider: script
skip_cleanup: true
script: bash $TRAVIS_BUILD_DIR/tools/ci/deploy-release.sh -t$TRAVIS_TAG -a$ESP32_GITHUB_TOKEN -s$TRAVIS_REPO_SLUG -drelease
on:
tags: true
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 1 1
notifications:
email:
......
build: off
environment:
matrix:
- PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiClient"
- PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiClientBasic"
- PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiClientEvents"
- PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiIPv6"
- PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiScan"
- PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiSmartConfig"
install:
- cmd: git submodule update --init --recursive
- cmd: SET PATH=%PATH%;C:\Python27\Scripts
- cmd: pip install -U https://github.com/platformio/platformio/archive/develop.zip
- cmd: platformio platform install https://github.com/platformio/platform-espressif32.git#feature/stage
test_script:
- cmd: platformio ci -b esp32dev -b nano32 -b node32s
This diff is collapsed.
#!/bin/bash
json_escape () {
printf '%s' "$1" | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))'
#printf '%s' "$1" | php -r 'echo json_encode(file_get_contents("php://stdin"));'
}
set -e
#Cmdline options
# -t: tag (*_RC* determines prerelease version, can be overriden be -p)
# -a: GitHub API access token
# -s: GitHub repository slug (user/repo)
# -p: prerelease true/false
# -f: files to upload (ie assets. delim = ';', must come quoted)
# -d: directory to upload (by adding dir contents to assets)
while getopts ":t:,:a:,:s:,:p:,:f:,:d:" opt; do
case $opt in
t)
varTagName=$OPTARG
echo "TAG: $varTagName" >&2
;;
a)
varAccessToken=$OPTARG
echo "ACCESS TOKEN: $varAccessToken" >&2
;;
s)
varRepoSlug=$OPTARG
echo "REPO SLUG: $varRepoSlug" >&2
;;
p)
varPrerelease=$OPTARG
echo "PRERELEASE: $varPrerelease" >&2
;;
f)
varAssets=$OPTARG
echo "ASSETS: $varAssets" >&2
;;
d)
varAssetsDir=$OPTARG
echo "ASSETS DIR: $varAssetsDir" >&2
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
# use TravisCI env as default, if available
if [ -z $varTagName ] && [ ! -z $TRAVIS_TAG ]; then
varTagName=$TRAVIS_TAG
fi
if [ -z $varTagName ]; then
echo "No tag name available => aborting"
exit 1
fi
#Check tag name for release/prerelease (prerelease tag contains '_RC' as for release-candidate. case-insensitive)
shopt -s nocasematch
if [ -z $varPrerelease ]; then
if [[ $varTagName == *-RC* ]]; then
varPrerelease=true
else
varPrerelease=false
fi
fi
shopt -u nocasematch
#
# Prepare Markdown release notes:
#################################
# - annotated tags only, lightweight tags just display message of referred commit
# - tag's description conversion to relnotes:
# first 3 lines (tagname, commiter, blank): ignored
# 4th line: relnotes heading
# remaining lines: each converted to bullet-list item
# empty lines ignored
# if '* ' found as a first char pair, it's converted to '- ' to keep bulleting unified
echo
echo Preparing release notes
echo -----------------------
echo "Tag's message:"
relNotesRaw=`git show -s --format=%b $varTagName`
readarray -t msgArray <<<"$relNotesRaw"
arrLen=${#msgArray[@]}
#process annotated tags only
if [ $arrLen > 3 ] && [ "${msgArray[0]:0:3}" == "tag" ]; then
ind=3
while [ $ind -lt $arrLen ]; do
if [ $ind -eq 3 ]; then
releaseNotes="#### ${msgArray[ind]}"
releaseNotes+=$'\r\n'
else
oneLine="$(echo -e "${msgArray[ind]}" | sed -e 's/^[[:space:]]*//')"
if [ ${#oneLine} -gt 0 ]; then
if [ "${oneLine:0:2}" == "* " ]; then oneLine=$(echo ${oneLine/\*/-}); fi
if [ "${oneLine:0:2}" != "- " ]; then releaseNotes+="- "; fi
releaseNotes+="$oneLine"
releaseNotes+=$'\r\n'
#debug output
echo " ${oneLine}"
fi
fi
let ind=$ind+1
done
fi
echo "$releaseNotes"
# - list of commits (commits.txt must exit in the output dir)
commitFile=$varAssetsDir/commits.txt
if [ -s "$commitFile" ]; then
releaseNotes+=$'\r\n##### Commits\r\n'
echo
echo "Commits:"
IFS=$'\n'
for next in `cat $commitFile`
do
IFS=' ' read -r commitId commitMsg <<< "$next"
commitLine="- [$commitId](https://github.com/$varRepoSlug/commit/$commitId) $commitMsg"
echo " $commitLine"
releaseNotes+="$commitLine"
releaseNotes+=$'\r\n'
done
rm -f $commitFile
fi
# Check possibly existing release for current tag
echo
echo "Processing GitHub release record for $varTagName:"
echo "-------------------------------------------------"
echo " - check $varTagName possible existence..."
# (eg build invoked by Create New Release GHUI button -> GH default release pack created immediately including default assests)
HTTP_RESPONSE=$(curl -L --silent --write-out "HTTPSTATUS:%{http_code}" https://api.github.com/repos/$varRepoSlug/releases/tags/$varTagName?access_token=$varAccessToken)
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
echo " ---> GitHub server HTTP response: $HTTP_STATUS"
# if the release exists, append/update recent files to its assets vector
if [ $HTTP_STATUS -eq 200 ]; then
releaseId=$(echo $HTTP_BODY | jq -r '.id')
echo " - $varTagName release found (id $releaseId)"
#Merge release notes and overwrite pre-release flag. all other attributes remain unchanged:
# 1. take existing notes from server (added by release creator)
releaseNotesGH=$(echo $HTTP_BODY | jq -r '.body')
# - strip possibly trailing CR
if [ "${releaseNotesGH: -1}" == $'\r' ]; then
releaseNotesTemp="${releaseNotesGH:0:-1}"
else
releaseNotesTemp="$releaseNotesGH"
fi
# - add CRLF to make relnotes consistent for JSON encoding
releaseNotesTemp+=$'\r\n'
# 2. #append generated relnotes (usually commit oneliners)
releaseNotes="$releaseNotesTemp$releaseNotes"
# 3. JSON-encode whole string for GH API transfer
releaseNotes=$(json_escape "$releaseNotes")
# 4. remove extra quotes returned by python (dummy but whatever)
releaseNotes=${releaseNotes:1:-1}
#Update current GH release record
echo " - updating release notes and pre-release flag:"
curlData="{\"body\": \"$releaseNotes\",\"prerelease\": $varPrerelease}"
echo " <data.begin>$curlData<data.end>"
echo
#echo "DEBUG: curl --data \"$curlData\" https://api.github.com/repos/$varRepoSlug/releases/$releaseId?access_token=$varAccessToken"
curl --data "$curlData" https://api.github.com/repos/$varRepoSlug/releases/$releaseId?access_token=$varAccessToken
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
echo " - $varTagName release record successfully updated"
#... or create a new release record
else
releaseNotes=$(json_escape "$releaseNotes")
releaseNotes=${releaseNotes:1:-1}
echo " - release $varTagName not found, creating a new record:"
curlData="{\"tag_name\": \"$varTagName\",\"target_commitish\": \"master\",\"name\": \"v$varTagName\",\"body\": \"$releaseNotes\",\"draft\": false,\"prerelease\": $varPrerelease}"
echo " <data.begin>$curlData<data.end>"
#echo "DEBUG: curl --data \"${curlData}\" https://api.github.com/repos/${varRepoSlug}/releases?access_token=$varAccessToken | jq -r '.id'"
releaseId=$(curl --data "$curlData" https://api.github.com/repos/$varRepoSlug/releases?access_token=$varAccessToken | jq -r '.id')
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
echo " - $varTagName release record successfully created (id $releaseId)"
fi
# Assets defined by dir contents
if [ ! -z $varAssetsDir ]; then
varAssetsTemp=$(ls -p $varAssetsDir | grep -v / | tr '\n' ';')
for item in $(echo $varAssetsTemp | tr ";" "\n")
do
varAssets+=$varAssetsDir/$item;
varAssets+=';'
done
fi
#Upload additional assets
if [ ! -z $varAssets ]; then
echo
echo "Uploading assets:"
echo "-----------------"
echo " Files to upload:"
echo " $varAssets"
echo
curlAuth="Authorization: token $varAccessToken"
for filename in $(echo $varAssets | tr ";" "\n")
do
echo " - ${filename}:"
curl -X POST -sH "$curlAuth" -H "Content-Type: application/octet-stream" --data-binary @"$filename" https://uploads.github.com/repos/$varRepoSlug/releases/$releaseId/assets?name=$(basename $filename)
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
echo
echo "OK"
echo
done
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment