Skip to content

Commit 5d4df2b

Browse files
committed
Release 0.0.2
Signed-off-by: Daniel Kampert <DanielKampert@kampis-elektroecke.de>
1 parent 8143be9 commit 5d4df2b

File tree

2 files changed

+98
-120
lines changed

2 files changed

+98
-120
lines changed

.github/workflows/release.yaml

Lines changed: 98 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,144 @@
11
name: Release
22

33
on:
4-
workflow_dispatch:
54
push:
6-
tags:
7-
- '[0-9]+.[0-9]+.[0-9]+'
85
branches:
96
- main
107
- master
11-
- dev
128
paths-ignore:
139
- '*.md'
1410

11+
pull_request:
12+
branches:
13+
- main
14+
- master
15+
16+
workflow_dispatch:
17+
1518
env:
16-
# Master branch (main or master)
1719
master_branch: main
1820

1921
permissions:
2022
contents: write
2123
id-token: write
2224

2325
jobs:
24-
release:
25-
if: startsWith(github.ref, 'refs/tags/')
26+
extract_version:
27+
name: Extract Version and Update Files
2628
runs-on: ubuntu-latest
2729

2830
steps:
29-
- name: Checkout
31+
- name: Checkout Repository
3032
uses: actions/checkout@v5
31-
with:
32-
fetch-depth: 0
33-
ref: ${{ github.ref }}
34-
35-
- name: Extract version from tag
36-
run: |
37-
TAG_NAME="${GITHUB_REF_NAME}"
38-
echo "VERSION=${TAG_NAME}" >> ${GITHUB_ENV}
39-
echo "Using version from tag: ${TAG_NAME}"
4033

