Skip to content

Commit

Permalink
chore: modify workflow-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Apr 27, 2021
1 parent 1f27199 commit 7cfa78a
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
CI: true
- name: Run Linting
run: |
npm run lint
yarn lint
env:
CI: true

Expand Down Expand Up @@ -80,12 +80,12 @@ jobs:
- name: Prepare Environment
run: |
npm install
npm run build
yarn build
env:
CI: true
- name: Run unit tests
run: |
npm run unit
yarn test
env:
CI: true

Expand Down Expand Up @@ -138,13 +138,13 @@ jobs:
COMMIT_DATE=$(date -d @$COMMIT_TIMESTAMP +%Y%m%d-%H%M%S)
GIT_HASH=$(git rev-parse --short HEAD)
PRERELEASE_TAG=nightly-$(echo "${{ steps.prerelease-tag.outputs.tag }}" | sed -r 's/[^a-z0-9]+/-/gi')
npm run standard-version -- --prerelease $PRERELEASE_TAG-$COMMIT_DATE-$GIT_HASH --skip.changelog --skip.commit --skip.tag
yarn standard-version -- --prerelease $PRERELEASE_TAG-$COMMIT_DATE-$GIT_HASH --skip.changelog --skip.commit --skip.tag
env:
CI: true
- name: Build
if: ${{ steps.do-publish.outputs.publish }}
run: |
npm run build
yarn build
env:
CI: true
- name: Publish to NPM
Expand Down
145 changes: 145 additions & 0 deletions .github/workflows/publish-prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Publish pre-release-version to NPM

# Controls when the action will run.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
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: Prepare Environment
run: |
npm install
env:
CI: true
- name: Run Linting
run: |
yarn lint
env:
CI: true

test:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
needs:
- lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
node_version: ['10', '12', '14']
os: [ubuntu-latest] # [windows-latest, macOS-latest]
timeout-minutes: 10
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- 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@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
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: Prepare Environment
run: |
npm install
yarn build
env:
CI: true
- name: Run unit tests
run: |
yarn test
env:
CI: true

publish:
name: Publish to NPM
runs-on: ubuntu-latest
continue-on-error: true
timeout-minutes: 15

# only run on master
if: github.ref == 'refs/heads/master'

needs:
- lint
- test

steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Check if token is set
id: check-npm-token
run: |
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
echo "env NPM_TOKEN not set!"
else
echo ::set-output name=is-ok::"1"
fi
- name: Prepare Environment
if: ${{ steps.check-npm-token.outputs.is-ok }}
run: |
yarn install
env:
CI: true
- name: Get the Prerelease tag
id: prerelease-tag
uses: yuya-takeyama/docker-tag-from-github-ref-action@2b0614b1338c8f19dd9d3ea433ca9bc0cc7057ba
with:
remove-version-tag-prefix: false
- name: Bump prerelease version
if: ${{ steps.do-publish.outputs.publish }}
run: |
COMMIT_TIMESTAMP=$(git log -1 --pretty=format:%ct HEAD)
COMMIT_DATE=$(date -d @$COMMIT_TIMESTAMP +%Y%m%d-%H%M%S)
GIT_HASH=$(git rev-parse --short HEAD)
PRERELEASE_TAG=nightly-$(echo "${{ steps.prerelease-tag.outputs.tag }}" | sed -r 's/[^a-z0-9]+/-/gi')
yarn standard-version -- --prerelease $PRERELEASE_TAG-$COMMIT_DATE-$GIT_HASH --skip.changelog --skip.commit --skip.tag
env:
CI: true
- name: Build
if: ${{ steps.check-npm-token.outputs.is-ok }}
run: |
yarn build
env:
CI: true
- name: Publish nightly to NPM
if: ${{ steps.check-npm-token.outputs.is-ok }}
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
yarn publish:nightly --yes
env:
CI: true
127 changes: 127 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Publish Release-version to NPM

# Controls when the action will run.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
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: Prepare Environment
run: |
npm install
env:
CI: true
- name: Run Linting
run: |
yarn lint
env:
CI: true

test:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
needs:
- lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
node_version: ['10', '12', '14']
os: [ubuntu-latest] # [windows-latest, macOS-latest]
timeout-minutes: 10
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- 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@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
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: Prepare Environment
run: |
npm install
yarn build
env:
CI: true
- name: Run unit tests
run: |
yarn test
env:
CI: true

publish:
name: Publish to NPM
runs-on: ubuntu-latest
continue-on-error: true
timeout-minutes: 15

needs:
- lint
- test

steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Check if token is set
id: check-npm-token
run: |
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
echo "env NPM_TOKEN not set!"
else
echo ::set-output name=is-ok::"1"
fi
- name: Prepare Environment
if: ${{ steps.check-npm-token.outputs.is-ok }}
run: |
npm install
env:
CI: true
- name: Build
if: ${{ steps.check-npm-token.outputs.is-ok }}
run: |
yarn build
env:
CI: true
- name: Publish to NPM
if: ${{ steps.check-npm-token.outputs.is-ok }}
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
yarn publish:latest --yes
env:
CI: true

0 comments on commit 7cfa78a

Please sign in to comment.