-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (97 loc) · 3.92 KB
/
release.yaml
File metadata and controls
115 lines (97 loc) · 3.92 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
name: Release Plugin
on:
push:
branches:
- 'release/*'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from branch
id: extract_version
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
VERSION="${BRANCH_NAME#release/}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Check if tag already exists
id: check_tag
run: |
if git rev-parse --verify "refs/tags/${{ steps.extract_version.outputs.version }}" >/dev/null 2>&1; then
echo "tag_exists=true" >> $GITHUB_OUTPUT
echo "Tag ${{ steps.extract_version.outputs.version }} already exists"
else
echo "tag_exists=false" >> $GITHUB_OUTPUT
echo "Tag ${{ steps.extract_version.outputs.version }} does not exist"
fi
- name: Setup Bun
if: steps.check_tag.outputs.tag_exists == 'false'
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
if: steps.check_tag.outputs.tag_exists == 'false'
run: bun install
- name: Run tests
if: steps.check_tag.outputs.tag_exists == 'false'
run: cd packages/plugin && bun test
env:
CI: true
- name: Build plugin
if: steps.check_tag.outputs.tag_exists == 'false'
run: |
cd packages/plugin
bun run build
- name: Create and push tag
if: steps.check_tag.outputs.tag_exists == 'false'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -a "${{ steps.extract_version.outputs.version }}" -m "Release ${{ steps.extract_version.outputs.version }}"
git push origin "${{ steps.extract_version.outputs.version }}"
- name: Create GitHub release
if: steps.check_tag.outputs.tag_exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.extract_version.outputs.version }}"
cd packages/plugin
# Create release with plugin files
gh release create "$VERSION" \
--title="$VERSION" \
--notes="Release $VERSION - See CHANGELOG.md for details" \
--draft \
main.js manifest.json styles.css
- name: Skip release (tag exists)
if: steps.check_tag.outputs.tag_exists == 'true'
run: |
echo "Tag ${{ steps.extract_version.outputs.version }} already exists"
echo "If you want to re-release, delete the tag first: git push --delete origin ${{ steps.extract_version.outputs.version }}"
- name: Update package.json and manifest.json versions
run: |
VERSION="${{ steps.extract_version.outputs.version }}"
echo "Updating version to $VERSION in package.json and manifest.json"
# Update package.json
cd packages/plugin
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" package.json
# Update manifest.json
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" manifest.json
# Show the changes
echo "Updated package.json:"
grep "version" package.json
echo "Updated manifest.json:"
grep "version" manifest.json
cd ../..
- name: Commit version changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add packages/plugin/package.json packages/plugin/manifest.json
git diff --staged --quiet || git commit -m "chore: bump version to ${{ steps.extract_version.outputs.version }}"
git push origin "${GITHUB_REF#refs/heads/}"