Merge pull request #294 from rtfpessoa/revert-to-circleci
feature: Release in CircleCI
This commit is contained in:
commit
78f5c78ced
6 changed files with 212 additions and 237 deletions
210
.circleci/config.yml
Normal file
210
.circleci/config.yml
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
version: 2.1
|
||||
|
||||
jobs:
|
||||
checkout-and-version:
|
||||
docker:
|
||||
- image: codacy/git-version
|
||||
working_directory: ~/workdir
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Get next version
|
||||
command: |
|
||||
# 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
|
||||
- run:
|
||||
name: Get next npm tag name
|
||||
command: |
|
||||
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
|
||||
- persist_to_workspace:
|
||||
root: ~/workdir
|
||||
paths:
|
||||
- '*'
|
||||
|
||||
build-common: &common-build
|
||||
docker:
|
||||
- image: node
|
||||
working_directory: ~/workdir
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ~/workdir
|
||||
- restore_cache:
|
||||
key: yarn-cache-{{ checksum "yarn.lock" }}
|
||||
- run:
|
||||
name: Log environment setup
|
||||
command: |
|
||||
node -v
|
||||
yarn -v
|
||||
- run:
|
||||
name: Install dependencies
|
||||
command: yarn
|
||||
- save_cache:
|
||||
key: yarn-cache-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- /usr/local/share/.cache/yarn
|
||||
- run: yarn run validate
|
||||
- store_artifacts:
|
||||
path: coverage
|
||||
- store_test_results:
|
||||
path: coverage
|
||||
|
||||
build-latest: &latest-build
|
||||
docker:
|
||||
- image: node
|
||||
working_directory: ~/workdir
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ~/workdir
|
||||
- restore_cache:
|
||||
key: yarn-cache-{{ checksum "yarn.lock" }}
|
||||
- run:
|
||||
name: Log environment setup
|
||||
command: |
|
||||
node -v
|
||||
yarn -v
|
||||
- run:
|
||||
name: Install dependencies
|
||||
command: yarn
|
||||
- save_cache:
|
||||
key: yarn-cache-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- /usr/local/share/.cache/yarn
|
||||
- run: yarn run validate
|
||||
- store_artifacts:
|
||||
path: coverage
|
||||
- store_test_results:
|
||||
path: coverage
|
||||
- run: yarn run coverage:push
|
||||
- persist_to_workspace:
|
||||
root: ~/workdir
|
||||
paths:
|
||||
- '*'
|
||||
|
||||
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
|
||||
|
||||
publish_library:
|
||||
docker:
|
||||
- image: node:13
|
||||
working_directory: ~/workdir
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ~/workdir
|
||||
- run:
|
||||
name: Configure Yarn version
|
||||
command: |
|
||||
yarn config set version-tag-prefix ""
|
||||
yarn config set version-git-message "Release version %s"
|
||||
- run:
|
||||
name: Configure Git
|
||||
command: |
|
||||
git config user.email "circleci@users.noreply.github.com"
|
||||
git config user.name "CircleCI"
|
||||
- run:
|
||||
name: Version package
|
||||
command: |
|
||||
# Update version in packages to publish
|
||||
yarn version --non-interactive --new-version $(cat .version)
|
||||
- run:
|
||||
name: Setup npm credentials
|
||||
command: |
|
||||
rm -f .npmrc
|
||||
touch .npmrc
|
||||
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
|
||||
echo "registry=https://registry.npmjs.org/" >> .npmrc
|
||||
echo "access=public" >> .npmrc
|
||||
echo "save-exact=true" >> .npmrc
|
||||
- run:
|
||||
name: Publish npm package
|
||||
command: |
|
||||
# Publish package versions to npmjs.org
|
||||
yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
|
||||
- run:
|
||||
name: Setup gpr credentials
|
||||
command: |
|
||||
rm -f .npmrc
|
||||
touch .npmrc
|
||||
echo "//npm.pkg.github.com/:_authToken=${GPR_AUTH_TOKEN}" >> .npmrc
|
||||
echo "@rtfpessoa:registry=https://npm.pkg.github.com/" >> .npmrc
|
||||
echo "access=public" >> .npmrc
|
||||
echo "save-exact=true" >> .npmrc
|
||||
- run:
|
||||
name: Publish gpr package
|
||||
command: |
|
||||
# HACK: Override npm package name to be able to publish in GitHub
|
||||
sed -i 's/^ "name":.*/ "name": "@rtfpessoa\/diff2html",/g' package.json
|
||||
echo "Going to publish version $(cat .version) to GitHub"
|
||||
yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
|
||||
# HACK: Restore npm package name
|
||||
sed -i 's/^ "name":.*/ "name": "diff2html",/g' package.json
|
||||
|
||||
publish_website:
|
||||
machine:
|
||||
enabled: true
|
||||
working_directory: ~/workdir
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ~/workdir
|
||||
- run:
|
||||
name: Deploy
|
||||
working_directory: ~/workdir/docs
|
||||
command: |
|
||||
aws s3 sync --region eu-west-1 --delete . s3://diff2html.xyz --metadata-directive REPLACE --cache-control max-age=31557600
|
||||
aws cloudfront create-invalidation --region eu-west-1 --distribution-id $AWS_CF_DISTRIBUTION_ID --paths /index.html /demo.html /sitemap.xml /robots.txt
|
||||
|
||||
workflows:
|
||||
validate-and-publish:
|
||||
jobs:
|
||||
- checkout-and-version
|
||||
- build-node-10:
|
||||
requires:
|
||||
- checkout-and-version
|
||||
- build-node-11:
|
||||
requires:
|
||||
- checkout-and-version
|
||||
- build-node-12:
|
||||
requires:
|
||||
- checkout-and-version
|
||||
- build-node-13:
|
||||
requires:
|
||||
- checkout-and-version
|
||||
- publish_approval:
|
||||
type: approval
|
||||
requires:
|
||||
- build-node-10
|
||||
- build-node-11
|
||||
- build-node-12
|
||||
- build-node-13
|
||||
- publish_library:
|
||||
requires:
|
||||
- publish_approval
|
||||
- publish_website:
|
||||
requires:
|
||||
- publish_approval
|
||||
47
.github/workflows/ci.yml
vendored
47
.github/workflows/ci.yml
vendored
|
|
@ -1,47 +0,0 @@
|
|||
name: CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: contains(github.event.head_commit.message, '[skip ci]') == false
|
||||
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: Validate
|
||||
run: yarn run validate
|
||||
- name: Push coverage to Codacy
|
||||
if: matrix.node-version == '13.x'
|
||||
env:
|
||||
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||
run: yarn run coverage:push
|
||||
- name: Save coverage report
|
||||
if: matrix.node-version == '13.x'
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: coverage
|
||||
path: coverage
|
||||
122
.github/workflows/release.yml
vendored
122
.github/workflows/release.yml
vendored
|
|
@ -1,122 +0,0 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
version:
|
||||
if:
|
||||
github.event.pull_request.merged && contains(github.event.head_commit.message, '[skip ci]') == false &&
|
||||
contains(github.event.head_commit.message, '[skip release]') == false
|
||||
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]
|
||||
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
|
||||
- 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)
|
||||
66
.github/workflows/website.yml
vendored
66
.github/workflows/website.yml
vendored
|
|
@ -1,66 +0,0 @@
|
|||
name: Website
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if:
|
||||
github.event.pull_request.merged && contains(github.event.head_commit.message, '[skip ci]') == false &&
|
||||
contains(github.event.head_commit.message, '[skip release]') == false
|
||||
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
|
||||
- name: Build website
|
||||
run: |
|
||||
yarn run build:templates
|
||||
yarn run build:website
|
||||
- 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 website
|
||||
aws s3 sync --region eu-west-1 --delete . s3://diff2html.xyz --metadata-directive REPLACE --cache-control max-age=31557600
|
||||
aws cloudfront create-invalidation --region eu-west-1 --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths /index.html /demo.html /sitemap.xml /robots.txt
|
||||
|
|
@ -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://github.com/rtfpessoa/diff2html/actions?query=branch%3Amaster)
|
||||
[](https://circleci.com/gh/rtfpessoa/diff2html)
|
||||
|
||||
[](https://www.npmjs.com/package/diff2html)
|
||||
[](https://david-dm.org/rtfpessoa/diff2html)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ module.exports = {
|
|||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
coverageDirectory: './coverage',
|
||||
coverageReporters: ['lcov', 'text', 'html'],
|
||||
coverageReporters: ['lcov', 'text', 'html', 'json', 'cobertura', 'clover'],
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.ts',
|
||||
'!src/ui/**',
|
||||
|
|
|
|||
Loading…
Reference in a new issue