Skip to content

Commit bb19f3c

Browse files
olivermrblclaude
andauthored
chore: automate releases (#15029)
* chore: automate releases * chore: add manual dispatch and update release title format Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 62e0760 commit bb19f3c

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Generate Release Notes
2+
3+
on:
4+
# repository_dispatch:
5+
# types: [release-published]
6+
workflow_dispatch:
7+
inputs:
8+
published_packages:
9+
description: 'JSON array of published packages (e.g. [{"name":"@medusajs/medusa","version":"2.13.5"}])'
10+
required: true
11+
type: string
12+
13+
jobs:
14+
create-github-release:
15+
name: Create GitHub Release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Determine release version
24+
id: version
25+
run: |
26+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
27+
PACKAGES='${{ github.event.inputs.published_packages }}'
28+
else
29+
PACKAGES='${{ toJson(github.event.client_payload.published_packages) }}'
30+
fi
31+
VERSION=$(echo "$PACKAGES" | jq -r '.[0].version')
32+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
33+
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
34+
35+
- name: Find previous release tag
36+
id: previous
37+
run: |
38+
CURRENT_TAG="${{ steps.version.outputs.tag }}"
39+
# Fetch all tags
40+
git fetch --tags
41+
# Find the previous stable release tag (exclude pre-releases)
42+
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "$CURRENT_TAG" | head -1)
43+
echo "tag=$PREVIOUS_TAG" >> "$GITHUB_OUTPUT"
44+
45+
- name: Create GitHub Release with auto-generated notes
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
TAG="${{ steps.version.outputs.tag }}"
50+
VERSION="${{ steps.version.outputs.version }}"
51+
PREVIOUS_TAG="${{ steps.previous.outputs.tag }}"
52+
53+
ARGS=(
54+
"$TAG"
55+
--title "$TAG"
56+
--generate-notes
57+
--target "${{ github.sha }}"
58+
)
59+
60+
if [ -n "$PREVIOUS_TAG" ]; then
61+
ARGS+=(--notes-start-tag "$PREVIOUS_TAG")
62+
fi
63+
64+
gh release create "${ARGS[@]}"

.github/workflows/release.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,22 @@ jobs:
3333

3434
- name: Build packages
3535
run: yarn build
36-
37-
- name: Create Release Pull Request
36+
- name: Create Release Pull Request or Publish packages
37+
id: changesets
3838
uses: changesets/action@v1
39+
with:
40+
commit: "Chore: Release"
41+
title: "Chore: Release"
42+
publish: yarn changeset publish
3943
env:
44+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4045
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Trigger release notes generation
48+
if: steps.changesets.outputs.published == 'true'
49+
run: |
50+
curl -X POST \
51+
-H "Accept: application/vnd.github.v3+json" \
52+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
53+
https://api.github.com/repos/${{ github.repository }}/dispatches \
54+
-d '{"event_type":"release-published","client_payload":{"published_packages":${{ steps.changesets.outputs.publishedPackages }}}}'

0 commit comments

Comments
 (0)