generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 10
69 lines (59 loc) · 2.1 KB
/
create-release.yml
File metadata and controls
69 lines (59 loc) · 2.1 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
name: Create Release
on:
workflow_dispatch:
jobs:
create-release:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version bump
id: bump
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LATEST_TAG" ]; then
SINCE=$(git rev-list --max-parents=0 HEAD)
COMMITS=$(git log "$SINCE"..HEAD --pretty=format:"%s")
else
COMMITS=$(git log "$LATEST_TAG"..HEAD --pretty=format:"%s")
fi
BUMP="patch"
if echo "$COMMITS" | grep -q "^feat:"; then
BUMP="minor"
fi
if echo "$COMMITS" | grep -q "^breaking:"; then
BUMP="major"
fi
echo "type=$BUMP" >> "$GITHUB_OUTPUT"
- name: Compute new version
id: version
run: |
CURRENT=$(grep '^pluginVersion=' gradle.properties | cut -d= -f2)
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
BUMP="${{ steps.bump.outputs.type }}"
if [ "$BUMP" = "major" ]; then
MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0
elif [ "$BUMP" = "minor" ]; then
MINOR=$((MINOR + 1)); PATCH=0
else
PATCH=$((PATCH + 1))
fi
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "new=$NEW_VERSION" >> "$GITHUB_OUTPUT"
- name: Update gradle.properties
run: |
sed -i "s/^pluginVersion=.*/pluginVersion=${{ steps.version.outputs.new }}/" gradle.properties
- name: Commit and tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add gradle.properties
git commit -m "chore: bump version to ${{ steps.version.outputs.new }}"
git tag "v${{ steps.version.outputs.new }}"
git push origin main --tags