Skip to content

Commit 873806f

Browse files
committed
Extract release workflow logic into a reusable composite action and add path filtering
- cache: true doesn't seem to work
1 parent 6120c97 commit 873806f

2 files changed

Lines changed: 86 additions & 67 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 'Create App Release'
2+
description: 'Checks tag, generates changelog, and publishes a GitHub Release.'
3+
4+
inputs:
5+
app_name:
6+
description: 'Display name of the application'
7+
required: true
8+
app_suffix:
9+
description: 'Suffix for the release tag'
10+
required: true
11+
version:
12+
description: 'Raw version string from manifest'
13+
required: true
14+
changelog_paths:
15+
description: 'Paths to filter git log'
16+
required: true
17+
18+
runs:
19+
using: 'composite'
20+
steps:
21+
- name: Check if tag exists
22+
id: check_tag
23+
shell: bash
24+
run: |
25+
if git ls-remote --tags origin refs/tags/${{ inputs.version }}-${{ inputs.app_suffix }} | grep -q 'refs/tags/'; then
26+
echo "exists=true" >> $GITHUB_OUTPUT
27+
else
28+
echo "exists=false" >> $GITHUB_OUTPUT
29+
fi
30+
31+
- name: Generate Release Notes
32+
if: steps.check_tag.outputs.exists == 'false'
33+
shell: bash
34+
run: |
35+
PREV_TAG=$(git describe --tags --match "*-${{ inputs.app_suffix }}" --abbrev=0 2>/dev/null || echo "")
36+
37+
echo "### What's changed in the ${{ inputs.app_name }} extension:" > release_notes.md
38+
echo "" >> release_notes.md
39+
40+
if [ -n "$PREV_TAG" ]; then
41+
git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" -- ${{ inputs.changelog_paths }} >> release_notes.md
42+
else
43+
git log --pretty=format:"* %s (%h)" -- ${{ inputs.changelog_paths }} >> release_notes.md
44+
fi
45+
46+
- name: Create Release
47+
if: steps.check_tag.outputs.exists == 'false'
48+
uses: softprops/action-gh-release@v2
49+
with:
50+
tag_name: ${{ inputs.version }}-${{ inputs.app_suffix }}
51+
name: ${{ inputs.version }} - ${{ inputs.app_name }}
52+
body_path: release_notes.md
53+
target_commitish: ${{ github.sha }}

‎.github/workflows/github-release.yml‎

Lines changed: 33 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ permissions:
1212
contents: write
1313

