add caching & use single wf & steps

This commit is contained in:
jem 2020-06-29 17:35:04 +02:00
parent 8ceded6122
commit ba065753b2
3 changed files with 70 additions and 55 deletions

View file

@ -1,5 +1,4 @@
name: Node.js CI name: release dev
on: on:
push: push:
tags: '![0-9]+.[0-9]+.[0-9]+' tags: '![0-9]+.[0-9]+.[0-9]+'
@ -14,37 +13,38 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- 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.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: npm install run: npm install
- run: npm install -g --save-dev shadow-cljs run: npm install -g --save-dev shadow-cljs
- run: shadow-cljs compile test run: shadow-cljs compile test
release-build-dev: - name: build release with node.js ${{ matrix.node-version }}
name: release dev
needs: test-matrix
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: npm install run: shadow-cljs release app
- run: npm install -g --save-dev shadow-cljs run: mkdir -p target/npm-build
- run: shadow-cljs release app run: cp mastodon-bot.js target/npm-build/
- run: rm -rf target/npm-build run: cp package.json target/npm-build/
- run: mkdir -p target/npm-build run: cp README.md target/npm-build/
- run: cp mastodon-bot.js target/npm-build/ run: tar -cz -C target/npm-build -f target/npm-build.tgz .
- run: cp package.json target/npm-build/
- run: cp README.md target/npm-build/
- run: tar -cz -C target/npm-build -f target/npm-build.tgz .
- name: Create Release - name: Create Release
id: create_release id: create_release
@ -56,6 +56,7 @@ jobs:
release_name: Release ${{ github.ref }} release_name: Release ${{ github.ref }}
draft: false draft: false
prerelease: true prerelease: true
- name: Upload Release Asset - name: Upload Release Asset
id: upload-release-asset id: upload-release-asset
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
@ -66,4 +67,3 @@ jobs:
asset_path: ./mastodon-bot.js asset_path: ./mastodon-bot.js
asset_name: mastodon-bot.js asset_name: mastodon-bot.js
asset_content_type: application/json asset_content_type: application/json

View file

@ -1,4 +1,4 @@
name: Node.js CI name: release prod
on: on:
push: push:
@ -14,37 +14,38 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- 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.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: npm install run: npm install
- run: npm install -g --save-dev shadow-cljs run: npm install -g --save-dev shadow-cljs
- run: shadow-cljs compile test run: shadow-cljs compile test
release-build-dev: - name: build release with node.js ${{ matrix.node-version }}
name: release dev
needs: test-matrix
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: npm install run: shadow-cljs release app
- run: npm install -g --save-dev shadow-cljs run: mkdir -p target/npm-build
- run: shadow-cljs release app run: cp mastodon-bot.js target/npm-build/
- run: rm -rf target/npm-build run: cp package.json target/npm-build/
- run: mkdir -p target/npm-build run: cp README.md target/npm-build/
- run: cp mastodon-bot.js target/npm-build/ run: tar -cz -C target/npm-build -f target/npm-build.tgz .
- run: cp package.json target/npm-build/
- run: cp README.md target/npm-build/
- run: tar -cz -C target/npm-build -f target/npm-build.tgz .
- name: Create Release - name: Create Release
id: create_release id: create_release
@ -56,6 +57,7 @@ jobs:
release_name: Release ${{ github.ref }} release_name: Release ${{ github.ref }}
draft: false draft: false
prerelease: false prerelease: false
- name: Upload Release Asset - name: Upload Release Asset
id: upload-release-asset id: upload-release-asset
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
@ -66,4 +68,3 @@ jobs:
asset_path: ./mastodon-bot.js asset_path: ./mastodon-bot.js
asset_name: mastodon-bot.js asset_name: mastodon-bot.js
asset_content_type: application/json asset_content_type: application/json

View file

@ -1,4 +1,4 @@
name: Node.js CI name: test PR
on: on:
pull_request: pull_request:
@ -14,10 +14,24 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- 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.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: npm install run: npm install
- run: npm install -g --save-dev shadow-cljs run: npm install -g --save-dev shadow-cljs
- run: shadow-cljs compile test run: shadow-cljs compile test