-
Notifications
You must be signed in to change notification settings - Fork 1
48 lines (42 loc) · 1.46 KB
/
set_version.yaml
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
name: Sets the version for a release and tags the repo
on:
workflow_dispatch:
inputs:
version:
description: 'The version to set for the release'
required: true
jobs:
setVersion:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Set version in build.gradle
run: |
# Update build.gradle with new version
echo "${{ github.event.inputs.version }}"
sed -i "s/version \"[^\"]*\"/version \"${{ github.event.inputs.version }}\"/g" build.gradle
- name: Set version in README example
run: |
echo "${{ github.event.inputs.version }}"
sed -i "s/implementation 'com.craxiom:mqttlibrary:[^\"]*\'/implementation 'com.craxiom:mqttlibrary:${{ github.event.inputs.version }}\'/g" build.gradle
- name: Commit and push changes
run: |
git config user.email "[email protected]"
git config user.name "Github Actions"
git add .
# Check for changes
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Bump version to ${{ env.VERSION_NAME }}"
git push origin main
fi
- name: Create and push tag
run: |
TAG="v${{ github.event.inputs.version }}"
git tag $TAG
git push origin $TAG