Skip to content
Merged
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
186 changes: 69 additions & 117 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,162 +1,114 @@
name: Release

on:
workflow_dispatch:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
branches:
- main
- master
- dev
paths-ignore:
- '*.md'

pull_request:
branches:
- main
- master

workflow_dispatch:

env:
# Master branch (main or master)
master_branch: main

permissions:
contents: write
id-token: write

jobs:
release:
if: startsWith(github.ref, 'refs/tags/')
extract_version:
name: Extract Version and Update Files
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ github.ref }}

- name: Extract version from tag

- name: Extract Version from Branch Name
id: extract_version
run: |
TAG_NAME="${GITHUB_REF_NAME}"
echo "VERSION=${TAG_NAME}" >> ${GITHUB_ENV}
echo "Using version from tag: ${TAG_NAME}"
BRANCH_NAME="${GITHUB_REF_NAME}"
echo "Branch Name: $BRANCH_NAME"

# Extract version from branch name (format: Major.Minor.Revision_Dev)
BASE_VERSION="${BRANCH_NAME%%_*}"
IFS='.' read -r MAJOR MINOR BUILD <<< "$BASE_VERSION"
if [ -z "$BUILD" ]; then BUILD=0; fi

echo "MAJOR=$MAJOR" >> $GITHUB_ENV
echo "MINOR=$MINOR" >> $GITHUB_ENV
echo "BUILD=$BUILD" >> $GITHUB_ENV
echo "VERSION=$BASE_VERSION" >> $GITHUB_ENV

- name: ZIP artifact
shell: bash
echo "Extracted Version: $BASE_VERSION"

- name: Update CMakeLists.txt
run: |
sudo apt-get update
sudo apt-get install -y zip
zip -r ${GITHUB_REF_NAME}.zip .
sed -i -E "s/set\(ESP32_LEPTON_LIB_MAJOR[[:space:]]+[0-9]+\)/set(ESP32_LEPTON_LIB_MAJOR $MAJOR)/" CMakeLists.txt
sed -i -E "s/set\(ESP32_LEPTON_LIB_MINOR[[:space:]]+[0-9]+\)/set(ESP32_LEPTON_LIB_MINOR $MINOR)/" CMakeLists.txt
sed -i -E "s/set\(ESP32_LEPTON_LIB_BUILD[[:space:]]+[0-9]+\)/set(ESP32_LEPTON_LIB_BUILD $BUILD)/" CMakeLists.txt

- name: Upload to Component registry
uses: espressif/upload-components-ci-action@v2
with:
components: "ESP32-Lepton:."
version: ${{ env.VERSION }}
namespace: "Kampi"
api_token: ${{ secrets.IDF_COMPONENT_REGISTRY_TOKEN }}
- name: Update idf_component.yml
run: |
sed -i -E "s/^version: \".*\"/version: \"$VERSION\"/" idf_component.yml

- name: Release
uses: docker://antonyurchenko/git-release:v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHANGELOG_FILE: CHANGELOG.md
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
args: |
${GITHUB_REF_NAME}.zip

generate_outputs:
if: github.ref_type == 'branch' && github.ref_name != 'main'
commit_message: "Update version to $VERSION"
branch: ${{ github.ref_name }}

update_changelog:
name: Update Changelog
needs: extract_version
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master')
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v5

- name: Initialize
- name: Update CHANGELOG.md
run: |
mkdir -p log
echo "DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> "${GITHUB_ENV}"
sed -i "s/^## \[Unreleased\]/## [$VERSION] - $(date +'%Y-%m-%d')/" CHANGELOG.md
sed -i '/^# CHANGELOG/a \n## [Unreleased]' CHANGELOG.md

- name: Get release version
run: |
BRANCH_NAME="${GITHUB_REF_NAME}"
echo "BRANCH_NAME=${BRANCH_NAME}"

# Extract version from branch name (format: x.y.z_Dev or x.y_Dev)
BASE_VERSION="${BRANCH_NAME%%_*}"

