-
Notifications
You must be signed in to change notification settings - Fork 2
45 lines (36 loc) · 1.26 KB
/
version-bump.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
name: Version Bump
# Bump the current version following Semver MAJOR.MINOR.PATCH
# Update PATCH number with every commit
on:
push:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
version-bump:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Increment Version
id: increment_version
run: |
VERSION=$(cat VERSION)
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
# Update the VERSION file
echo "$NEW_VERSION" > VERSION
echo "NEW_VERSION=$(cat NEW_VERSION)" >> "$GITHUB_ENV"
# Update Version in mix.exs
sed -i 's/$VERSION/$NEW_VERSION/g' tololo/mix.exs
- name: Commit Updated Version
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add VERSION
git add tololo/mix.exs
git commit -m "Bump version to $NEW_VERSION"
git push --force