-
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (64 loc) · 2.07 KB
/
version.yml
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
name: Update Version
on:
push:
branches:
- main
jobs:
update_version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get commit count and last commit hash
id: get_info
run: |
COMMIT_COUNT=$(git rev-list --count HEAD)
echo "commit_count=$COMMIT_COUNT" >> $GITHUB_ENV
echo "last_commit_hash=$LAST_COMMIT_HASH" >> $GITHUB_ENV
- name: Create VERSION file
run: |
# Формируем версию
echo "$VERSION" > VERSION
- name: Commit and push changes
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git add VERSION
git commit -m "Update VERSION file"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Update Version
on:
push:
branches:
- main
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get current version
id: get_version
run: |
LAST_COMMIT_HASH=$(git rev-parse HEAD) # Получаем полный хеш
VERSION=$(cat VERSION)
echo "Current version: $VERSION"
echo "::set-output name=current_version::$VERSION"
- name: Increment version
id: increment_version
run: |
IFS='.' read -r major minor patch <<< "${{ steps.get_version.outputs.current_version }}"
new_patch=$((patch + 1))
new_version="$major.$minor.$new_patch"
echo "New version: $new_version"
echo "$new_version" > VERSION
echo "::set-output name=new_version::$new_version"
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add VERSION
git commit -m "Update version to ${{ steps.increment_version.outputs.new_version }}" || echo "No changes to commit"
git push