Skip to content

Commit 7d5288b

Browse files
committed
Update build-and-release.yml
1 parent a4d009c commit 7d5288b

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

.github/workflows/build-and-release.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ on:
88
branches: [ master ]
99

1010
jobs:
11-
tag-commit-if-version-updated:
12-
name: Tag commit if new version number in package.json
11+
check-if-version-updated:
12+
name: Check if version updated
1313
runs-on: ubuntu-latest
1414
outputs:
15-
NEW_VERSION: ${{ steps.check-if-version-updated.outputs.NEW_VERSION }}
15+
NEW_VERSION: ${{ steps.step2.outputs.NEW_VERSION }}
1616

1717
steps:
1818
- name: Check out Git repository
1919
uses: actions/checkout@v2
2020

2121
- name: Check if version updated
22-
id: check-if-version-updated
22+
id: step2
2323
run: |
2424
VERSION=$(cat 'package.json' | jq -r '.version')
25-
VERSION=0.1.6
25+
# VERSION=0.1.6
2626
if [[ ! $(git tag | grep "${VERSION}") ]]; then
2727
echo "New version: v${VERSION}"
2828
echo "::set-output name=NEW_VERSION::v${VERSION}"
@@ -31,18 +31,28 @@ jobs:
3131
echo "::set-output name=NEW_VERSION::"
3232
fi
3333
34+
tag-commit:
35+
name: Tag commit
36+
needs: check-if-version-updated
37+
if: ${{needs.check-if-version-updated.outputs.NEW_VERSION}}
38+
runs-on: ubuntu-latest
39+
env:
40+
GIT_NAME: "Github Action: ${{github.action}}"
41+
GIT_EMAIL: no-reply@karsten-moholt.no
42+
TAG: ${{steps.check-if-version-updated.outputs.NEW_VERSION}}
43+
steps:
44+
- name: Check out Git repository
45+
uses: actions/checkout@v2
46+
3447
- name: Tag commit with version
35-
if: ${{steps.check-if-version-updated.outputs.NEW_VERSION}}
36-
env:
37-
TAG: ${{steps.check-if-version-updated.outputs.NEW_VERSION}}
3848
run: |
39-
git config --global user.email "no-reply@karsten-moholt.no"
40-
git config --global user.name "Github Action: ${{github.action}}"
49+
git config --global user.name "${GIT_NAME}"
50+
git config --global user.email "${GIT_EMAIL}"
4151
git tag -a ${TAG} -m ${TAG}
4252
git push --follow-tags
4353
4454
release:
45-
needs: tag-commit-if-version-updated
55+
needs: tag-commit
4656
if: ${{needs.tag-commit-if-version-updated.outputs.NEW_VERSION}}
4757
runs-on: ${{ matrix.os }}
4858

0 commit comments

Comments
 (0)