-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (92 loc) · 4.07 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
106
107
108
109
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches: [main]
name: Main CI
env:
NODE_VERSION: '14'
jobs:
build:
name: 🚧 Lint, Test, Build & (optionally) Release
runs-on: ubuntu-latest
steps:
- name: Set RELEASE_VERSION env variable
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Check out Git repository
uses: actions/checkout@v2
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Set C8Y_VERSION env variable
run: echo "C8Y_VERSION=$(node -p -e "require('./package.json').dependencies['@c8y/ngx-components']")" >> $GITHUB_ENV
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Node.js dependencies
run: |
npm ci
- name: 🕵️♂️ Lint
run: |
npm run lint --if-present
- name: 🧪 Test
run: |
npm test --if-present
- name: 🚧 Build Frontend
run: |
npm run build:ci
- name: Upload Frontend Artifact
uses: actions/upload-artifact@v2
with:
name: sag-ps-iot-pkg-layered-map-widget-plugin-${{ env.C8Y_VERSION }}-${{ github.event.number }}-${{ github.run_id }}
if-no-files-found: error
retention-days: 5
path: dist/apps/sag-ps-iot-pkg-layered-map-widget-plugin/
- name: Upload Frontend Artifact (microfrontend)
uses: actions/upload-artifact@v2
with:
name: sag-ps-iot-pkg-layered-map-widget-plugin-${{ env.C8Y_VERSION }}-${{ github.event.number }}-${{ github.run_id }}
if-no-files-found: error
retention-days: 5
path: dist/apps/sag-ps-iot-pkg-layered-map-widget-plugin/
- name: 🎁 Zip Frontend (microfrontend)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
cd dist/apps/sag-ps-iot-pkg-layered-map-widget-plugin
zip -r -q ../../../sag-ps-iot-pkg-layered-map-widget-plugin.zip *
- name: Create Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ env.RELEASE_VERSION }} based on ${{ env.C8Y_VERSION }}
draft: false
prerelease: true
- name: Upload Release Asset Frontend (microfrontend)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
id: upload-release-asset-frontend
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./sag-ps-iot-pkg-layered-map-widget-plugin.zip
asset_name: sag-ps-iot-pkg-layered-map-widget-plugin-${{ env.C8Y_VERSION }}-${{ env.RELEASE_VERSION }}.zip
asset_content_type: application/zip