41-
- name: ZIP artifact
42-
shell: bash
34+
- name: Extract Version from Branch Name
35+
id: extract_version
4336
run: |
44-
sudo apt-get update
45-
sudo apt-get install -y zip
46-
zip -r ${GITHUB_REF_NAME}.zip .
37+
BRANCH_NAME="${GITHUB_REF_NAME}"
38+
echo "Branch Name: $BRANCH_NAME"
4739
48-
- name: Upload to Component registry
49-
uses: espressif/upload-components-ci-action@v2
50-
with:
51-
components: "ESP32-Lepton:."
52-
version: ${{ env.VERSION }}
53-
namespace: "Kampi"
54-
api_token: ${{ secrets.IDF_COMPONENT_REGISTRY_TOKEN }}
40+
# Extract version from branch name (format: Major.Minor.Revision_Dev)
41+
BASE_VERSION="${BRANCH_NAME%%_*}"
42+
IFS='.' read -r MAJOR MINOR BUILD <<< "$BASE_VERSION"
43+
if [ -z "$BUILD" ]; then BUILD=0; fi
5544
56-
- name: Release
57-
uses: docker://antonyurchenko/git-release:v6
58-
env:
59-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60-
CHANGELOG_FILE: CHANGELOG.md
61-
with:
62-
args: |
63-
${GITHUB_REF_NAME}.zip
64-
65-
generate_outputs:
66-
if: github.ref_type == 'branch' && github.ref_name != 'main'
67-
runs-on: ubuntu-latest
45+
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
46+
echo "MINOR=$MINOR" >> $GITHUB_ENV
47+
echo "BUILD=$BUILD" >> $GITHUB_ENV
48+
echo "VERSION=$BASE_VERSION" >> $GITHUB_ENV
6849
69-
steps:
70-
- name: Checkout
71-
uses: actions/checkout@v5
50+
echo "Extracted Version: $BASE_VERSION"
7251
73-
- name: Initialize
52+
- name: Update CMakeLists.txt
7453
run: |
75-
mkdir -p log
76-
echo "DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> "${GITHUB_ENV}"
54+
sed -i -E "s/set\(ESP32_LEPTON_LIB_MAJOR[[:space:]]+[0-9]+\)/set(ESP32_LEPTON_LIB_MAJOR $MAJOR)/" CMakeLists.txt
55+
sed -i -E "s/set\(ESP32_LEPTON_LIB_MINOR[[:space:]]+[0-9]+\)/set(ESP32_LEPTON_LIB_MINOR $MINOR)/" CMakeLists.txt
56+
sed -i -E "s/set\(ESP32_LEPTON_LIB_BUILD[[:space:]]+[0-9]+\)/set(ESP32_LEPTON_LIB_BUILD $BUILD)/" CMakeLists.txt
7757
78-
- name: Get release version
58+
- name: Update idf_component.yml
7959
run: |
80-
BRANCH_NAME="${GITHUB_REF_NAME}"
81-
echo "BRANCH_NAME=${BRANCH_NAME}"
82-
83-
# Extract version from branch name (format: x.y.z_Dev or x.y_Dev)
84-
BASE_VERSION="${BRANCH_NAME%%_*}"
85-
86-
# Split version into components
87-
IFS='.' read -r MAJOR MINOR BUILD <<< "${BASE_VERSION}"
88-
89-
# Handle optional BUILD number
90-
if [ -z "$BUILD" ]; then
91-
BUILD=0
92-
fi
93-
94-
echo "MAJOR=${MAJOR}" >> ${GITHUB_ENV}
95-
echo "MINOR=${MINOR}" >> ${GITHUB_ENV}
96-
echo "BUILD=${BUILD}" >> ${GITHUB_ENV}
97-
echo "VERSION=${BASE_VERSION}" >> ${GITHUB_ENV}
98-
99-
- name: Update version numbers
100-
shell: bash
60+
sed -i -E "s/^version: \".*\"/version: \"$VERSION\"/" idf_component.yml
61+
62+
- name: Stash Changes Before Pull
10163
run: |
102-
echo "Using version: ${{ env.VERSION }}"
103-
104-
# Update CMakeLists.txt version definitions
105-
sed -i -E "s/(ESP32_LEPTON_LIB_MAJOR=)[0-9]+/\1${{ env.MAJOR }}/" CMakeLists.txt
106-
sed -i -E "s/(ESP32_LEPTON_LIB_MINOR=)[0-9]+/\1${{ env.MINOR }}/" CMakeLists.txt
107-
sed -i -E "s/(ESP32_LEPTON_LIB_BUILD=)[0-9]+/\1${{ env.BUILD }}/" CMakeLists.txt
108-
109-
# Update idf_component.yml version field
110-
sed -i -E "s/^version: \".*\"/version: \"${{ env.VERSION }}\"/" idf_component.yml
111-
112-
- name: Push outputs
64+
git config user.name "github-actions[bot]"
65+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
66+
git stash
67+
68+
- name: Pull Remote Changes with Rebase
69+
run: |
70+
git config user.name "github-actions[bot]"
71+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
72+
git stash
73+
git pull --rebase origin ${{ github.ref_name }}
74+
git stash pop || echo "No changes to apply from stash"
75+
76+
- name: Force Push Changes
77+
run: |
78+
git push origin ${{ github.ref_name }} --force
79+
80+
- name: Commit Changes
11381
uses: stefanzweifel/git-auto-commit-action@v5
11482
with:
83+
commit_message: "Update version to $VERSION"
84+
env:
85+
VERSION: ${{ env.VERSION }}
11586
branch: ${{ github.ref_name }}
116-
commit_message: Push outputs from CI/CD (${{ env.DATE }})
117-
118-
release_changelog_update:
119-
if: github.ref_type == 'branch' && github.ref_name == 'main'
87+
88+
update_changelog:
89+
name: Update Changelog
90+
needs: extract_version
91+
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master')
12092
runs-on: ubuntu-latest
12193

12294
steps:
123-
- name: Checkout
95+
- name: Checkout Repository
12496
uses: actions/checkout@v5
12597

