Skip to content

Commit b924b93

Browse files
workflow
Signed-off-by: Vedansh Saini <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 7e54ba0 commit b924b93

File tree

1 file changed

+28
-52
lines changed

1 file changed

+28
-52
lines changed

.github/workflows/release-drafter.yml

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ name: Release Drafter
22

33
on:
44
push:
5-
# branches to consider in the event; optional, defaults to all
65
branches:
76
- master
8-
97
pull_request:
108
types: [opened, reopened, synchronize]
119

@@ -15,48 +13,56 @@ permissions:
1513
jobs:
1614
update_release_draft:
1715
permissions:
18-
# write permission is required to create a github release
1916
contents: write
20-
# write permission is required for autolabeler
2117
pull-requests: write
2218
runs-on: ubuntu-latest
2319
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
2424

25-
# Drafts your next Release notes as Pull Requests are merged into "master"
2625
- name: Draft Release
2726
id: release_drafter
2827
uses: release-drafter/release-drafter@v6
2928
with:
3029
config-name: release-drafter.yml
3130
publish: false
3231
env:
33-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
34-
35-
- name: Debug release-drafter outputs
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Debug release-drafter outputs (safe)
3635
run: |
37-
echo "release-drafter.tag_name='${{ steps.release_drafter.outputs.tag_name }}"
38-
echo "release-drafter.body:"
39-
echo "${{ steps.release_drafter.outputs.body }}"
36+
printf 'release-drafter.tag_name=%s\n' "${{ steps.release_drafter.outputs.tag_name }}"
37+
echo 'release-drafter.body:'
38+
printf '%s\n' "${{ steps.release_drafter.outputs.body }}" > /tmp/release_drafter_body.txt
39+
echo "Wrote release body to /tmp/release_drafter_body.txt"
4040
4141
- name: Create / prepend CHANGELOG entry
4242
if: steps.release_drafter.outputs.tag_name != ''
4343
run: |
4444
TAG="${{ steps.release_drafter.outputs.tag_name }}"
45-
BODY="${{ steps.release_drafter.outputs.body }}"
45+
BODY_FILE="/tmp/release_drafter_body.txt"
4646
DATE="$(date +%F)"
47+
if [ -f "$BODY_FILE" ]; then
48+
BODY="$(cat "$BODY_FILE")"
49+
else
50+
BODY="${{ steps.release_drafter.outputs.body }}"
51+
fi
4752
printf "## %s - %s\n\n%s\n\n---\n\n" "$TAG" "$DATE" "$BODY" > /tmp/new_changelog.md
4853
if [ -f CHANGELOG.md ]; then
4954
cat CHANGELOG.md >> /tmp/new_changelog.md
5055
fi
5156
mv /tmp/new_changelog.md CHANGELOG.md
52-
git status --porcelain
57+
git status --porcelain || true
5358
54-
- name: Commit CHANGELOG, create & push tag (explicit)
59+
- name: Commit & push CHANGELOG and tag via GITHUB_TOKEN
5560
if: steps.release_drafter.outputs.tag_name != ''
5661
env:
5762
TAG: ${{ steps.release_drafter.outputs.tag_name }}
5863
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5964
run: |
65+
set -e
6066
git config user.name "github-actions[bot]"
6167
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
6268
@@ -69,54 +75,24 @@ jobs:
6975
fi
7076
7177
REPO="${{ github.repository }}"
72-
echo "Pushing commit to origin..."
73-
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${REPO}.git" HEAD:master || echo "Push failed"
7478
79+
# Push commit (use token to authenticate)
80+
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${REPO}.git" HEAD:refs/heads/master
81+
82+
# Create annotated tag if missing and push it
7583
if git rev-parse "${TAG}" >/dev/null 2>&1; then
7684
echo "Tag ${TAG} already exists locally"
7785
else
7886
git tag -a "${TAG}" -m "Release ${TAG}" || true
7987
fi
8088
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${REPO}.git" "refs/tags/${TAG}" || echo "Tag push failed or tag exists"
8189
82-
- name: Checkout code
83-
uses: actions/checkout@v4
84-
with:
85-
fetch-depth: 0
86-
87-
- name: Ensure correct branch is checked out (only on PR)
88-
if: github.event_name == 'pull_request'
89-
run: |
90-
echo "Checking out PR source branch: ${{ github.head_ref }}"
91-
git fetch origin ${{ github.head_ref }}
92-
git checkout ${{ github.head_ref }}
93-
9490
- name: Setup Node.js
9591
uses: actions/setup-node@v4
96-
with:
92+
with:
9793
node-version: '20'
9894

99-
- name: Update Changelog
95+
- name: (Optional) Update Changelog formatting / run scripts
10096
run: |
101-
VERSION="${{ steps.release_drafter.outputs.tag_name }}"
102-
BODY="${{ steps.release_drafter.outputs.body }}"
103-
104-
# Create a new changelog entry file
105-
echo -e "## ${VERSION} ($(date +'%Y-%m-%d'))\n\n${BODY}\n\n" > new_changelog_entry.md
106-
107-
# Prepend the new entry to the existing CHANGELOG.md
108-
if [ -f CHANGELOG.md ]; then
109-
cat CHANGELOG.md >> new_changelog_entry.md
110-
fi
111-
mv new_changelog_entry.md CHANGELOG.md
112-
113-
# Commits the updated CHANGELOG.md and creates a tag for the new version
114-
- name: Commit and Push Changelog
115-
uses: stefanzweifel/git-auto-commit-action@v5
116-
with:
117-
commit_message: 'docs: Update CHANGELOG.md for ${{ steps.release_drafter.outputs.tag_name }}'
118-
file_pattern: 'CHANGELOG.md'
119-
tagging_message: ${{ steps.release_drafter.outputs.tag_name }}
120-
121-
122-
97+
# placeholder for any project-specific changelog formatting commands
98+
echo "Changelog updated; no additional formatting configured"

0 commit comments

Comments
 (0)