feature: Use GitHub workflows :breaking:
This commit is contained in:
parent
a4c43bd6ae
commit
3da01dda79
6 changed files with 236 additions and 96 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
|
||||
50
.github/workflows/ci.yml
vendored
Normal file
50
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
name: CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-18.04
|
||||
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 }}
|
||||
- name: Log environment setup
|
||||
run: |
|
||||
node -v
|
||||
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: Lint
|
||||
run: yarn run lint
|
||||
- name: Build
|
||||
run: yarn run build
|
||||
- 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
|
||||
118
.github/workflows/release.yml
vendored
Normal file
118
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
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
|
||||
run: |
|
||||
# Hack: Set a unique fake name for the release branch to avoid releasing master as the new 3.x major release for now
|
||||
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=FAKE-RELEASE-BRANCH-NAME)"
|
||||
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
|
||||
- name: Get next npm tag name
|
||||
run: |
|
||||
if [ "${GITHUB_REF#refs/heads/}" = "master" ]; then
|
||||
export PUBLISH_TAG="latest"
|
||||
elif [ "${GITHUB_REF#refs/heads/}" = "next" ]; then
|
||||
export PUBLISH_TAG="next"
|
||||
else
|
||||
export PUBLISH_TAG="pr"
|
||||
fi
|
||||
echo "Next tag is ${PUBLISH_TAG}"
|
||||
echo "${PUBLISH_TAG}" > tag.txt
|
||||
- name: Save npm tag name artifact
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: tag
|
||||
path: tag.txt
|
||||
|
||||
publish:
|
||||
needs: [version, 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
|
||||
- name: Download npm tag name artifact
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: tag
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 13.x
|
||||
- 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: 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#refs/heads/}
|
||||
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 --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 $(cat tag/tag.txt) --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: |
|
||||
# HACK: Override npm package name to be able to publish in GitHub
|
||||
(TMP_FILE=$(mktemp) && jq '.name = "@rtfpessoa/diff2html"' package.json > "${TMP_FILE}" && mv "${TMP_FILE}" package.json)
|
||||
echo "Going to publish version $(cat version/version.txt) to GitHub"
|
||||
yarn publish --tag $(cat tag/tag.txt) --non-interactive --new-version $(cat version/version.txt)
|
||||
# HACK: Restore npm package name
|
||||
(TMP_FILE=$(mktemp) && jq '.name = "diff2html"' package.json > "${TMP_FILE}" && mv "${TMP_FILE}" package.json)
|
||||
63
.github/workflows/website.yml
vendored
Normal file
63
.github/workflows/website.yml
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
name: Website
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-18.04
|
||||
env:
|
||||
CI: true
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [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: Lint
|
||||
run: yarn run lint
|
||||
- name: Build
|
||||
run: yarn run build
|
||||
- name: Test
|
||||
run: yarn run coverage
|
||||
- name: Save website artifact
|
||||
if: matrix.node-version == '13.x'
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: website
|
||||
path: docs
|
||||
|
||||
deploy:
|
||||
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
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[](https://www.codacy.com/app/rtfpessoa/diff2html?utm_source=github.com&utm_medium=referral&utm_content=rtfpessoa/diff2html&utm_campaign=Badge_Grade)
|
||||
[](https://www.codacy.com/app/rtfpessoa/diff2html?utm_source=github.com&utm_medium=referral&utm_content=rtfpessoa/diff2html&utm_campaign=Badge_Coverage)
|
||||
[](https://circleci.com/gh/rtfpessoa/diff2html)
|
||||

|
||||
|
||||
[](https://www.npmjs.com/package/diff2html)
|
||||
[](https://david-dm.org/rtfpessoa/diff2html)
|
||||
|
|
|
|||
|
|
@ -49,11 +49,12 @@
|
|||
"build-templates": "ts-node ./scripts/hulk.ts --wrapper ts --variable 'defaultTemplates' ./src/templates/*.mustache > ./src/diff2html-templates.ts",
|
||||
"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"
|
||||
"preversion": "yarn run lint && yarn run build && yarn test",
|
||||
"version": "git add -A package.json"
|
||||
},
|
||||
"main": "./lib/diff2html.js",
|
||||
"module": "./lib-esm/diff2html.js",
|
||||
"types": "./lib/diff2html.d.ts",
|
||||
"dependencies": {
|
||||
"diff": "4.0.1",
|
||||
"hogan.js": "3.0.2"
|
||||
|
|
|
|||
Loading…
Reference in a new issue