Repository navigation
67 lines (59 loc) · 2.06 KB
/
Copy pathincrease-version.yml
File metadata and controls
67 lines (59 loc) · 2.06 KB
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
name: increase version
# this workflow update version file
# TRIGGERED BY
# - push-master-ci.yml
# - push-rc-ci.yml
# VERSION is made of 3 fragments: version.feature.bug (e.g. 1.7.8)
# a push on release-candidate increase bug fragment (e.g. 1.7.8 -> 1.7.9)
# a push on master increase feature fragment (e.g. 1.7.8 -> 1.8.0)
on:
workflow_call:
secrets:
token:
description: 'Token to commit file on protected branches'
required: true
outputs:
new-sha:
description: "git sha of new commit"
value: ${{ jobs.increase-version-number.outputs.new-sha }}
defaults:
run:
shell: bash
env:
ext-dir: $GITHUB_WORKSPACE/external/install/
jobs:
increase-version-number:
runs-on: ubuntu-latest
outputs:
new-sha: ${{ steps.commit.outputs.commit_long_sha }}
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.token }}
- name: Read VERSION file
id: read
uses: juliangruber/read-file-action@v1
with:
path: ./VERSION
- name: Trim version string and set fragment name according to branch name
id: set
run: |
# this echo remove \n from steps.read.outputs.content
echo "version=${{ steps.read.outputs.content }}" >> $GITHUB_OUTPUT
[[ "${{ github.ref_name }}" == "master" ]] && echo "fragment=feature" >> $GITHUB_OUTPUT || echo "fragment=bug" >> $GITHUB_OUTPUT
- name: Increase version
id: increment
uses: christian-draeger/increment-semantic-version@1.0.2
with:
current-version: "${{ steps.set.outputs.version }}"
version-fragment: "${{ steps.set.outputs.fragment }}"
- name: Store new version in VERSION file
run: |
echo ${{ steps.increment.outputs.next-version }} > VERSION
- name: Commit new VERSION file
uses: EndBug/add-and-commit@v8
id: commit
with:
add: 'VERSION'
default_author: github_actions
message: 'Update version to ${{ steps.increment.outputs.next-version }} [skip ci]'