-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
113 lines (103 loc) · 3.47 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
---
name: actions-release-ui-components
description: |
Releases the UI Components package to NPM and GitHub.
inputs:
NPM_TOKEN:
description: The NPM token to use for publishing the package.
required: true
GITHUB_TOKEN:
description: The Github token to use for creating the release.
required: true
RELEASE_TYPE:
description: The type of release to perform - value should be patch, minor, or major
required: true
default: 'patch'
SKIP_BUILD:
description: Skip the build step.
required: true
default: 'false'
WORKING_DIR:
description: The directory containing the package to build and release. Defaults to repository root.
required: false
default: '.'
outputs:
version:
value: ${{ steps.publish.outputs.version }}
description: The version of the package that was published.
type:
value: ${{ steps.publish.outputs.type }}
description: The type of the package that was published.
runs:
using: composite
steps:
- name: Setup Node
id: setup_node
uses: prefecthq/actions-setup-nodejs@main
- name: Bump Package Version
id: bump_version
working-directory: ${{ inputs.WORKING_DIR }}
run: |
npm version ${{ inputs.RELEASE_TYPE }}
echo "RELEASE_VERSION=$(cat package.json | jq .version | tr -d '"')" >> $GITHUB_ENV
shell: bash
# If the working directory is the root, we need npm will create the commits and tag for us
- name: Bump Version and Create Release
if: ${{ inputs.WORKING_DIR == '.' }}
env:
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
working-directory: ${{ inputs.WORKING_DIR }}
run: |
git checkout -b $RELEASE_VERSION
git push --set-upstream origin $RELEASE_VERSION
gh pr create --base main -f
gh pr merge --squash --admin --delete-branch
shell: bash
# If the working directory is not the root, we need to manually create the commits and tag
- name: Bump Version and Create Release
if: ${{ inputs.WORKING_DIR != '.' }}
env:
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
working-directory: ${{ inputs.WORKING_DIR }}
run: |
git checkout -b $RELEASE_VERSION
git commit -am "$RELEASE_VERSION"
git push --set-upstream origin $RELEASE_VERSION
gh pr create --base main -f
# Create and push a Tag of the new version
git tag $RELEASE_VERSION
git push origin tags/$RELEASE_VERSION
# Once tag is pushed, merge the PR
gh pr merge --squash --admin --delete-branch
shell: bash
- uses: actions/checkout@v4
with:
ref: main
- name: Install Dependencies
working-directory: ${{ inputs.WORKING_DIR }}
run: npm ci
shell: bash
- name: Build Package
if: ${{ inputs.SKIP_BUILD == 'false' }}
working-directory: ${{ inputs.WORKING_DIR }}
run: npm run build
shell: bash
- name: Publish Package to NPM
id: publish
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ inputs.NPM_TOKEN }}
strategy: upgrade
access: public
package: ${{ inputs.WORKING_DIR }}/package.json
- name: Create Release
if: ${{ steps.publish.outputs.type }}
env:
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
tag: ${{ steps.publish.outputs.version }}
run: |
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="Release ${tag#v}" \
--generate-notes
shell: bash