-
-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (56 loc) · 2.27 KB
/
publish_dev.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
name: Publish Dev Build
on:
push:
branches:
- main
jobs:
build:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v1
- name: Install Node v14
uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm install
- name: Build package
run: npm run build
- name: Clone staging, prep, and check for changes
id: staging
run: |
git clone https://${{ github.actor }}:${{ secrets.DOCS_TOKEN }}@github.com/${{ github.repository }}.git -b staging ../staging
cd ../staging
# Delete everything but .git directory
ls -la | grep -oP '\S+?(?<!\.git|\.)$' | xargs rm -rf
# Return to main repo directory
cd ../$(echo '${{ github.repository }}' | grep -oP '/\K.+')
# Copy src files to staging
cp -a src/. ../staging/.
# Copy package.json to staging (Package changes warrant rebuild)
cp package.json ../staging/package.json
# Remove tests from staging, dont need to publish new build for test changes
rm -rf ../staging/__test__
cd ../staging
echo "##[set-output name=status;]$(git status | grep 'nothing to commit')"
- name: Update staging
if: contains(steps.staging.outputs.status, 'nothing to commit') != true
run: |
cd ../staging
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor}}@users.noreply.github.com"
git add --all
git commit -m "Push staging from: ${{ github.sha }}"
git push origin staging
- name: Generate dev version
if: contains(steps.staging.outputs.status, 'nothing to commit') != true
run: |
npm --no-git-tag-version version $(cat package.json | grep -oP '"version": "\K[^"]+(?=")')-dev.$(git rev-parse --verify HEAD)
- name: Publish to NPM
if: contains(steps.staging.outputs.status, 'nothing to commit') != true
run: npm publish --tag dev --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}