From ba065753b259be6d3f72ab8dfdd68958f4b5f2d0 Mon Sep 17 00:00:00 2001 From: jem Date: Mon, 29 Jun 2020 17:35:04 +0200 Subject: [PATCH] add caching & use single wf & steps --- .github/workflows/release-dev.yml | 52 +++++++++++++++--------------- .github/workflows/release-prod.yml | 51 +++++++++++++++-------------- .github/workflows/test-pr.yml | 22 ++++++++++--- 3 files changed, 70 insertions(+), 55 deletions(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 978da05..c1f4cfe 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -1,5 +1,4 @@ -name: Node.js CI - +name: release dev on: push: tags: '![0-9]+.[0-9]+.[0-9]+' @@ -14,37 +13,38 @@ jobs: steps: - 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 }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm install -g --save-dev shadow-cljs - - run: shadow-cljs compile test + run: npm install + run: npm install -g --save-dev shadow-cljs + run: shadow-cljs compile test - release-build-dev: - 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 }} + - name: build release with node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm install -g --save-dev shadow-cljs - - run: shadow-cljs release app - - run: rm -rf target/npm-build - - run: mkdir -p target/npm-build - - run: cp mastodon-bot.js target/npm-build/ - - 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 . + run: shadow-cljs release app + run: mkdir -p target/npm-build + run: cp mastodon-bot.js target/npm-build/ + 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 id: create_release @@ -56,6 +56,7 @@ jobs: release_name: Release ${{ github.ref }} draft: false prerelease: true + - name: Upload Release Asset id: upload-release-asset uses: actions/upload-release-asset@v1 @@ -66,4 +67,3 @@ jobs: asset_path: ./mastodon-bot.js asset_name: mastodon-bot.js asset_content_type: application/json - \ No newline at end of file diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index 3661983..1806229 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -1,4 +1,4 @@ -name: Node.js CI +name: release prod on: push: @@ -14,37 +14,38 @@ jobs: steps: - 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 }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm install -g --save-dev shadow-cljs - - run: shadow-cljs compile test + run: npm install + run: npm install -g --save-dev shadow-cljs + run: shadow-cljs compile test - release-build-dev: - 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 }} + - name: build release with node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm install -g --save-dev shadow-cljs - - run: shadow-cljs release app - - run: rm -rf target/npm-build - - run: mkdir -p target/npm-build - - run: cp mastodon-bot.js target/npm-build/ - - 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 . + run: shadow-cljs release app + run: mkdir -p target/npm-build + run: cp mastodon-bot.js target/npm-build/ + 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 id: create_release @@ -56,6 +57,7 @@ jobs: release_name: Release ${{ github.ref }} draft: false prerelease: false + - name: Upload Release Asset id: upload-release-asset uses: actions/upload-release-asset@v1 @@ -66,4 +68,3 @@ jobs: asset_path: ./mastodon-bot.js asset_name: mastodon-bot.js asset_content_type: application/json - \ No newline at end of file diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index b636255..45186d5 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -1,4 +1,4 @@ -name: Node.js CI +name: test PR on: pull_request: @@ -14,10 +14,24 @@ jobs: steps: - 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 }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm install -g --save-dev shadow-cljs - - run: shadow-cljs compile test + run: npm install + run: npm install -g --save-dev shadow-cljs + run: shadow-cljs compile test