Skip to content

Commit

Permalink
[CICD] Add releasing to npmjs (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechpavlu authored Apr 8, 2024
1 parent b72d130 commit ed3c780
Show file tree
Hide file tree
Showing 15 changed files with 297 additions and 107 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release

on:
# On push to master branch and only if the package.json has changed
push:
paths:
- package.json
branches:
- master

env:
NODE_VERSION: 20
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

jobs:
release:
name: Publish to NPM
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm install

- name: Run Unit tests
run: npm run test:unit

- name: Link from root project
run: npm link

- name: Install dependencies in nested project
run: npm install
working-directory: ./integration

- name: Link to nested project
run: npm link @falbricate/geography
working-directory: ./integration

- name: Run Integration tests
run: npm run test:integration

- name: Compile
run: npm run compile

- name: Build
run: npm run build

- name: Publish to NPM
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ env.NPM_AUTH_TOKEN }}
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ unit-test.config.js
tsconfig.json
tsup.config.ts
docs
integration
2 changes: 1 addition & 1 deletion integration/integration-tests.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
resetModules: true
resetModules: true,
};
9 changes: 6 additions & 3 deletions integration/tests/Plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { getStandard, getValueGenerator, registerPlugin } from '@falbricate/base';
import {
getStandard,
getValueGenerator,
registerPlugin,
} from '@falbricate/base';
import { GeographyPlugin } from '../../src';

