Skip to content

Commit

Permalink
improved github action scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Nov 12, 2024
1 parent b463588 commit b9b0ab6
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 3,298 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

tests:
strategy:
matrix:
node:
- 18.x
check-and-test:

runs-on: ubuntu-20.04
name: Node.js ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- uses: actions/cache@v3
node-version-file: ".nvmrc"

- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- uses: actions/cache@v4
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ~/.npm
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Npm update
run: npm update
- name: Npm install
Expand Down
114 changes: 60 additions & 54 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,64 @@ name: Build AR.js libraries
on: push

jobs:
build:
runs-on: ubuntu-latest
check-and-test:
runs-on: ubuntu-20.04

strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set output
id: vars
run: echo name=tag::${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
- name: Check output
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: |
echo $RELEASE_VERSION
echo ${{ steps.vars.outputs.tag }}
- run: npm update
- run: npm install
- uses: actions/upload-artifact@v3
with:
name: build
path: |
aframe/build/*.js
three.js/build/*.js
- run: |
npm run build
- name: Commit changes
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: new build files from action
add: '["aframe/build", "three.js/build"]'
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
aframe/build/aframe-ar.js
aframe/build/aframe-ar-nft.js
aframe/build/aframe-ar-location-only.js
three.js/build/ar.js
three.js/build/ar-threex.js
three.js/build/ar-threex-location-only.js
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"

- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- 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: Set output
id: vars
run: echo name=tag::${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
- name: Check output
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: |
echo $RELEASE_VERSION
echo ${{ steps.vars.outputs.tag }}
- run: npm update
- run: npm install
- uses: actions/upload-artifact@v4
with:
name: build
path: |
aframe/build/*.js
three.js/build/*.js
- run: |
npm run build
- name: Commit changes
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: new build files from action
add: '["aframe/build", "three.js/build"]'
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
aframe/build/aframe-ar.js
aframe/build/aframe-ar-nft.js
aframe/build/aframe-ar-location-only.js
three.js/build/ar.js
three.js/build/ar-threex.js
three.js/build/ar-threex-location-only.js
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.15.0
v20.18.0
Loading

0 comments on commit b9b0ab6

Please sign in to comment.