Repository navigation
143 lines (118 loc) · 4.51 KB
/
Copy pathgithub-release.yml
File metadata and controls
143 lines (118 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Create GitHub Release
on:
push:
branches:
- main
paths:
- 'apps/editor/package.json'
- 'apps/browser/src/manifest.json'
permissions:
contents: write
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 12.17.0
run_install: false
- name: Install dependencies
run: pnpm i
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
release:
needs: check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Get version from package.json
id: package_version
run: |
VERSION=$(jq -r .version apps/editor/package.json)
echo "version=$VERSION-vscode" >> $GITHUB_OUTPUT
echo "raw_version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: check_tag
run: |
# Prevent failing if package.json was modified but version wasn't bumped
if git ls-remote --tags origin refs/tags/${{ steps.package_version.outputs.version }} | grep -q 'refs/tags/'; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Generate Release Notes
if: steps.check_tag.outputs.exists == 'false'
run: |
PREV_TAG=$(git describe --tags --match "*-vscode" --abbrev=0 2>/dev/null || echo "")
echo "### What's changed in the VS Code extension:" > release_notes.md
echo "" >> release_notes.md
if [ -n "$PREV_TAG" ]; then
git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" -- apps/editor packages/ui/src/components/editor >> release_notes.md
else
git log --pretty=format:"* %s (%h)" -- apps/editor packages/ui/src/components/editor >> release_notes.md
fi
- name: Create Release
if: steps.check_tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.package_version.outputs.version }}
name: ${{ steps.package_version.outputs.raw_version }} - VS Code
body_path: release_notes.md
target_commitish: ${{ github.sha }}
release-browser:
needs: check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Get version from manifest.json
id: browser_version
run: |
VERSION=$(jq -r .version apps/browser/src/manifest.json)
echo "version=$VERSION-browser" >> $GITHUB_OUTPUT
echo "raw_version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: check_tag
run: |
# Prevent failing if manifest.json was modified but version wasn't bumped
if git ls-remote --tags origin refs/tags/${{ steps.browser_version.outputs.version }} | grep -q 'refs/tags/'; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Generate Release Notes
if: steps.check_tag.outputs.exists == 'false'
run: |
PREV_TAG=$(git describe --tags --match "*-browser" --abbrev=0 2>/dev/null || echo "")
echo "### What's changed in the browser extension:" > release_notes_browser.md
echo "" >> release_notes_browser.md
if [ -n "$PREV_TAG" ]; then
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
else
git log --pretty=format:"* %s (%h)" -- apps/browser packages/shared/src/constants/chatbots.ts packages/ui/src/components/browser >> release_notes_browser.md
fi
- name: Create Release
if: steps.check_tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.browser_version.outputs.version }}
name: ${{ steps.browser_version.outputs.raw_version }} - Browser
body_path: release_notes_browser.md
target_commitish: ${{ github.sha }}