-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaction.yml
41 lines (37 loc) · 1.14 KB
/
action.yml
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
name: Tag on NPM Package Version Change
branding:
icon: package
color: green
description: Creates a new Git tag whenever the npm package version has changed.
inputs:
git-user-email:
description: Git user.email to use.
default: 41898282+github-actions[bot]@users.noreply.github.com
git-user-name:
description: Git user.name.
default: github-actions[bot]
tag-prefix:
description: Prefix prepended to the version in package.json
default: v
runs:
using: composite
steps:
- shell: bash
run: |
#!/bin/bash
set -eux
TAG="${TAG_PREFIX}$(cat package.json | jq -r '.version')"
# In case only a shallow clone was done
git fetch --tags
if ! git tag | grep "${TAG}"; then
git config user.name ${GIT_USER_NAME}
git config user.email ${GIT_USER_EMAIL}
git tag -a ${TAG} -m ${TAG}
git push --follow-tags
else
echo "'${TAG}' already exists. No action taken."
fi
env:
GIT_USER_NAME: ${{ inputs.git-user-name }}
GIT_USER_EMAIL: ${{ inputs.git-user-email }}
TAG_PREFIX: ${{ inputs.tag-prefix }}