Skip to content

Commit

Permalink
ci(github-actions): implement semantic-release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
flo-sch committed Apr 16, 2021
1 parent ce9599f commit a7963a5
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/release.yml
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 }}
41 changes: 41 additions & 0 deletions .github/workflows/simulate-release.yml
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 }}
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
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

0 comments on commit a7963a5

Please sign in to comment.