Skip to content

Commit acc60fc

Browse files
Merge pull request #4548 from hmislk/Issue#4547
Signed-off-by: Lawan Samarasekara <[email protected]>
2 parents 53b1a98 + 431771d commit acc60fc

File tree

1 file changed

+14
-35
lines changed

1 file changed

+14
-35
lines changed

.github/workflows/create_version.yml

+14-35
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
name: Update Version and README
22

33
on:
4-
push:
5-
branches:
6-
- master
74
pull_request:
85
# The branches below must be a subset of the branches above
9-
branches: [ "master" ]
6+
branches: [ "master" ]:
107

118
jobs:
129
update_version_and_readme:
@@ -15,50 +12,32 @@ jobs:
1512
steps:
1613
- name: Checkout code
1714
uses: actions/checkout@v2
18-
15+
1916
- name: Set up Python
2017
uses: actions/setup-python@v2
2118
with:
2219
python-version: '3.x'
2320

24-
- name: Determine current commit number
25-
id: current_commit
26-
run: echo "::set-output name=commit_number::$(git rev-parse HEAD)"
27-
28-
- name: Read previous commit number from file
29-
id: read_prev_commit
30-
run: echo "::set-output name=prev_commit::$(cat commit_number.txt || echo '')"
31-
32-
- name: Compare commit numbers
33-
id: compare_commit
34-
run: |
35-
if [ "${{ steps.current_commit.outputs.commit_number }}" != "${{ steps.read_prev_commit.outputs.prev_commit }}" ]; then
36-
echo "commit_numbers_different=true" >> $GITHUB_ENV
37-
else
38-
echo "commit_numbers_different=false" >> $GITHUB_ENV
39-
fi
40-
41-
- name: Increment version if commit numbers differ
42-
id: increment_version
43-
if: env.commit_numbers_different == 'true'
44-
run: echo "increment_version=true" >> $GITHUB_ENV
45-
4621
- name: Determine current date
47-
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV
22+
id: current_date
23+
run: echo "::set-output name=date::$(date +'%Y%m%d')"
4824

4925
- name: Read merge counter from file
50-
run: echo "counter=$(cat counter.txt || echo '0')" >> $GITHUB_ENV
26+
id: read_counter
27+
run: echo "::set-output name=counter::$(cat counter.txt || echo '0')"
5128

52-
- name: Increment merge counter if needed
53-
if: steps.increment_version.outputs.increment_version == 'true'
54-
run: echo "counter=$((counter + 1))" >> $GITHUB_ENV
29+
- name: Increment merge counter
30+
id: increment_counter
31+
run: |
32+
counter=$((${{ steps.read_counter.outputs.counter }} + 1))
33+
echo "::set-output name=counter::$counter"
5534
5635
- name: Update version file with date and merge counter
57-
run: echo "3.0.0.${{ env.date }}.${{ env.counter }}" > VERSION.txt
36+
run: echo "3.0.0.${{ steps.current_date.outputs.date }}.${{ steps.increment_counter.outputs.counter }}" > VERSION.txt
5837

5938
- name: Update README.md
6039
run: |
61-
sed -i "s/Current Version:.*/Current Version: 3.0.0.${{ env.date }}.${{ env.counter }} (This line will be automatically updated to reflect the latest version)/" README.md
40+
sed -i "s/Current Version:.*/Current Version: 3.0.0.${{ steps.current_date.outputs.date }}.${{ steps.increment_counter.outputs.counter }} (This line will be automatically updated to reflect the latest version)/" README.md
6241
6342
- name: Set up Git identity
6443
run: |
@@ -68,5 +47,5 @@ jobs:
6847
- name: Commit version and README update
6948
run: |
7049
git add VERSION.txt README.md
71-
git commit -m "Update version to 3.0.0.${{ env.date }}.${{ env.counter }}"
50+
git commit -m "Update version to 3.0.0.${{ steps.current_date.outputs.date }}.${{ steps.increment_counter.outputs.counter }}"
7251
git push

0 commit comments

Comments
 (0)