-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(github-actions): implement semantic-release workflow
- Loading branch information
Showing
3 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Conventional Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
# Run tests | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout git branch | ||
- uses: actions/checkout@v2 | ||
# Install node.js environment | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.x | ||
# Cache node_modules (busting only when yarn.lock change) | ||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | ||
# Install dependencies | ||
- name: Install | ||
run: yarn install --frozen-lockfile | ||
# Run all tests | ||
- name: Test | ||
run: yarn run test | ||
|
||
# Conventional release | ||
release: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout git branch | ||
- uses: actions/checkout@v2 | ||
with: | ||
# Fetch the entire history | ||
fetch-depth: 0 | ||
# Install node.js environment | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.x | ||
# Cache node_modules (busting only when yarn.lock change) | ||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | ||
# Configure git with the built-in token | ||
# (to push back the release updates: package.json's version, CHANGELOG etc.) | ||
- name: Configure Git & NPM | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
# Install dependencies | ||
- name: Install | ||
run: yarn install --frozen-lockfile | ||
# Build all packages | ||
- name: Build | ||
run: yarn run build | ||
# Authenticate yarn towards registry.npmjs.org | ||
- name: Authenticate with Registry | ||
run: | | ||
yarn logout | ||
echo "registry=http://registry.npmjs.org/" >> .npmrc | ||
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> .npmrc | ||
npm whoami | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
# Publish packages | ||
- name: Release | ||
run: yarn semantic-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Simulate Release | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
# Simulate version release | ||
simulate-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout git branch | ||
- uses: actions/checkout@v2 | ||
with: | ||
# Fetch the entire history | ||
fetch-depth: 0 | ||
# Install node.js environment | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.x | ||
# Cache node_modules (busting only when yarn.lock change) | ||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | ||
# Install dependencies | ||
- name: Install | ||
run: yarn install --frozen-lockfile | ||
# Authenticate yarn towards registry.npmjs.org | ||
- name: Authenticate with Registry | ||
run: | | ||
yarn logout | ||
echo "registry=http://registry.npmjs.org/" >> .npmrc | ||
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> .npmrc | ||
npm whoami | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
# Simulate semantic-release version | ||
- name: Simulate release | ||
run: yarn semantic-release --dry-run | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Lint and run test | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout git branch | ||
- uses: actions/checkout@v2 | ||
# Install node.js environment | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.x | ||
# Cache node_modules (busting only when yarn.lock change) | ||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | ||
# Install dependencies | ||
- name: Install | ||
run: yarn install --frozen-lockfile | ||
# Run eslint | ||
- name: Lint | ||
run: yarn run lint | ||
|
||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: ['ubuntu-latest', 'windows-latest'] | ||
node-version: [ | ||
14.x, # current LTS | ||
] | ||
steps: | ||
# Checkout git branch | ||
- uses: actions/checkout@v2 | ||
# Install node.js environment | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
# Cache node_modules (busting only when yarn.lock change) | ||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | ||
# Install dependencies | ||
- name: Install | ||
run: yarn install --frozen-lockfile | ||
# Run all tests | ||
- name: Test | ||
run: yarn run test |