-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (86 loc) · 3.16 KB
/
ci.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
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
name: CI
on:
push:
branches:
- "*"
tags-ignore:
- "*"
jobs:
pipeline:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set Environment Variables
run: |
echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT
echo "NEW_VERSION=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
echo "PUBLISHED_VERSION=$(npm view react-input-suggestions version)" >> $GITHUB_OUTPUT
echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
id: env_vars
- name: Install Node.js ${{ steps.env_vars.outputs.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Cache node_modules
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Security Audit
run: yarn audit || true
- name: Outdated Packages
run: yarn outdated || true
- name: Coding Standards
run: yarn lint
- name: Test
run: yarn test:coverage
- name: Type
run: yarn type
- name: Build
run: yarn build
- name: Package Public Folder
if: github.ref == 'refs/heads/main'
run: yarn predeploy
- name: Deploy
if: github.ref == 'refs/heads/main'
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: public
- name: Create Changeset
run: |
CHANGELOG=$(git --no-pager log ${{ steps.env_vars.outputs.PUBLISHED_VERSION }}..HEAD --format="%C(auto)%h %s")
DELIMITER="$(openssl rand -hex 8)"
echo "RELEASE_NOTES<<${DELIMITER}" >> $GITHUB_OUTPUT
echo -e "$CHANGELOG" >> $GITHUB_OUTPUT
echo "${DELIMITER}" >> $GITHUB_OUTPUT
id: changeset
- name: Create Release
if: github.ref == 'refs/heads/main'
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
tag_name: ${{ steps.env_vars.outputs.NEW_VERSION }}
release_name: ${{ steps.env_vars.outputs.NEW_VERSION }}
body: "${{ steps.changeset.outputs.RELEASE_NOTES }}\n\n**Full Changelog**: https://github.com/adhamu/react-input-suggestions/compare/${{ steps.env_vars.outputs.PUBLISHED_VERSION }}...${{ steps.env_vars.outputs.NEW_VERSION }}"
draft: false
prerelease: false
- name: Publish to Registry
run: |
pkg_version=${{ steps.env_vars.outputs.NEW_VERSION }}
branch=${{ steps.env_vars.outputs.BRANCH }}
if [[ $branch != "main" ]]; then
yarn version --new-version "$pkg_version-beta$GITHUB_RUN_NUMBER" --no-git-tag-version
yarn publish --tag beta --access public
else
yarn publish --access public
fi