describe('Not failing Plugin registration', () => {
Expand All @@ -10,7 +14,7 @@ describe('Not failing Plugin registration', () => {
describe('Registering contents', () => {
it('should register Random Country Generator', () => {
const config = {
countries: ['no', 'it']
countries: ['no', 'it'],
};

expect(() => getValueGenerator('random-country', config)).not.toThrow();
Expand All @@ -20,4 +24,3 @@ describe('Registering contents', () => {
expect(() => getStandard('country-abbr-eu')).not.toThrow();
});
});

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"name": "@falbricate/geography",
"version": "1.0.0",
"version": "1.0.1",
"description": "Geographical data plugin for Falbricate",
"repository": {
"type": "git",
"url": "https://github.com/vojtechpavlu/falbricate-geography.git"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/data/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type NamedGeography = {
type: GeographyType;
name: string;
abbr: string;
}
};

/** Declaration of regions and groups */
export interface Region extends NamedGeography {
Expand Down
11 changes: 8 additions & 3 deletions src/data/countries/european.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export const EUROPEAN_COUNTRIES: Country[] = [
{ type: 'country', abbr: 'az', name: 'Azerbaijan', capital: 'Baku' },
{ type: 'country', abbr: 'by', name: 'Belarus', capital: 'Minsk' },
{ type: 'country', abbr: 'be', name: 'Belgium', capital: 'Brussels' },
{ type: 'country', abbr: 'ba', name: 'Bosnia and Herzegovina', capital: 'Sarajevo' },
{
type: 'country',
abbr: 'ba',
name: 'Bosnia and Herzegovina',
capital: 'Sarajevo',
},
{ type: 'country', abbr: 'bg', name: 'Bulgaria', capital: 'Sofia' },
{ type: 'country', abbr: 'hr', name: 'Croatia', capital: 'Zagreb' },
{ type: 'country', abbr: 'cy', name: 'Cyprus', capital: 'Nicosia' },
Expand All @@ -28,7 +33,7 @@ export const EUROPEAN_COUNTRIES: Country[] = [
{ type: 'country', abbr: 'li', name: 'Liechtenstein', capital: 'Vaduz' },
{ type: 'country', abbr: 'lt', name: 'Lithuania', capital: 'Vilnius' },
{ type: 'country', abbr: 'lu', name: 'Luxembourg', capital: 'Luxembourg' },
{ type: 'country', abbr: 'mt', name: 'Malta', capital: 'St. Paul\'s Bay' },
{ type: 'country', abbr: 'mt', name: 'Malta', capital: "St. Paul's Bay" },
{ type: 'country', abbr: 'md', name: 'Moldova', capital: 'Chisinau' },
{ type: 'country', abbr: 'mc', name: 'Monaco', capital: 'Monaco' },
{ type: 'country', abbr: 'me', name: 'Montenegro', capital: 'Podgorica' },
Expand All @@ -49,5 +54,5 @@ export const EUROPEAN_COUNTRIES: Country[] = [
{ type: 'country', abbr: 'tr', name: 'Turkey', capital: 'Ankara' },
{ type: 'country', abbr: 'ua', name: 'Ukraine', capital: 'Kyiv' },
{ type: 'country', abbr: 'uk', name: 'United Kingdom', capital: 'London' },
{ type: 'country', abbr: 'va', name: 'Vatican', capital: 'Vatican City' }
{ type: 'country', abbr: 'va', name: 'Vatican', capital: 'Vatican City' },
];
157 changes: 115 additions & 42 deletions src/data/regions/european/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,95 +6,168 @@ export const EUROPEAN_REGIONS: Region[] = [
abbr: 'eu',
name: 'European Union',
subs: [
'at', 'be', 'bg', 'hr', 'cy', 'cz', 'dk', 'fi', 'ee', 'fr', 'de',
'gr', 'hu', 'ie', 'it', 'lv', 'lt', 'lu', 'mt', 'nl', 'pl', 'pt',
'ro', 'sk', 'si', 'es', 'se'
]
}, {
'at',
'be',
'bg',
'hr',
'cy',
'cz',
'dk',
'fi',
'ee',
'fr',
'de',
'gr',
'hu',
'ie',
'it',
'lv',
'lt',
'lu',
'mt',
'nl',
'pl',
'pt',
'ro',
'sk',
'si',
'es',
'se',
],
},
{
type: 'region',
abbr: 'not-eu',
name: 'European Countries not in EU',
subs: [
'al', 'ad', 'am', 'az', 'by', 'ba', 'ge', 'is', 'li', 'md', 'mc',
'me', 'mkd', 'no', 'ru', 'sm', 'rs', 'ch', 'tr', 'ua', 'uk', 'va'
]
}, {
'al',
'ad',
'am',
'az',
'by',
'ba',
'ge',
'is',
'li',
'md',
'mc',
'me',
'mkd',
'no',
'ru',
'sm',
'rs',
'ch',
'tr',
'ua',
'uk',
'va',
],
},
{
type: 'region',
abbr: 'europe',
name: 'Europe',
subs: ['eu', 'not-eu']
}, {
subs: ['eu', 'not-eu'],
},
{
type: 'region',
abbr: 'nordics',
name: 'Nordic countries',
subs: ['dk', 'fi', 'no', 'se', 'is']
}, {
subs: ['dk', 'fi', 'no', 'se', 'is'],
},
{
type: 'region',
abbr: 'baltics',
name: 'Baltic states',
subs: ['ee', 'lv', 'lt']
}, {
subs: ['ee', 'lv', 'lt'],
},
{
type: 'region',
abbr: 'v4',
name: 'Visegrád Group',
subs: ['cz', 'hu', 'pl', 'sk']
}, {
subs: ['cz', 'hu', 'pl', 'sk'],
},
{
type: 'region',
abbr: 'benelux',
name: 'Benelux',
subs: ['be', 'nl', 'lu']
}, {
subs: ['be', 'nl', 'lu'],
},
{
type: 'region',
abbr: 'iberia',
name: 'Iberian Penisula',
subs: ['es', 'pt']
}, {
subs: ['es', 'pt'],
},
{
type: 'region',
abbr: 'balkans',
name: 'Balkan Countries',
subs: ['al', 'ba', 'bg', 'hr', 'me', 'mkd', 'rs']
}, {
subs: ['al', 'ba', 'bg', 'hr', 'me', 'mkd', 'rs'],
},
{
type: 'region',
abbr: 'balkans-broad',
name: 'Broad Balkan Countries',
subs: ['balkans', 'gr', 'ro', 'si', 'tr']
}, {
subs: ['balkans', 'gr', 'ro', 'si', 'tr'],
},
{
type: 'region',
abbr: 'n-europe',
name: 'Northern Europe',
subs: ['dk', 'ee', 'fi', 'is', 'ie', 'lv', 'lt', 'no', 'se', 'uk']
}, {
subs: ['dk', 'ee', 'fi', 'is', 'ie', 'lv', 'lt', 'no', 'se', 'uk'],
},
{
type: 'region',
abbr: 's-europe',
name: 'Southwest Europe',
subs: [
'al', 'ad', 'ba', 'hr', 'gr', 'va', 'it', 'mt', 'me', 'pt', 'sm',
'rs', 'si', 'es', 'mkd'
]
}, {
'al',
'ad',
'ba',
'hr',
'gr',
'va',
'it',
'mt',
'me',
'pt',
'sm',
'rs',
'si',
'es',
'mkd',
],
},
{
type: 'region',
abbr: 'w-europe',
name: 'Western Europe',
subs: ['au', 'be', 'fr', 'de', 'li', 'lu', 'mc', 'nl', 'ch']
}, {
subs: ['au', 'be', 'fr', 'de', 'li', 'lu', 'mc', 'nl', 'ch'],
},
{
type: 'region',
abbr: 'e-europe',
name: 'Eastern Europe',
subs: ['bg', 'by', 'cz', 'hu', 'md', 'pl', 'ro', 'ru', 'sk', 'ua']
}, {
subs: ['bg', 'by', 'cz', 'hu', 'md', 'pl', 'ro', 'ru', 'sk', 'ua'],
},
{
type: 'region',
abbr: 'c-europe',
name: 'Central Europe',
subs: ['at', 'de', 'cz', 'sk', 'pl', 'hu']
}, {
subs: ['at', 'de', 'cz', 'sk', 'pl', 'hu'],
},
{
type: 'region',
abbr: 'sw-europe',
name: 'Southwest Europe',
subs: ['es', 'pt']
}, {
subs: ['es', 'pt'],
},
{
type: 'region',
abbr: 'se-europe',
name: 'Southeast Europe',
subs: ['balkans-broad', 'it']
}
];
subs: ['balkans-broad', 'it'],
},
];
Loading

0 comments on commit ed3c780

Please sign in to comment.