Skip to content

Commit 103305e

Browse files
committed
ops: revert checkout workflow
1 parent cf025cc commit 103305e

File tree

1 file changed

+23
-34
lines changed

1 file changed

+23
-34
lines changed

.github/workflows/release.yml

+23-34
Original file line numberDiff line numberDiff line change
@@ -137,56 +137,45 @@ jobs:
137137

138138
- name: Generate and Commit Changelog
139139
run: |
140-
echo "Installing git-chglog..."
140+
# Create a temporary directory for extraction
141141
mkdir chglog_tmp
142+
143+
# Download git-chglog archive
142144
wget https://github.com/git-chglog/git-chglog/releases/download/v0.15.4/git-chglog_0.15.4_linux_amd64.tar.gz
145+
146+
# Extract into the temporary directory
143147
tar -xvzf git-chglog_0.15.4_linux_amd64.tar.gz -C chglog_tmp
144-
145-
echo "Generating changelog..."
148+
149+
# Generate changelog using the extracted executable
146150
./chglog_tmp/git-chglog -o ./CHANGELOG.md
147-
148-
echo "Cleaning up git-chglog files..."
151+
152+
# Clean up downloaded archive and temporary directory
149153
rm git-chglog_0.15.4_linux_amd64.tar.gz
150154
rm -rf chglog_tmp
151-
152-
echo "Configuring git user..."
155+
156+
# Configure git user
153157
git config user.name "github-actions[bot]"
154158
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
155-
156-
echo "Fetching main branch..."
159+
157160
# Fetch the latest main branch from origin
161+
# Use refs/heads/main to be explicit about fetching the branch, not a tag named main
158162
git fetch origin refs/heads/main
159-
160-
echo "Creating temporary branch based on origin/main..."
161-
# Create a new branch based on the fetched origin/main
162-
echo "Stashing generated CHANGELOG.md..."
163-
# Stash the generated changelog (include untracked files like CHANGELOG.md if new)
164-
git stash push -u -- CHANGELOG.md
165163
164+
# Create a new branch based on the fetched origin/main
166165
git checkout -b changelog-update origin/main
167166
168-
echo "Adding and committing CHANGELOG.md..."
169-
echo "Applying stashed CHANGELOG.md..."
170-
# Apply the stashed changes (the generated CHANGELOG.md)
171-
# Use || true in case stash is empty (e.g., changelog didn't change)
172-
git stash pop || true
173-
167+
# Add, commit the changelog to the new branch
174168
git add ./CHANGELOG.md
175-
# Check if there are changes to commit to avoid empty commit error if file exists and is unchanged
176-
if ! git diff --staged --quiet; then
177-
git commit -m "chore(docs): update CHANGELOG for release ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} [skip ci]"
178-
else
179-
echo "No changes to CHANGELOG.md to commit."
180-
fi
181-
182-
183-
echo "Cleaning up temporary local branch..."
184-
# Switch away from the branch before deleting it
185-
git checkout --detach
186-
git branch -D changelog-update
187-
echo "Pushing changelog commit to remote main branch..."
169+
# Use --allow-empty in case the changelog hasn't changed (e.g., rerunning on same tag)
170+
git commit --allow-empty -m "chore(docs): update CHANGELOG for release ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} [skip ci]"
171+
188172
# Push the new local branch specifically to the remote *branch* main
189173
git push origin changelog-update:refs/heads/main
174+
175+
# Clean up the temporary local branch (optional but good practice)
176+
# We might need to checkout --detach first if this fails
177+
git branch -D changelog-update || echo "Could not delete local branch changelog-update"
178+
190179
env:
191180
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
192181

0 commit comments

Comments
 (0)