feature: Use GitHub workflows :breaking:
This commit is contained in:
parent
a4c43bd6ae
commit
0b323105ab
3 changed files with 152 additions and 94 deletions
|
|
@ -1,92 +0,0 @@
|
|||
version: 2
|
||||
jobs:
|
||||
build-common: &common-build
|
||||
docker:
|
||||
- image: node
|
||||
working_directory: ~/diff2html
|
||||
steps: &common-steps
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
- run: yarn
|
||||
- save_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- ./node_modules
|
||||
- run: yarn run build
|
||||
- run: yarn run coverage
|
||||
|
||||
build-latest: &latest-build
|
||||
docker:
|
||||
- image: node
|
||||
working_directory: ~/diff2html
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
- run: yarn
|
||||
- save_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- ./node_modules
|
||||
- run: yarn run build
|
||||
- run: yarn run lint
|
||||
- run: yarn run coverage
|
||||
- run: yarn run codacy
|
||||
- persist_to_workspace:
|
||||
root: ~/diff2html
|
||||
paths:
|
||||
- docs
|
||||
- build
|
||||
|
||||
build-node_8:
|
||||
<<: *common-build
|
||||
docker:
|
||||
- image: node:8
|
||||
|
||||
build-node_10:
|
||||
<<: *common-build
|
||||
docker:
|
||||
- image: node:10
|
||||
|
||||
build-node_11:
|
||||
<<: *common-build
|
||||
docker:
|
||||
- image: node:11
|
||||
|
||||
build-node_12:
|
||||
<<: *common-build
|
||||
docker:
|
||||
- image: node:12
|
||||
|
||||
build-node_13:
|
||||
<<: *latest-build
|
||||
docker:
|
||||
- image: node:13
|
||||
|
||||
deploy:
|
||||
machine:
|
||||
enabled: true
|
||||
working_directory: ~/diff2html
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: Deploy
|
||||
working_directory: ~/diff2html/docs
|
||||
command: aws s3 sync . s3://diff2html.xyz --region eu-west-1
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build:
|
||||
jobs:
|
||||
- build-node_10
|
||||
- build-node_11
|
||||
- build-node_12
|
||||
- build-node_13
|
||||
- deploy:
|
||||
requires:
|
||||
- build-node_13
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
||||
151
.github/workflows/nodejs.yml
vendored
Normal file
151
.github/workflows/nodejs.yml
vendored
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
name: CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
version:
|
||||
runs-on: ubuntu-18.04
|
||||
container:
|
||||
image: codacy/git-version
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git checkout -f ${GITHUB_REF#refs/heads/}
|
||||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
git config user.name "$GITHUB_ACTOR"
|
||||
- name: Get next version
|
||||
id: git-version
|
||||
run: |
|
||||
export NEXT_VERSION="$(/bin/git-version --folder=$PWD)"
|
||||
echo "Next version is ${NEXT_VERSION}"
|
||||
echo "${NEXT_VERSION}" > version.txt
|
||||
- name: Save version artifact
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: version
|
||||
path: version.txt
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: version
|
||||
env:
|
||||
CI: true
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [10.x, 11.x, 12.x, 13.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Setup Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: node -v
|
||||
- run: yarn -v
|
||||
- name: Get yarn cache
|
||||
id: yarn-cache
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ steps.yarn-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: Install dependencies
|
||||
run: yarn install
|
||||
- name: Build
|
||||
run: yarn run build
|
||||
- name: Lint
|
||||
run: yarn run lint
|
||||
- name: Test
|
||||
run: yarn run coverage
|
||||
- name: Push coverage to Codacy
|
||||
if: matrix.node-version == '13.x'
|
||||
env:
|
||||
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||
run: yarn run codacy
|
||||
- name: Save coverage report
|
||||
if: matrix.node-version == '13.x'
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: coverage
|
||||
path: coverage
|
||||
- name: Save website artifact
|
||||
if: matrix.node-version == '13.x'
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: website
|
||||
path: docs
|
||||
|
||||
deploy:
|
||||
if: github.ref == 'refs/heads/master'
|
||||
needs: build
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- name: Download website artifact
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: website
|
||||
- name: Deploy website
|
||||
env:
|
||||
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
run: |
|
||||
cd docs
|
||||
aws s3 sync . s3://diff2html.xyz --region eu-west-1
|
||||
|
||||
publish:
|
||||
if: github.ref == 'refs/heads/github-workflows'
|
||||
needs: build
|
||||
runs-on: ubuntu-18.04
|
||||
env:
|
||||
CI: true
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Download version artifact
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: version
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 13
|
||||
- name: Configure Yarn version
|
||||
run: |
|
||||
yarn config set version-tag-prefix ""
|
||||
yarn config set version-git-message "Release version %s"
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git switch -c $GITHUB_REF
|
||||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
git config user.name "$GITHUB_ACTOR"
|
||||
- name: Install dependencies
|
||||
run: yarn install
|
||||
- name: Prepare version
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
run: |
|
||||
yarn version --non-interactive --new-version $(cat version/version.txt)
|
||||
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY"
|
||||
git push --tags "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY"
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- name: Publish to NPM
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
run: |
|
||||
echo "Going to publish version $(cat version/version.txt) to NPM"
|
||||
yarn publish --tag latest --non-interactive --new-version $(cat version/version.txt)
|
||||
# - uses: actions/setup-node@v1
|
||||
# with:
|
||||
# node-version: 13
|
||||
# registry-url: https://npm.pkg.github.com
|
||||
# scope: "@rtfpessoa"
|
||||
# - name: Publish to GitHub
|
||||
# env:
|
||||
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
# run: |
|
||||
# echo "Going to publish version $(cat version/version.txt) to GitHub"
|
||||
# yarn publish --tag latest --non-interactive --new-version $(cat version/version.txt)
|
||||
|
|
@ -50,8 +50,7 @@
|
|||
"build-website": "rm -rf docs; NODE_ENV=production WEBPACK_MINIMIZE=true webpack --mode production --config webpack.website.ts",
|
||||
"start-website": "WEBPACK_MINIFY=false NODE_ENV=dev webpack-dev-server --mode dev --config webpack.website.ts",
|
||||
"preversion": "yarn run build && yarn run lint && yarn test",
|
||||
"version": "git add -A package.json",
|
||||
"postversion": "git push && git push --tags"
|
||||
"version": "git add -A package.json"
|
||||
},
|
||||
"main": "./lib/diff2html.js",
|
||||
"dependencies": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue