Skip to content

chore: setup auto release #3422

chore: setup auto release

chore: setup auto release #3422

Workflow file for this run

name: CI & Release
# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
run-name: >-
${{
inputs.release && 'Publish to NPM' ||
''
}}
on:
push:
branches:
- 7.x
pull_request:
branches:
- 7.x
workflow_dispatch:
inputs:
release:
description: 'Publish new release'
required: true
default: false
type: boolean
permissions:
contents: read # for checkout
jobs:
build:
name: Lint and build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
- name: Install dependencies
run: npm ci
- name: lint, prettier --check
run: npm run lint
test:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [build]
strategy:
matrix:
node_version: [12, 14, 16, 17]
# @TODO figure out why windows-latest is hanging so mcuh
#os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@master
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm ci
- name: build:lib, test:integration
run: |
npm run build:lib
npm run test:integration
browser:
name: Test browser.js
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
- name: Install dependencies
run: npm ci
- name: build:browser.js, test:browser.js
run: |
npm run build:browser.js
npm run test:browser.js
e2e:
name: Run integration tests on real redis
runs-on: ubuntu-latest
needs: [build]
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
- name: Install dependencies
run: npm ci
- name: test:e2e
run: npm run test:e2e -- --detectOpenHandles
release:
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
needs: [build, test, browser, e2e]
# only run if opt-in during workflow_dispatch
if: github.event.inputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- run: npm ci --ignore-scripts
- run: npm audit signatures
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
# e.g. git tags were pushed but it exited before `npm publish`
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}