generated from ngnjs/.github
-
-
Notifications
You must be signed in to change notification settings - Fork 2
121 lines (105 loc) · 3.57 KB
/
release.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
110
111
112
113
114
115
116
117
118
119
120
121
name: Test Suite
on:
push:
branches:
- master
jobs:
build:
name: 'Release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup npm Cache
uses: actions/cache@v4
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: |
npm install -g @quikdev/js
npm install
- name: Setup Docker Cache
uses: actions/cache@v4
id: docker-cache
with:
path: docker-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Load Cached Docker Layers
run: |
if [ -d "docker-cache" ]; then
cat docker-cache/x* > my-image.tar
docker load < my-image.tar
rm -rf docker-cache
fi
- name: Build & Test
if: success()
run: |
npm test
- name: Tag
id: autotagger
if: success()
uses: butlerlogic/[email protected]
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# If the new version/tag is a pre-release (i.e. 1.0.0-beta.1), create
# an environment variable indicating it is a prerelease.
- name: Pre-release
if: steps.autotagger.outputs.tagname != ''
run: |
if [[ "${{ steps.autotagger.output.version }}" == *"-"* ]]; then echo "::set-env IS_PRERELEASE=true";else echo "::set-env IS_PRERELEASE=''";fi
- name: Release
id: create_release
if: steps.autotagger.outputs.tagname != ''
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.autotagger.outputs.tagname }}
body: ${{ steps.autotagger.outputs.tagmessage }}
draft: false
prerelease: env.IS_PRERELEASE != ''
# Build tarballs of the module code.
- name: Build Release Artifacts
id: build_release
if: steps.create_release.outputs.id != ''
run: |
npm run bundle:module
ls -l ./.dist
# Upload tarballs to the release.
- name: Upload Release Artifacts
uses: AButler/[email protected]
if: steps.create_release.outputs.id != ''
with:
files: './.dist/*.tar.gz'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ steps.autotagger.outputs.tagname }}
- name: Publish to npm
id: publish_npm
if: steps.autotagger.outputs.tagname != ''
uses: author/action-publish@master
with:
scan: ./.dist
prerelease_dist_tag: next
env:
REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
- name: Rollback Release
if: failure() && steps.create_release.outputs.id != ''
uses: author/action-rollback@master
with:
tag: ${{ steps.autotagger.outputs.tagname }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}