-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
125 lines (107 loc) · 3.58 KB
/
action.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: "Autobump version and publish to npm"
description: "Hedia's npm package autobumper & publisher"
inputs:
github-token:
description: "Required by izhangzhihao/delete-comment to remove comment from PR"
required: true
npm-token:
description: "Required to publish package to npm"
required: true
label:
description: "Type of version bump [major, minor, patch]"
required: false
issue-number:
description: "Required by peter-evans/create-or-update-comment & izhangzhihao/delete-comment in order to write/remove comments on the current PR"
required: true
is-post-merge:
description: "To identify if package should be published as release on npm when post-merging the PR"
required: false
default: "false"
git-name:
description: "Value for git config user.name"
required: false
default: "HediaBot [bot]"
git-email:
description: "Value for git config user.email"
required: false
default: "[email protected]"
runs:
using: "composite"
steps:
- name: Use Node.js from package.json
uses: actions/[email protected]
with:
node-version-file: 'package.json'
cache: "npm"
- name: Set git identity
run: |
git config --global user.name ${{ inputs.git-name }}
git config --global user.email ${{ inputs.git-email }}
shell: bash
- name: Set npm access token
run: |
echo "Set npm access token"
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ inputs.npm-token }}
shell: bash
- name: Bump package version
id: bump-package-version
run: |
if [[ "${{inputs.is-post-merge}}" == 'false' ]]; then
echo "Fetching latest package version"
chmod +x ${{ github.action_path }}/bump-package-version.sh
${{ github.action_path }}/bump-package-version.sh "${LABEL}"
else
echo "Skipped bumping version"
fi
exit 0
env:
LABEL: ${{ inputs.label }}
shell: bash
- name: Publish package on npm
id: publish-package-npm
run: |
if [[ "${{inputs.is-post-merge}}" == 'true' ]]; then
echo "Publishing release on npm"
publish=$(npm publish)
version=${publish##*+}
else
echo "Publishing alpha on npm"
publish=$(npm publish --tag alpha)
version=${publish##*+}
fi
echo "publish-output=$version" >> $GITHUB_OUTPUT
shell: bash
- name: Remove alpha tag
id: remove-alpha-tag
run: |
if [[ "${{inputs.is-post-merge}}" == 'false' ]]; then
echo "Removing the alpha-tag"
chmod +x ${{ github.action_path }}/remove-alpha-tag.sh
${{ github.action_path }}/remove-alpha-tag.sh
else
echo "Skipped remove-alpha-tag"
fi
exit 0
shell: bash
- name: Remove old comment from PR
id: delete-comment
uses: izhangzhihao/delete-comment@master
with:
github_token: ${{ inputs.github-token }}
delete_user_name: ${{ inputs.git-name }}
issue_number: ${{ inputs.issue-number }} # remove comments from the current PR
- name: Write comment on PR
id: write-comment
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ inputs.github-token }}
issue-number: ${{ inputs.issue-number }}
body: |
🎉 Successfully published new version 🎉
✅ ${{ steps.publish-package-npm.outputs.publish-output }}
[skip ci]
branding:
icon: "arrow-up-circle"
color: "purple"