-
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(gh-actions): add a release workflow
- Loading branch information
1 parent
e242059
commit 3784f2b
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['14'] | ||
name: "[v${{ matrix.node-version }}] check" | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2-beta | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
# Check if cache exists, based on the hash of the lockfile | ||
- name: Cache node_modules | ||
id: cache-node_modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node-${{matrix.node-version}}- | ||
${{ runner.os }}-node- | ||
${{ runner.os }}- | ||
# If there is no cache available, we run npm installation in CI mode | ||
- name: Install dependencies | ||
if: steps.cache-node_modules.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
- name: Lint | ||
run: npm run lint | ||
|
||
- name: Run tests | ||
run: npm run test | ||
|
||
build-and-release: | ||
runs-on: ubuntu-latest | ||
needs: prepare | ||
strategy: | ||
matrix: | ||
node-version: ['14'] | ||
name: "[v${{ matrix.node-version }}] release" | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2-beta | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
# Check if cache exists, based on the hash of the lockfile | ||
- name: Cache node_modules | ||
id: cache-node_modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node-${{matrix.node-version}}- | ||
${{ runner.os }}-node- | ||
${{ runner.os }}- | ||
# If there is no cache available, we run npm installation in CI mode | ||
- name: Install dependencies | ||
if: steps.cache-node_modules.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
# Build and check if it builds ok. | ||
- name: Build | ||
env: | ||
BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE }} | ||
run: npm run build | ||
|
||
- name: Release | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: npm run release |