-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (45 loc) · 1.76 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
49
50
51
name: Sets the version for a release and tags the repo
run-name: Set the version number to ${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: 'The version to set for the release (e.g. 1.0.0)'
required: true
jobs:
setVersion:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
# You must use a personal access token when pushing the tag or it won't trigger the next workflow (purposefully done by GH to prevent runaway recursive workflows)
token: ${{ secrets.MY_GH_TOKEN }}
- 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" MqttLibrary/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" README.md
- 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 ${{ github.event.inputs.version }}"
git push origin main
fi
- name: Create and push tag
run: |
TAG="v${{ github.event.inputs.version }}"
git tag $TAG
git push origin $TAG