Skip to content

Commit 190cf5c

Browse files
authored
feat: Auto-set head name for markdown table when running in release (#3)
1 parent d7c61a0 commit 190cf5c

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,10 @@ jobs:
163163
with:
164164
app_name: "My ESP-IDF App"
165165
app_path: "."
166-
head_name: "${{ github.event.release.tag_name }}"
167166
idf_target: esp32s3
168167
idf_version: v5.5
169168
idf_component_manager: "1" # enable component manager
170-
# base_ref is automatically detected for releases (previous tag)
169+
# base_ref and head_name are automatically detected for releases
171170
flash_total_override: 1500000 # optional, number of bytes for app partition in flash for percentage calculation
172171
post_comment: 'false' # set to false since this is not a PR with comments
173172
```
@@ -176,6 +175,7 @@ jobs:
176175
- Find the previous tag chronologically when processing a release
177176
- Use that tag as the base reference for comparison
178177
- Set the base column name to the actual tag name (e.g., "v1.0.0") for clear labeling
178+
- Set the head column name to the current release tag (e.g., "v1.1.0") for clear labeling
179179
- Fall back to a size-only report if it's the first release (no previous tags)
180180

181181
### Inputs
@@ -200,7 +200,7 @@ inputs:
200200
required: false
201201
default: '0'
202202
head_name:
203-
description: 'Name of the head app (for reporting, defaults to "PR")'
203+
description: 'Name of the head app (for reporting, defaults to "PR", auto-set to tag name for releases)'
204204
required: false
205205
default: 'PR'
206206
base_name:

action.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ runs:
9292
run: |
9393
base_ref="${{ inputs.base_ref }}"
9494
base_name="${{ inputs.base_name }}"
95+
head_name="${{ inputs.head_name }}"
9596
9697
# If no base_ref provided, try to determine it automatically
9798
if [ -z "$base_ref" ]; then
@@ -107,6 +108,11 @@ runs:
107108
current_tag="${{ github.event.release.tag_name }}"
108109
echo "Current release tag: $current_tag"
109110
111+
# Auto-set head_name to current tag if not already specified
112+
if [ "$head_name" = "PR" ]; then
113+
head_name="$current_tag"
114+
fi
115+
110116
# Get all tags sorted by creation date (newest first), exclude current tag
111117
prev_tag=$(git --no-pager tag --sort=-creatordate | grep -v "^${current_tag}$" | head -n1 || true)
112118
@@ -130,13 +136,15 @@ runs:
130136
131137
echo "base_ref=$base_ref" >> $GITHUB_OUTPUT
132138
echo "base_name=$base_name" >> $GITHUB_OUTPUT
139+
echo "head_name=$head_name" >> $GITHUB_OUTPUT
133140
if [ -n "$base_ref" ]; then
134141
echo "has_base_ref=true" >> $GITHUB_OUTPUT
135142
echo "Using base_ref: $base_ref (base_name: $base_name)"
136143
else
137144
echo "has_base_ref=false" >> $GITHUB_OUTPUT
138145
echo "No base_ref - will generate size-only report"
139146
fi
147+
echo "Using head_name: $head_name"
140148
141149
- name: Checkout BASE
142150
if: ${{ steps.determine_base_ref.outputs.has_base_ref == 'true' }}
@@ -179,9 +187,9 @@ runs:
179187
run: |
180188
# generate markdown
181189
if [ "${{ steps.determine_base_ref.outputs.has_base_ref }}" = "true" ]; then
182-
md=$(${{ steps.id_python_313.outputs.python-path }} ${{ github.action_path }}/render_markdown.py --app-name "${{ inputs.app_name }}" --base-name "${{ steps.determine_base_ref.outputs.base_name }}" --head-name "${{ inputs.head_name }}" --head-json head/${{ inputs.app_path }}/size.json --base-json base/${{ inputs.app_path }}/size.json)
190+
md=$(${{ steps.id_python_313.outputs.python-path }} ${{ github.action_path }}/render_markdown.py --app-name "${{ inputs.app_name }}" --base-name "${{ steps.determine_base_ref.outputs.base_name }}" --head-name "${{ steps.determine_base_ref.outputs.head_name }}" --head-json head/${{ inputs.app_path }}/size.json --base-json base/${{ inputs.app_path }}/size.json)
183191
else
184-
md=$(${{ steps.id_python_313.outputs.python-path }} ${{ github.action_path }}/render_markdown.py --app-name "${{ inputs.app_name }}" --head-name "${{ inputs.head_name }}" --head-json head/${{ inputs.app_path }}/size.json --no-base)
192+
md=$(${{ steps.id_python_313.outputs.python-path }} ${{ github.action_path }}/render_markdown.py --app-name "${{ inputs.app_name }}" --head-name "${{ steps.determine_base_ref.outputs.head_name }}" --head-json head/${{ inputs.app_path }}/size.json --no-base)
185193
fi
186194
# append to summary and set output
187195
echo "$md" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)