-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
277 additions
and
5 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
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,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 |
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,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 |