126-
- name: Initialize
98+
- name: Update CHANGELOG.md
12799
run: |
128-
mkdir -p log
129-
echo "DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> "${GITHUB_ENV}"
100+
sed -i "s/^## \[Unreleased\]/## [$VERSION] - $(date +'%Y-%m-%d')/" CHANGELOG.md
101+
sed -i '/^# CHANGELOG/a \n## [Unreleased]' CHANGELOG.md
130102
131-
- name: Get release version from CMakeLists.txt
103+
- name: Pull Remote Changes Before Commit
132104
run: |
133-
# Extract version from CMakeLists.txt
134-
MAJOR=$(grep -oP 'ESP32_LEPTON_LIB_MAJOR=\K[0-9]+' CMakeLists.txt)
135-
MINOR=$(grep -oP 'ESP32_LEPTON_LIB_MINOR=\K[0-9]+' CMakeLists.txt)
136-
BUILD=$(grep -oP 'ESP32_LEPTON_LIB_BUILD=\K[0-9]+' CMakeLists.txt)
137-
138-
VERSION="${MAJOR}.${MINOR}.${BUILD}"
139-
140-
echo "MAJOR=${MAJOR}" >> ${GITHUB_ENV}
141-
echo "MINOR=${MINOR}" >> ${GITHUB_ENV}
142-
echo "BUILD=${BUILD}" >> ${GITHUB_ENV}
143-
echo "VERSION=${VERSION}" >> ${GITHUB_ENV}
144-
145-
echo "Extracted version: ${VERSION}"
146-
147-
- name: Update CHANGELOG for release
148-
shell: bash
149-
run: |
150-
echo "Updating CHANGELOG with version: ${{ env.VERSION }}"
151-
152-
# Replace ## [Unreleased] with version and date
153-
sed -i "s/^## \[Unreleased\]/## [${{ env.VERSION }}] - $(date +'%Y-%m-%d')/" CHANGELOG.md
154-
155-
# Add new [Unreleased] section at the top
156-
sed -i '/^# CHANGELOG/a \\n## [Unreleased]' CHANGELOG.md
157-
158-
- name: Push CHANGELOG update
105+
git config user.name "github-actions[bot]"
106+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
107+
git pull origin ${{ github.ref_name }} --rebase
108+
109+
- name: Commit Changes
159110
uses: stefanzweifel/git-auto-commit-action@v5
160111
with:
112+
commit_message: "Update CHANGELOG for release ${{ env.VERSION }}"
161113
branch: ${{ github.ref_name }}
162-
commit_message: Release ${{ env.VERSION }} - Update CHANGELOG (${{ env.DATE }})
114+
115+
- name: Push Changes
116+
run: |
117+
git push origin ${{ github.ref_name }}
118+
119+
create_release:
120+
name: Create GitHub Release
121+
needs: [extract_version, update_changelog]
122+
runs-on: ubuntu-latest
123+
124+
steps:
125+
- name: Checkout Repository
126+
uses: actions/checkout@v5
127+
128+
- name: Create GitHub Release
129+
uses: actions/create-release@v1
130+
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
with:
133+
tag_name: ${{ env.VERSION }}
134+
release_name: Release ${{ env.VERSION }}
135+
draft: false
136+
prerelease: false
137+
138+
- name: Upload Release Assets
139+
uses: actions/upload-release-asset@v1
140+
with:
141+
upload_url: ${{ steps.create_release.outputs.upload_url }}
142+
asset_path: ./build/firmware.bin
143+
asset_name: firmware-${{ env.VERSION }}.bin
144+
asset_content_type: application/octet-stream

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
set(ESP32_LEPTON_LIB_MAJOR=0)
2-
set(ESP32_LEPTON_LIB_MINOR=0)
3-
set(ESP32_LEPTON_LIB_BUILD=2)
4-
51
set(COMPONENT_SRCS
62
"src/lepton.cpp"
73
"src/lepton_cci.cpp"

0 commit comments

Comments
 (0)