Skip to content

Commit

Permalink
Automate releasing and publishing to npm (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkudrna committed Oct 1, 2020
1 parent 658a2ed commit 5d7d065
Show file tree
Hide file tree
Showing 5 changed files with 285 additions and 95 deletions.
34 changes: 34 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
exclude-labels:
- 'skip changelog'
categories:
- title: '⚠️ Breaking Changes'
label: 'BC'
- title: '🌟 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐞 Bug Fixes'
labels:
- 'bug'
- 'bugfix'
- title: '♻️ Refactoring'
label: 'refactoring'
- title: '📖 Documentation'
label: 'documentation'
- title: '🔧 Maintenance'
label: 'maintenance'
version-resolver:
major:
labels:
- 'BC'
minor:
labels:
- 'feature'
patch:
labels:
- 'bug'
- 'bugfix'
default: patch
template: $CHANGES
20 changes: 20 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR Labeler

on:
pull_request:
types: [opened, edited]
# types: [opened]

jobs:
pr-labeler:
runs-on: ubuntu-18.04
steps:
- uses: TimonVS/pr-labeler-action@v3
with:
BC: bc/*
feature: feature/*
bugfix: bugfix/*
maintenance: maintenance/*
'skip changelog': release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133 changes: 133 additions & 0 deletions .github/workflows/release-management.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Release Management

on:
push:
branches: [maintenance/71]
# branches: [master]

jobs:
build_and_test:
runs-on: ubuntu-18.04
steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm test

- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: docs
path: dist/docs

update_release_draft:
needs: [build_and_test]
runs-on: ubuntu-18.04
steps:
- name: Draft release on GitHub
uses: release-drafter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish_release_draft_on_version_bump:
needs: [update_release_draft]
runs-on: ubuntu-18.04
steps:
- name: Clone repository
uses: actions/checkout@v2

# An existing release draft is published only if there is a version bump in `package.json`.
- name: Publish the matching GitHub release draft
id: github_release
uses: JamesMGreene/node-draft-releaser@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Write out the release URL
run: echo "Released at $RELEASE_URL"
env:
RELEASE_URL: ${{ steps.github_release.outputs.release_url }}

publish_package_to_npm:
needs: [publish_release_draft_on_version_bump]
runs-on: ubuntu-18.04
steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install
run: npm ci

- name: Publish to npm
run: npm publish --dry-run
# run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}}

deploy_docs:
needs: [publish_release_draft_on_version_bump]
runs-on: ubuntu-18.04
steps:
- name: Clone repository
uses: actions/[email protected]
with:
persist-credentials: false

- name: Download artifacts
uses: actions/download-artifact@v1
with:
name: docs

- name: Deploy docs to GitHub Pages
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FOLDER: docs # Must match the name of the artifact used.
REPOSITORY_NAME: react-ui-org/react-ui-docs
ACCESS_TOKEN: ${{ secrets.DOCS_REPOSITORY_ACCESS_TOKEN }}
BRANCH: master
TARGET_FOLDER: docs
COMMIT_MESSAGE: Release new version
CLEAN: true
65 changes: 34 additions & 31 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
name: Build and Run Tests

on:
- push
- pull_request
push:
branches-ignore:
- master
pull_request:
branches:
- master

jobs:
build:

build_and_test:
runs-on: ubuntu-18.04

strategy:
matrix:
node-version: [ 12 ]

steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.github/workflows/test.yml') }}
restore-keys: |
${{ runner.OS }}-node-v${{ matrix.node }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.github/workflows/test.yml') }}
${{ runner.OS }}-node-v${{ matrix.node }}-
- name: Install
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm test
- name: Clone repository
uses: actions/checkout@v2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-node-v${{ matrix.node }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-node-v${{ matrix.node }}-${{ env.cache-name }}-
${{ runner.os }}-build-node-v${{ matrix.node }}-
- name: Install
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm test
Loading

0 comments on commit 5d7d065

Please sign in to comment.