-
-
Notifications
You must be signed in to change notification settings - Fork 1
108 lines (104 loc) · 3.98 KB
/
devops.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
name: DevOps
on:
[push, pull_request]
env:
nodeLastVersion: '20.X'
jobs:
##############################################################################
# Build application
#
build:
runs-on: ubuntu-latest
name: Build and test
strategy:
matrix:
node-version: [18.X, 20.X, 21.X]
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install globally grunt-cli
run: npm install -g grunt-cli
- name: Install other dependencies
run: npm install
- name: Build .min.js file
run: npm run build
- name: Run tests (QA and unit tests)
run: npm test
- name: SonarCloud Scan
if: (matrix.node-version == "${{ env.nodeLastVersion }}") && (github.event_name != 'pull_request')
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Archive artifacts
if: matrix.node-version == "${{ env.nodeLastVersion }}"
uses: actions/upload-artifact@v3
with:
name: jquery.async-gravatar-${{ github.sha }}.min.js
path: dist/*.min.js
- name: Package
if: matrix.node-version == "${{ env.nodeLastVersion }}" && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v'))
run: npm run release
- name: Archive package
if: matrix.node-version == "${{ env.nodeLastVersion }}" && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v'))
uses: actions/upload-artifact@v3
with:
name: jquery-async-gravatar-${{ github.sha }}.tar.gz
path: build/*.tar.gz
##############################################################################
# Release application
#
release:
needs: build
runs-on: ubuntu-latest
if: contains(github.ref, 'refs/tags/v')
name: Release on GitHub and NPM
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install globally grunt-cli
run: npm install -g grunt-cli
- name: Install other dependencies
run: npm install
- name: Package
run: npm run release
- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes in this Release
- First Change
- Second Change
draft: true
prerelease: false
- name: Upload asset in GitHub release
id: upload-release-asset
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: build/jquery-async-gravatar-${{ env.RELEASE_VERSION }}.tar.gz
asset_name: jquery-async-gravatar-${{ env.RELEASE_VERSION }}.tar.gz
asset_content_type: application/tar+gzip
- name: Create NPM release
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}