-
Notifications
You must be signed in to change notification settings - Fork 0
2.1.1 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
2.1.1 #21
Changes from all commits
96f3dc0
f2b3f6a
405763d
b220bfd
7a8fc9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: Auto Tag on Version Bump | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'library.json' | ||
| - 'library.properties' | ||
| - 'src/HttpCommon.h' | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| check-and-tag: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # full history needed for tag comparison | ||
|
|
||
| - name: Extract version from library.json | ||
| id: version | ||
| run: | | ||
| VERSION=$(grep -m1 '"version"' library.json | sed -E 's/.*"version" *: *"([^"]+)".*/\1/') | ||
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | ||
| echo "Detected version: ${VERSION}" | ||
|
|
||
| - name: Verify version consistency across files | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| V_PROP=$(grep '^version=' library.properties | cut -d'=' -f2) | ||
| V_HDR=$(grep '#define ESP_ASYNC_WEB_CLIENT_VERSION' src/HttpCommon.h | sed -E 's/.*"([^"]+)".*/\1/') | ||
|
|
||
| MISMATCH=0 | ||
| if [[ "${VERSION}" != "${V_PROP}" ]]; then | ||
| echo "::error::Version mismatch: library.json=${VERSION} vs library.properties=${V_PROP}" | ||
| MISMATCH=1 | ||
| fi | ||
| if [[ "${VERSION}" != "${V_HDR}" ]]; then | ||
| echo "::error::Version mismatch: library.json=${VERSION} vs HttpCommon.h=${V_HDR}" | ||
| MISMATCH=1 | ||
| fi | ||
| if [[ $MISMATCH -ne 0 ]]; then | ||
| echo "::error::Fix version mismatches before tagging. Use: scripts/sync-version.sh <version>" | ||
| exit 1 | ||
| fi | ||
| echo "All 3 version sources agree: ${VERSION}" | ||
|
|
||
| - name: Check if tag already exists | ||
| id: tag_check | ||
| run: | | ||
| TAG="v${{ steps.version.outputs.version }}" | ||
| if git rev-parse "refs/tags/${TAG}" >/dev/null 2>&1; then | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
| echo "Tag ${TAG} already exists — skipping." | ||
| else | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| echo "Tag ${TAG} does not exist — will create." | ||
| fi | ||
|
|
||
| - name: Create and push tag | ||
| if: steps.tag_check.outputs.exists == 'false' | ||
| run: | | ||
| TAG="v${{ steps.version.outputs.version }}" | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git tag -a "${TAG}" -m "Release ${TAG}" | ||
| git push origin "${TAG}" | ||
| echo "::notice::Created and pushed tag ${TAG}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/usr/bin/env bash | ||
| # sync-version.sh — Update version in all 3 source-of-truth files at once. | ||
| # Usage: ./scripts/sync-version.sh 2.2.0 | ||
| set -euo pipefail | ||
|
|
||
| if [[ $# -ne 1 ]]; then | ||
| echo "Usage: $0 <version>" | ||
| echo "Example: $0 2.2.0" | ||
| exit 1 | ||
| fi | ||
|
|
||
| NEW_VERSION="$1" | ||
|
|
||
| # Validate semver format | ||
| if [[ ! "${NEW_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Error: '${NEW_VERSION}' is not a valid semver (expected X.Y.Z)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Syncing version to ${NEW_VERSION} across all files..." | ||
|
|
||
| # 1. library.json | ||
| if [[ -f library.json ]]; then | ||
| sed -i -E "s/\"version\" *: *\"[^\"]+\"/\"version\": \"${NEW_VERSION}\"/" library.json | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Useful? React with 👍 / 👎. |
||
| echo " ✓ library.json" | ||
| else | ||
|
Comment on lines
+22
to
+26
|
||
| echo " ✗ library.json not found" | ||
| fi | ||
|
|
||
| # 2. library.properties | ||
| if [[ -f library.properties ]]; then | ||
| sed -i -E "s/^version=.*/version=${NEW_VERSION}/" library.properties | ||
| echo " ✓ library.properties" | ||
| else | ||
| echo " ✗ library.properties not found" | ||
| fi | ||
|
|
||
| # 3. src/HttpCommon.h | ||
| if [[ -f src/HttpCommon.h ]]; then | ||
| sed -i -E "s/#define ESP_ASYNC_WEB_CLIENT_VERSION \"[^\"]+\"/#define ESP_ASYNC_WEB_CLIENT_VERSION \"${NEW_VERSION}\"/" src/HttpCommon.h | ||
| echo " ✓ src/HttpCommon.h" | ||
|
Comment on lines
+23
to
+41
|
||
| else | ||
| echo " ✗ src/HttpCommon.h not found" | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "Done! Version is now ${NEW_VERSION} everywhere." | ||
| echo "" | ||
| echo "Next steps:" | ||
| echo " 1. Update CHANGELOG.md with your changes under [${NEW_VERSION}]" | ||
| echo " 2. Commit and push to main" | ||
| echo " 3. The auto-tag workflow will create the tag v${NEW_VERSION} automatically" | ||
| echo " 4. The release workflow will generate the release with auto-generated notes" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the changelog extraction step,
VERSION=$(grep '"version"' library.json | ...)will match multiple"version"keys inlibrary.json(the top-level library version and dependency versions). This can produce a multi-lineVERSIONvalue and break release naming/notes. Usejq -r .versionor at leastgrep -m1with a stricter pattern targeting only the top-levelversion.