Skip to content

Commit 405763d

Browse files
committed
feat: Updated to version 2.1.1 and added a workflow for automatic tagging during version updates.
1 parent f2b3f6a commit 405763d

6 files changed

Lines changed: 222 additions & 12 deletions

File tree

.github/workflows/auto-tag.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Auto Tag on Version Bump
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'library.json'
8+
- 'library.properties'
9+
- 'src/HttpCommon.h'
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
check-and-tag:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # full history needed for tag comparison
22+
23+
- name: Extract version from library.json
24+
id: version
25+
run: |
26+
VERSION=$(grep -m1 '"version"' library.json | sed -E 's/.*"version" *: *"([^"]+)".*/\1/')
27+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
28+
echo "Detected version: ${VERSION}"
29+
30+
- name: Verify version consistency across files
31+
run: |
32+
VERSION="${{ steps.version.outputs.version }}"
33+
V_PROP=$(grep '^version=' library.properties | cut -d'=' -f2)
34+
V_HDR=$(grep '#define ESP_ASYNC_WEB_CLIENT_VERSION' src/HttpCommon.h | sed -E 's/.*"([^"]+)".*/\1/')
35+
36+
MISMATCH=0
37+
if [[ "${VERSION}" != "${V_PROP}" ]]; then
38+
echo "::error::Version mismatch: library.json=${VERSION} vs library.properties=${V_PROP}"
39+
MISMATCH=1
40+
fi
41+
if [[ "${VERSION}" != "${V_HDR}" ]]; then
42+
echo "::error::Version mismatch: library.json=${VERSION} vs HttpCommon.h=${V_HDR}"
43+
MISMATCH=1
44+
fi
45+
if [[ $MISMATCH -ne 0 ]]; then
46+
echo "::error::Fix version mismatches before tagging. Use: scripts/sync-version.sh <version>"
47+
exit 1
48+
fi
49+
echo "All 3 version sources agree: ${VERSION}"
50+
51+
- name: Check if tag already exists
52+
id: tag_check
53+
run: |
54+
TAG="v${{ steps.version.outputs.version }}"
55+
if git rev-parse "refs/tags/${TAG}" >/dev/null 2>&1; then
56+
echo "exists=true" >> "$GITHUB_OUTPUT"
57+
echo "Tag ${TAG} already exists — skipping."
58+
else
59+
echo "exists=false" >> "$GITHUB_OUTPUT"
60+
echo "Tag ${TAG} does not exist — will create."
61+
fi
62+
63+
- name: Create and push tag
64+
if: steps.tag_check.outputs.exists == 'false'
65+
run: |
66+
TAG="v${{ steps.version.outputs.version }}"
67+
git config user.name "github-actions[bot]"
68+
git config user.email "github-actions[bot]@users.noreply.github.com"
69+
git tag -a "${TAG}" -m "Release ${TAG}"
70+
git push origin "${TAG}"
71+
echo "::notice::Created and pushed tag ${TAG}"

.github/workflows/release.yml

Lines changed: 95 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0 # full history for changelog generation
1416

1517
- name: Set up Python
1618
uses: actions/setup-python@v5
@@ -59,16 +61,100 @@ jobs:
5961
name: source-archive
6062
path: ${{ env.ARCHIVE }}
6163