# Split version into components
IFS='.' read -r MAJOR MINOR BUILD <<< "${BASE_VERSION}"

# Handle optional BUILD number
if [ -z "$BUILD" ]; then
BUILD=0
fi

echo "MAJOR=${MAJOR}" >> ${GITHUB_ENV}
echo "MINOR=${MINOR}" >> ${GITHUB_ENV}
echo "BUILD=${BUILD}" >> ${GITHUB_ENV}
echo "VERSION=${BASE_VERSION}" >> ${GITHUB_ENV}

- name: Update version numbers
shell: bash
run: |
echo "Using version: ${{ env.VERSION }}"

# Update CMakeLists.txt version definitions
sed -i -E "s/(ESP32_LEPTON_LIB_MAJOR=)[0-9]+/\1${{ env.MAJOR }}/" CMakeLists.txt
sed -i -E "s/(ESP32_LEPTON_LIB_MINOR=)[0-9]+/\1${{ env.MINOR }}/" CMakeLists.txt
sed -i -E "s/(ESP32_LEPTON_LIB_BUILD=)[0-9]+/\1${{ env.BUILD }}/" CMakeLists.txt

# Update idf_component.yml version field
sed -i -E "s/^version: \".*\"/version: \"${{ env.VERSION }}\"/" idf_component.yml

- name: Push outputs
- name: Commit Changelog Update
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update CHANGELOG for release $VERSION"
branch: ${{ github.ref_name }}
commit_message: Push outputs from CI/CD (${{ env.DATE }})

release_changelog_update:
if: github.ref_type == 'branch' && github.ref_name == 'main'

create_release:
name: Create GitHub Release
needs: [extract_version, update_changelog]
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v5

- name: Initialize
run: |
mkdir -p log
echo "DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> "${GITHUB_ENV}"
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
draft: false
prerelease: false

- name: Get release version from CMakeLists.txt
run: |
# Extract version from CMakeLists.txt
MAJOR=$(grep -oP 'ESP32_LEPTON_LIB_MAJOR=\K[0-9]+' CMakeLists.txt)
MINOR=$(grep -oP 'ESP32_LEPTON_LIB_MINOR=\K[0-9]+' CMakeLists.txt)
BUILD=$(grep -oP 'ESP32_LEPTON_LIB_BUILD=\K[0-9]+' CMakeLists.txt)

VERSION="${MAJOR}.${MINOR}.${BUILD}"

echo "MAJOR=${MAJOR}" >> ${GITHUB_ENV}
echo "MINOR=${MINOR}" >> ${GITHUB_ENV}
echo "BUILD=${BUILD}" >> ${GITHUB_ENV}
echo "VERSION=${VERSION}" >> ${GITHUB_ENV}

echo "Extracted version: ${VERSION}"

- name: Update CHANGELOG for release
shell: bash
run: |
echo "Updating CHANGELOG with version: ${{ env.VERSION }}"

# Replace ## [Unreleased] with version and date
sed -i "s/^## \[Unreleased\]/## [${{ env.VERSION }}] - $(date +'%Y-%m-%d')/" CHANGELOG.md

# Add new [Unreleased] section at the top
sed -i '/^# CHANGELOG/a \\n## [Unreleased]' CHANGELOG.md

- name: Push CHANGELOG update
uses: stefanzweifel/git-auto-commit-action@v5
- name: Upload Release Assets
uses: actions/upload-release-asset@v1
with:
branch: ${{ github.ref_name }}
commit_message: Release ${{ env.VERSION }} - Update CHANGELOG (${{ env.DATE }})
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/firmware.bin
asset_name: firmware-${{ env.VERSION }}.bin
asset_content_type: application/octet-stream
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
set(ESP32_LEPTON_LIB_MAJOR=0)
set(ESP32_LEPTON_LIB_MINOR=0)
set(ESP32_LEPTON_LIB_BUILD=2)

set(COMPONENT_SRCS
"src/lepton.cpp"
"src/lepton_cci.cpp"
Expand Down
Loading