Skip to content

Release

Release #21

Workflow file for this run

name: 'CD'
on:
push:
paths:
- '**.ts'
- '**.js'
- '**.yml'
- '**.json'
pull_request:
paths:
- '**.ts'
- '**.js'
- '**.yml'
- '**.json'
jobs:
tests:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Expose GIT Commit Data
uses: rlespinasse/[email protected]
- name: Install the Interpreter
uses: actions/setup-node@v2
with:
node-version: 14.x
cache: yarn
- name: Load the Cached Dependencies
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn install
- name: Test
run: yarn test
outputs:
commit_message: ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}
# Run publish only when the branch is matches, and the commit message could match a release pattern.
publish:
name: Publish Package
runs-on: ubuntu-latest
needs: tests
if: ${{ startsWith(needs.tests.outputs.commit_message, 'Release') && success() && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install the Interpreter
uses: actions/setup-node@v2
with:
node-version: 14.x
always-auth: true
cache: yarn
- name: Load the Cached Dependencies
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn install
- name: Build
run: yarn build
- name: Publish if version has been updated
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
outputs:
changed: ${{ steps.npm-publish.outputs.changed == 'true' }}
version: ${{ steps.npm-publish.outputs.version }}
release:
name: Release GH
runs-on: ubuntu-latest
needs: [tests, publish]
if: ${{ success() && needs.publish.outputs.changed == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.publish.outputs.version }}
tag_name: ${{ needs.publish.outputs.version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}