64+
- name: Extract changelog for this version
65+
id: changelog
66+
run: |
67+
VERSION=$(grep '"version"' library.json | sed -E 's/.*"version" *: *"([^"]+)".*/\1/')
68+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
69+
70+
# Extract the section for this version from CHANGELOG.md
71+
# Matches everything between "## [X.Y.Z]" and the next "## [" heading
72+
NOTES=""
73+
if [[ -f CHANGELOG.md ]]; then
74+
NOTES=$(awk -v ver="${VERSION}" '
75+
BEGIN { found=0 }
76+
/^## \[/ {
77+
if (found) exit
78+
if ($0 ~ "\\[" ver "\\]") { found=1; next }
79+
}
80+
found { print }
81+
' CHANGELOG.md)
82+
fi
83+
84+
if [[ -z "${NOTES}" ]]; then
85+
echo "No CHANGELOG entry found for ${VERSION}, generating from commits..."
86+
# Get the previous tag
87+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
88+
if [[ -n "${PREV_TAG}" ]]; then
89+
NOTES=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges)
90+
else
91+
NOTES=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
92+
fi
93+
fi
94+
95+
# Write to file to preserve multiline
96+
echo "${NOTES}" > /tmp/release_notes.md
97+
98+
- name: Generate AI-style release summary
99+
id: summary
100+
run: |
101+
VERSION="${{ steps.changelog.outputs.version }}"
102+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
103+
104+
# Build a structured release body
105+
{
106+
echo "# ESPAsyncWebClient v${VERSION}"
107+
echo ""
108+
109+
# Changelog section
110+
echo "## What's Changed"
111+
cat /tmp/release_notes.md
112+
echo ""
113+
114+
# Auto-generated commit summary by category
115+
if [[ -n "${PREV_TAG}" ]]; then
116+
echo "## Commit Summary"
117+
echo ""
118+
119+
# Fixes
120+
FIXES=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges --grep="^[Ff]ix" || true)
121+
if [[ -n "${FIXES}" ]]; then
122+
echo "### Bug Fixes"
123+
echo "${FIXES}"
124+
echo ""
125+
fi
126+
127+
# Features
128+
FEATURES=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges --grep="^[Ff]eat" || true)
129+
if [[ -n "${FEATURES}" ]]; then
130+
echo "### New Features"
131+
echo "${FEATURES}"
132+
echo ""
133+
fi
134+
135+
# Other commits
136+
OTHER=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges --invert-grep --grep="^[Ff]ix" --grep="^[Ff]eat" || true)
137+
if [[ -n "${OTHER}" ]]; then
138+
echo "### Other Changes"
139+
echo "${OTHER}"
140+
echo ""
141+
fi
142+
143+
echo "**Full diff**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...v${VERSION}"
144+
echo ""
145+
fi
146+
147+
# Stats
148+
echo "## Verification"
149+
echo "- :white_check_mark: All examples built successfully"
150+
echo "- :white_check_mark: Version metadata consistent across library.json, library.properties, and HttpCommon.h"
151+
echo "- :package: Source archive attached"
152+
} > /tmp/full_release_notes.md
153+
62154
- name: Create Release
63155
uses: softprops/action-gh-release@v2
64156
with:
65157
files: ${{ env.ARCHIVE }}
66-
name: Release ${{ github.ref }}
67-
body: |
68-
## Changes in this release
69-
See the Git diff for this tag or the Releases page for details.
70-
71-
## Verification
72-
- Examples built successfully
73-
- Version metadata consistent
74-
- Source archive attached
158+
name: "v${{ steps.changelog.outputs.version }}"
159+
body_path: /tmp/full_release_notes.md
160+
generate_release_notes: true

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ESPAsyncWebClient",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Asynchronous HTTP client library for ESP32 ",
55
"keywords": [
66
"http",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ESPAsyncWebClient
2-
version=2.1.0
2+
version=2.1.1
33
author=playmiel
44
maintainer=playmiel
55
sentence=Asynchronous HTTP client library for ESP32 microcontrollers

scripts/sync-version.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
# sync-version.sh — Update version in all 3 source-of-truth files at once.
3+
# Usage: ./scripts/sync-version.sh 2.2.0
4+
set -euo pipefail
5+
6+
if [[ $# -ne 1 ]]; then
7+
echo "Usage: $0 <version>"
8+
echo "Example: $0 2.2.0"
9+
exit 1
10+
fi
11+
12+
NEW_VERSION="$1"
13+
14+
# Validate semver format
15+
if [[ ! "${NEW_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
16+
echo "Error: '${NEW_VERSION}' is not a valid semver (expected X.Y.Z)"
17+
exit 1
18+
fi
19+
20+
echo "Syncing version to ${NEW_VERSION} across all files..."
21+
22+
# 1. library.json
23+
if [[ -f library.json ]]; then
24+
sed -i -E "s/\"version\" *: *\"[^\"]+\"/\"version\": \"${NEW_VERSION}\"/" library.json
25+
echo " ✓ library.json"
26+
else
27+
echo " ✗ library.json not found"
28+
fi
29+
30+
# 2. library.properties
31+
if [[ -f library.properties ]]; then
32+
sed -i -E "s/^version=.*/version=${NEW_VERSION}/" library.properties
33+
echo " ✓ library.properties"
34+
else
35+
echo " ✗ library.properties not found"
36+
fi
37+
38+
# 3. src/HttpCommon.h
39+
if [[ -f src/HttpCommon.h ]]; then
40+
sed -i -E "s/#define ESP_ASYNC_WEB_CLIENT_VERSION \"[^\"]+\"/#define ESP_ASYNC_WEB_CLIENT_VERSION \"${NEW_VERSION}\"/" src/HttpCommon.h
41+
echo " ✓ src/HttpCommon.h"
42+
else
43+
echo " ✗ src/HttpCommon.h not found"
44+
fi
45+
46+
echo ""
47+
echo "Done! Version is now ${NEW_VERSION} everywhere."
48+
echo ""
49+
echo "Next steps:"
50+
echo " 1. Update CHANGELOG.md with your changes under [${NEW_VERSION}]"
51+
echo " 2. Commit and push to main"
52+
echo " 3. The auto-tag workflow will create the tag v${NEW_VERSION} automatically"
53+
echo " 4. The release workflow will generate the release with auto-generated notes"

src/HttpCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
// Library version (single source of truth inside code). Keep in sync with library.json and library.properties.
1919
#ifndef ESP_ASYNC_WEB_CLIENT_VERSION
20-
#define ESP_ASYNC_WEB_CLIENT_VERSION "2.1.0"
20+
#define ESP_ASYNC_WEB_CLIENT_VERSION "2.1.1"
2121
#endif
2222

2323
struct HttpHeader {

0 commit comments

Comments
 (0)