|
6 | 6 | - main |
7 | 7 | tags: |
8 | 8 | - 'v*' |
9 | | - workflow_dispatch: |
| 9 | + workflow_dispatch: |
10 | 10 |
|
11 | 11 | jobs: |
12 | 12 | build: |
@@ -48,30 +48,33 @@ jobs: |
48 | 48 | gcc \ |
49 | 49 | make |
50 | 50 |
|
| 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 | +
|
51 | 66 | - name: Build Electron app |
52 | 67 | env: |
53 | 68 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
54 | 69 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
55 | 70 | run: | |
56 | 71 | echo "Running custom build script..." |
57 | 72 | node build.js --build=platform |
58 | | - |
59 | | - # Publish release to GitHub |
| 73 | +
|
| 74 | + # Publish release to GitHub (Only when there's a tag push) |
60 | 75 | - name: Publish Release |
61 | | - if: github.event_name == 'push' |
| 76 | + if: startsWith(github.ref, 'refs/tags/') |
62 | 77 | uses: softprops/action-gh-release@v1 |
63 | 78 | with: |
64 | 79 | files: | |
65 | 80 | 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