Skip to content

Commit

Permalink
chore: improved github workflow for v3.x work
Browse files Browse the repository at this point in the history
  • Loading branch information
lquixada committed Jun 1, 2023
1 parent e624887 commit 4f63519
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 20 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/ci.yml → .github/workflows/branch.yml
@@ -1,11 +1,9 @@
name: Main Branch
name: v3.x branch

on:
push:
branches:
- v3.x
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v3.x

jobs:
install:
Expand Down Expand Up @@ -44,9 +42,3 @@ jobs:
- run: make secure
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

release:
name: Release
if: startsWith(github.event.ref, 'refs/tags/')
needs: [checks, security]
uses: ./.github/workflows/release.yml
26 changes: 21 additions & 5 deletions .github/workflows/checks.yml
@@ -1,15 +1,15 @@
name: Checks
name: checks

on: [workflow_call]

jobs:
test:
name: Test specs
test-node:
name: Node Test Specs
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]
node-version: [14.x, 16.x, 18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
Expand All @@ -22,7 +22,23 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install --prefer-offline
- run: make test
- run: make test-node

test-browser:
name: Browser Test Specs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install --prefer-offline
- run: make test-browser

lint:
name: Code Lint
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pr.yml
@@ -1,11 +1,13 @@
name: Pull Request
name: v3.x pull requests

on:
pull_request_target:
types:
- opened
- edited
- synchronize
branches:
- v3.x

jobs:
prlint:
Expand Down
51 changes: 47 additions & 4 deletions .github/workflows/release.yml
@@ -1,11 +1,53 @@
name: Release
name: v3.x release

on: [workflow_call]
on:
push:
tags:
- v3.[0-9]+.[0-9]+
- v3.[0-9]+.[0-9]+-(alpha|beta).[0-9]+ # prerelease

jobs:
install:
name: Install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache node_modules
id: cacheModules
uses: actions/cache@v3
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
- name: Install dependencies
if: steps.cacheModules.outputs.cache-hit != 'true'
run: npm install

checks:
name: Check
needs: [install]
uses: ./.github/workflows/checks.yml

# The security job can't run on pull requests opened from forks because
# Github doesn't pass down the SNYK_TOKEN environment variable.
security:
name: Check Security
needs: [install]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
- run: npm install --prefer-offline
- run: make secure
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

npm:
name: Publish to NPM registry
runs-on: ubuntu-latest
needs: [checks, security]
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
Expand All @@ -18,13 +60,14 @@ jobs:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
- run: npm install --prefer-offline
- run: npm publish
- run: npm publish --tag latest-v3.x
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

github:
name: Publish to Github registry
runs-on: ubuntu-latest
needs: [checks, security]
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to GitHub Packages
Expand All @@ -39,6 +82,6 @@ jobs:
- run: npm install --prefer-offline
# The package name needs to be scoped in order to publish on Github Registry
- run: sed -i 's/"cross-fetch"/"@lquixada\/cross-fetch"/g' package.json
- run: npm publish
- run: npm publish --tag latest-v3.x
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 4f63519

Please sign in to comment.