Skip to content

Commit

Permalink
chore: update release
Browse files Browse the repository at this point in the history
  • Loading branch information
meabed committed Jan 18, 2023
1 parent 8bebffa commit 848f6d1
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 41 deletions.
32 changes: 9 additions & 23 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,21 @@
{
"extends": [
"config:base"
],
"extends": ["config:base"],
"branchPrefix": "renovate-",
"baseBranches": ["develop"],
"assigneesFromCodeOwners": true,
"packageRules": [
{
"matchPackagePatterns": [
"*"
],
"matchUpdateTypes": [
"minor",
"patch"
],
"matchPackagePatterns": ["*"],
"matchUpdateTypes": ["minor", "patch"],
"groupName": "all non-major dependencies",
"groupSlug": "all-minor-patch",
"automerge": true,
"labels": [
"dependencies"
]
"labels": ["dependencies"]
},
{
"matchPackagePatterns": [
"*"
],
"matchUpdateTypes": [
"major"
],
"labels": [
"dependencies",
"breaking"
]
"matchPackagePatterns": ["*"],
"matchUpdateTypes": ["major"],
"labels": ["dependencies", "breaking"]
}
]
}
42 changes: 31 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,60 @@
name: ci
name: CI
on:
workflow_dispatch:
workflow_call:
push:
paths:
- 'src/**'
- 'test/**'
- '__tests__/**'
- 'package.json'
- 'yarn.lock'
- 'release.config.js'
- '.github/workflows/ci.yml'
branches:
- '*'
- '**'
- '!master'

env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI: true

jobs:
build:
runs-on: ubuntu-18.04
CI:
runs-on: ubuntu-latest
timeout-minutes: 20

permissions:
packages: write
contents: write

steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- uses: styfle/[email protected]
with:
workflow_id: build-docker.yml
workflow_id: ci.yml
access_token: ${{ github.token }}

- uses: actions/checkout@v3
with:
fetch-depth: 30
persist-credentials: false

- uses: bahmutov/npm-install@v1

- name: Yarn install
uses: bahmutov/npm-install@v1
- uses: FranzDiebold/github-env-vars-action@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
install-command: yarn --frozen-lockfile --silent
node-version: 19

- name: Yarn
run: yarn install --frozen-lockfile

- name: Test
run: |
yarn test
- name: Release
if: github.ref == 'refs/heads/develop'
run: |
npm i -g semantic-release @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits
npx semantic-release --no-ci --debug
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release
on:
workflow_dispatch:
workflow_call:
push:
paths:
- 'src/**'
- 'yarn.lock'
branches:
- 'master'

env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI: true

jobs:
Release:
runs-on: ubuntu-latest
timeout-minutes: 20

permissions:
packages: write
contents: write

steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- uses: styfle/[email protected]
with:
workflow_id: release.yml
access_token: ${{ github.token }}

- uses: actions/checkout@v3
with:
fetch-depth: 30

- uses: FranzDiebold/github-env-vars-action@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 19

- name: Yarn
run: yarn install --frozen-lockfile

- name: Test
run: |
yarn test
- name: Release
run: |
npm i -g semantic-release @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits
npx semantic-release --no-ci --debug
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
recursive: false,
reporter: 'spec',
require: ['ts-node/register', 'should'],
spec: ['./test/*-test.ts'],
spec: ['./__tests__/*-test.ts'],
timeout: '8s',
'trace-warnings': true,
};
6 changes: 3 additions & 3 deletions test/currency-test.ts → __tests__/currency-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ describe('currency', async function () {
expect(data.from).to.be.eql('USD');
expect(data.to).to.be.eql('EUR');

expect(data.convertedAmount).to.be.lessThan(9);
expect(data.convertedAmount).to.be.greaterThanOrEqual(9);
expect(data.convertedAmount).to.be.greaterThan(8);

expect(data.exchangeRate).to.be.lessThan(0.9);
expect(data.exchangeRate).to.be.greaterThanOrEqual(0.9);
expect(data.exchangeRate).to.be.greaterThan(0.8);

expect(data.originalAmount).to.be.eql(10);

expect(data.convertedText.startsWith('10 USD equal to')).to.be.eql(true);
expect(data.rateTime.startsWith('2022-')).to.be.eql(true);
expect(data.rateTime.startsWith('2023-')).to.be.eql(true);

// expect(result).to.be.eql({
// convertedAmount: 8.819,
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"typings": "./index.d.ts",
"scripts": {
"build": "rm -rf dist && tsc -p .",
"lint": "eslint src test",
"lint": "eslint src __tests__",
"lint-fix": "yarn lint -- --fix",
"prepare": "yarn husky install",
"prettier": "prettier --write \"src/**/*.{ts,json}\" \"test/**/*.{ts,json}\"",
"prettier": "prettier --write \"src/**/*.{ts,json}\" \"__tests__/**/*.{ts,json}\"",
"test": "TS_NODE_TRANSPILE_ONLY=1 TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha",
"test-ci": "TS_NODE_TRANSPILE_ONLY=1 TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha"
},
Expand Down
75 changes: 75 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// https://semantic-release.gitbook.io/semantic-release/usage/configuration
const pkg = require('./package.json');
const branch = process.env.BRANCH || process.env.CI_REF_NAME || '';
const branchSlug = branch.replace(/\//g, '-');
const branchPrefix = branch.split('/')[0];

const isMaster = branch === 'master' || branch === 'main';
// semantic-release configuration
module.exports = {
branches: [
{
name: 'master',
prerelease: false,
},
{
name: 'main',
prerelease: false,
},
{
name: 'next',
prerelease: 'next',
},
{
name: 'develop',
prerelease: 'beta',
},
{ name: branchSlug, prerelease: 'alpha' },
{ name: `${branchPrefix}/**`, prerelease: 'alpha' },
],
plugins: [
[
'@semantic-release/commit-analyzer',
{
preset: 'angular',
releaseRules: [
{ type: 'breaking', release: 'major' },
{ type: 'feat', release: 'minor' },
{ type: 'fix', release: 'patch' },
{ type: 'revert', release: 'patch' },
{ type: 'docs', release: 'patch' },
{ type: 'refactor', release: 'patch' },
{ type: 'style', release: 'patch' },
{ type: 'test', release: 'patch' },
{ type: 'chore', release: 'patch' },
{ type: 'ci', release: 'patch' },
{ type: 'perf', release: 'patch' },
{ type: 'build', release: 'patch' },
],
},
],
['@semantic-release/release-notes-generator'],
// https://github.com/semantic-release/npm
['@semantic-release/npm'],
// https://github.com/semantic-release/github
[
'@semantic-release/github',
{
successComment: false,
failComment: false,
},
],
// https://github.com/semantic-release/git
isMaster && [
'@semantic-release/git',
{
assets: ['package.json', 'package-lock.json', 'yarn.lock', 'npm-shrinkwrap.json', 'CHANGELOG.md'],
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
GIT_AUTHOR_NAME: pkg.author.name,
GIT_AUTHOR_EMAIL: pkg.author.email,
GIT_COMMITTER_NAME: pkg.author.name,
GIT_COMMITTER_EMAIL: pkg.author.email,
},
],
].filter(Boolean),
};
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"exclude": [
"dist",
"test",
"__tests__",
"node_modules"
]
}

0 comments on commit 848f6d1

Please sign in to comment.