1414
jobs:
15+
changes:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
editor: ${{ steps.filter.outputs.editor }}
19+
browser: ${{ steps.filter.outputs.browser }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: dorny/paths-filter@v3
23+
id: filter
24+
with:
25+
filters: |
26+
editor:
27+
- 'apps/editor/package.json'
28+
browser:
29+
- 'apps/browser/src/manifest.json'
30+
1531
check:
1632
runs-on: ubuntu-latest
1733

@@ -20,17 +36,17 @@ jobs:
2036
uses: actions/checkout@v4
2137

2238
- name: Setup PNPM
23-
uses: pnpm/action-setup@v2
39+
uses: pnpm/setup@v3
2440
with:
2541
version: 12.17.0
26-
run_install: false
42+
cache: true
43+
install: false
2744

2845
- name: Setup Node.js
2946
uses: actions/setup-node@v4
3047
with:
3148
node-version: '22'
3249
registry-url: 'https://registry.npmjs.org'
33-
cache: 'pnpm'
3450

3551
- name: Install dependencies
3652
run: pnpm i
@@ -45,7 +61,8 @@ jobs:
4561
run: pnpm test
4662

4763
release:
48-
needs: check
64+
needs: [check, changes]
65+
if: needs.changes.outputs.editor == 'true'
4966
runs-on: ubuntu-latest
5067

5168
steps:
@@ -59,44 +76,19 @@ jobs:
5976
id: package_version
6077
run: |
6178
VERSION=$(jq -r .version apps/editor/package.json)
62-
echo "version=$VERSION-vscode" >> $GITHUB_OUTPUT
6379
echo "raw_version=$VERSION" >> $GITHUB_OUTPUT
6480
65-
- name: Check if tag exists
66-
id: check_tag
67-
run: |
68-
# Prevent failing if package.json was modified but version wasn't bumped
69-
if git ls-remote --tags origin refs/tags/${{ steps.package_version.outputs.version }} | grep -q 'refs/tags/'; then
70-
echo "exists=true" >> $GITHUB_OUTPUT
71-
else
72-
echo "exists=false" >> $GITHUB_OUTPUT
73-
fi
74-
75-
- name: Generate Release Notes
76-
if: steps.check_tag.outputs.exists == 'false'
77-
run: |
78-
PREV_TAG=$(git describe --tags --match "*-vscode" --abbrev=0 2>/dev/null || echo "")
79-
80-
echo "### What's changed in the VS Code extension:" > release_notes.md
81-
echo "" >> release_notes.md
82-
83-
if [ -n "$PREV_TAG" ]; then
84-
git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" -- apps/editor packages/ui/src/components/editor >> release_notes.md
85-
else
86-
git log --pretty=format:"* %s (%h)" -- apps/editor packages/ui/src/components/editor >> release_notes.md
87-
fi
88-
8981
- name: Create Release
90-
if: steps.check_tag.outputs.exists == 'false'
91-
uses: softprops/action-gh-release@v2
82+
uses: ./.github/actions/create-app-release
9283
with:
93-
tag_name: ${{ steps.package_version.outputs.version }}
94-
name: ${{ steps.package_version.outputs.raw_version }} - VS Code
95-
body_path: release_notes.md
96-
target_commitish: ${{ github.sha }}
84+
app_name: 'VS Code'
85+
app_suffix: 'vscode'
86+
version: ${{ steps.package_version.outputs.raw_version }}
87+
changelog_paths: 'apps/editor packages/ui/src/components/editor'
9788

9889
release-browser:
99-
needs: check
90+
needs: [check, changes]
91+
if: needs.changes.outputs.browser == 'true'
10092
runs-on: ubuntu-latest
10193

10294
steps:
@@ -110,38 +102,12 @@ jobs:
110102
id: browser_version
111103
run: |
112104
VERSION=$(jq -r .version apps/browser/src/manifest.json)
113-
echo "version=$VERSION-browser" >> $GITHUB_OUTPUT
114105
echo "raw_version=$VERSION" >> $GITHUB_OUTPUT
115106
116-
- name: Check if tag exists
117-
id: check_tag
118-
run: |
119-
# Prevent failing if manifest.json was modified but version wasn't bumped
120-
if git ls-remote --tags origin refs/tags/${{ steps.browser_version.outputs.version }} | grep -q 'refs/tags/'; then
121-
echo "exists=true" >> $GITHUB_OUTPUT
122-
else
123-
echo "exists=false" >> $GITHUB_OUTPUT
124-
fi
125-
126-
- name: Generate Release Notes
127-
if: steps.check_tag.outputs.exists == 'false'
128-
run: |
129-
PREV_TAG=$(git describe --tags --match "*-browser" --abbrev=0 2>/dev/null || echo "")
130-
131-
echo "### What's changed in the browser extension:" > release_notes_browser.md
132-
echo "" >> release_notes_browser.md
133-
134-
if [ -n "$PREV_TAG" ]; then
135-
git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" -- apps/browser packages/shared/src/constants/chatbots.ts packages/ui/src/components/browser >> release_notes_browser.md
136-
else
137-
git log --pretty=format:"* %s (%h)" -- apps/browser packages/shared/src/constants/chatbots.ts packages/ui/src/components/browser >> release_notes_browser.md
138-
fi
139-
140107
- name: Create Release
141-
if: steps.check_tag.outputs.exists == 'false'
142-
uses: softprops/action-gh-release@v2
108+
uses: ./.github/actions/create-app-release
143109
with:
144-
tag_name: ${{ steps.browser_version.outputs.version }}
145-
name: ${{ steps.browser_version.outputs.raw_version }} - Browser
146-
body_path: release_notes_browser.md
147-
target_commitish: ${{ github.sha }}
110+
app_name: 'Browser'
111+
app_suffix: 'browser'
112+
version: ${{ steps.browser_version.outputs.raw_version }}
113+
changelog_paths: 'apps/browser packages/shared/src/constants/chatbots.ts packages/ui/src/components/browser'

0 commit comments

Comments
 (0)