summaryrefslogtreecommitdiff
path: root/.github/workflows/deploy.yml
blob: 4f17a6729fd1071084ef5a472572442b9653c389 (plain)
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
name: Publish

on:
  push:
  pull_request:
  release:
    types: [published]

jobs:
  npm:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: |
          GITREV=$(git rev-parse --short HEAD)
          echo $GITREV
          sed -i "s/^\(.*\"version\".*\)\"\([^\"]\+\)\"\(.*\)\$/\1\"\2-g$GITREV\"\3/" package.json
        if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
      - uses: actions/setup-node@v1
        with:
          # Needs to be explicitly specified for auth to work
          registry-url: 'https://registry.npmjs.org'
      - run: npm install
      - uses: actions/upload-artifact@v2
        with:
          name: npm
          path: lib
      - run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
        if: ${{ github.event_name == 'release' && !github.event.release.prerelease }}
      - run: npm publish --access public --tag beta
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
        if: ${{ github.event_name == 'release' && github.event.release.prerelease }}
      - run: npm publish --access public --tag dev
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
        if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
  snap:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: |
          GITREV=$(git rev-parse --short HEAD)
          echo $GITREV
          sed -i "s/^\(.*\"version\".*\)\"\([^\"]\+\)\"\(.*\)\$/\1\"\2-g$GITREV\"\3/" package.json
        if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
      - run: |
          VERSION=$(grep '"version"' package.json | cut -d '"' -f 4)
          echo $VERSION
          sed -i "s/@VERSION@/$VERSION/g" snap/snapcraft.yaml
      - uses: snapcore/action-build@v1
        id: snapcraft
      - uses: actions/upload-artifact@v2
        with:
          name: snap
          path: ${{ steps.snapcraft.outputs.snap }}
      - uses: snapcore/action-publish@v1
        with:
          store_login: ${{ secrets.SNAPCRAFT_LOGIN }}
          snap: ${{ steps.snapcraft.outputs.snap }}
          release: stable
        if: ${{ github.event_name == 'release' && !github.event.release.prerelease }}
      - uses: snapcore/action-publish@v1
        with:
          store_login: ${{ secrets.SNAPCRAFT_LOGIN }}
          snap: ${{ steps.snapcraft.outputs.snap }}
          release: beta
        if: ${{ github.event_name == 'release' && github.event.release.prerelease }}
      - uses: snapcore/action-publish@v1
        with:
          store_login: ${{ secrets.SNAPCRAFT_LOGIN }}
          snap: ${{ steps.snapcraft.outputs.snap }}
          release: edge
        if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}