Skip to content

Commit ee46409

Browse files
committed
#33
1 parent fc959f0 commit ee46409

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77
tags:
88
- 'v*'
9-
workflow_dispatch:
9+
workflow_dispatch:
1010

1111
jobs:
1212
build:
@@ -48,30 +48,33 @@ jobs:
4848
gcc \
4949
make
5050
51+
# Auto increment version using GitHub's Release tag (for example, "v1.2.3")
52+
- name: Increment version for release
53+
run: |
54+
# Only increment if on the main branch
55+
if [[ $GITHUB_REF == "refs/heads/main" ]]; then
56+
VERSION_TAG=$(git describe --tags --abbrev=0)
57+
VERSION_MAJOR=$(echo $VERSION_TAG | cut -d'.' -f1)
58+
VERSION_MINOR=$(echo $VERSION_TAG | cut -d'.' -f2)
59+
VERSION_PATCH=$(echo $VERSION_TAG | cut -d'.' -f3)
60+
NEW_VERSION_PATCH=$((VERSION_PATCH + 1))
61+
NEW_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${NEW_VERSION_PATCH}"
62+
git tag $NEW_VERSION
63+
git push origin $NEW_VERSION
64+
fi
65+
5166
- name: Build Electron app
5267
env:
5368
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5469
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5570
run: |
5671
echo "Running custom build script..."
5772
node build.js --build=platform
58-
59-
# Publish release to GitHub
73+
74+
# Publish release to GitHub (Only when there's a tag push)
6075
- name: Publish Release
61-
if: github.event_name == 'push'
76+
if: startsWith(github.ref, 'refs/tags/')
6277
uses: softprops/action-gh-release@v1
6378
with:
6479
files: |
6580
build/**/*
66-
67-
# Auto increment version using GitHub's Release tag (for example, "v1.2.3")
68-
- name: Increment version for release
69-
run: |
70-
VERSION_TAG=$(git describe --tags --abbrev=0)
71-
VERSION_MAJOR=$(echo $VERSION_TAG | cut -d'.' -f1)
72-
VERSION_MINOR=$(echo $VERSION_TAG | cut -d'.' -f2)
73-
VERSION_PATCH=$(echo $VERSION_TAG | cut -d'.' -f3)
74-
NEW_VERSION_PATCH=$((VERSION_PATCH + 1))
75-
NEW_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${NEW_VERSION_PATCH}"
76-
git tag $NEW_VERSION
77-
git push origin $NEW_VERSION

0 commit comments

Comments
 (0)