Skip to content

Use github actions

Use github actions #2

Workflow file for this run

name: CI
on:
push:
branches:
- '**'
tags:
- '*'
pull_request:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Cache PlatformIO and pip
uses: actions/cache@v3
with:
path: |
~/.platformio
~/.cache/pip
key: ${{ runner.os }}-platformio-${{ hashFiles('**/platformio.ini') }}
restore-keys: |
${{ runner.os }}-platformio-
- name: Install dependencies
run: |
pip install urllib3==1.26.15
pip install -U platformio
pio pkg update
- name: Extract version from tag
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG=${GITHUB_REF#refs/tags/}
if [[ $TAG =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "MAJOR_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
echo "MINOR_VERSION=${BASH_REMATCH[2]}" >> $GITHUB_ENV
echo "PATCH_VERSION=${BASH_REMATCH[3]}" >> $GITHUB_ENV
else
echo "Tag does not match version pattern"
exit 1
fi
- name: Set default version if no tag
if: github.ref != 'refs/tags/*'
run: |
echo "MAJOR_VERSION=0" >> $GITHUB_ENV
echo "MINOR_VERSION=0" >> $GITHUB_ENV
echo "PATCH_VERSION=0" >> $GITHUB_ENV
- name: Build project
run: |
pio --version
pio run
- name: Generate SHA256 checksum
run: |
sha256sum .pio/build/ATtiny1616/firmware.hex | cut -d ' ' -f 1 > .pio/build/ATtiny1616/firmware.hex.sha256
- name: Upload release assets
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
artifacts: |
.pio/build/ATtiny1616/firmware.hex
.pio/build/ATtiny1616/firmware.hex.sha256
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: false
prerelease: false