Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 71 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
node-version: 24

- name: Yarn
run: yarn install --frozen-lockfile
Expand All @@ -56,10 +56,79 @@ jobs:
yarn preparemetadata
yarn test

- name: Build
run: yarn build

- name: Release
id: semantic_release
if: github.ref == 'refs/heads/develop'
run: |
git config --global user.email "support@dev.me"
git config --global user.name "DEV.ME Team"
npm i -g semantic-release @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits
npx semantic-release --no-ci --debug
npx semantic-release --no-ci --debug 2>&1 | tee release-output.txt

# Extract version and tag info from release output
if grep -q "Published release" release-output.txt; then
echo "release_published=true" >> $GITHUB_OUTPUT
VERSION=$(grep -oP 'Published release \K[0-9]+\.[0-9]+\.[0-9]+' release-output.txt | head -1)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
else
echo "release_published=false" >> $GITHUB_OUTPUT
fi

- name: Add CI Summary
if: always()
run: |
echo "## πŸ”¬ CI Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

# Check if release step was run (only on develop branch)
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
if [[ "${{ steps.semantic_release.outputs.release_published }}" == "true" ]]; then
echo "### βœ… Pre-release Published Successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** \`${{ steps.semantic_release.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Tag:** \`${{ steps.semantic_release.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### πŸ”— Links" >> $GITHUB_STEP_SUMMARY
echo "- [NPM Package](https://www.npmjs.com/package/@devmehq/email-validator-js/v/${{ steps.semantic_release.outputs.version }})" >> $GITHUB_STEP_SUMMARY
echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.semantic_release.outputs.tag }})" >> $GITHUB_STEP_SUMMARY
else
echo "### ℹ️ No Pre-release Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "No pre-release was created. This could be because:" >> $GITHUB_STEP_SUMMARY
echo "- No relevant commits found for release" >> $GITHUB_STEP_SUMMARY
echo "- Commits don't follow conventional commit format" >> $GITHUB_STEP_SUMMARY
echo "- Release conditions not met" >> $GITHUB_STEP_SUMMARY
fi
else
echo "### βœ… CI Tests Passed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "All tests completed successfully on branch \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "ℹ️ **Note:** Releases are only created from the \`develop\` branch" >> $GITHUB_STEP_SUMMARY
fi

echo "" >> $GITHUB_STEP_SUMMARY
echo "### πŸ“Š Build Information" >> $GITHUB_STEP_SUMMARY
echo "- **Workflow:** \`${{ github.workflow }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Run ID:** \`${{ github.run_id }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Run Number:** \`${{ github.run_number }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Actor:** \`${{ github.actor }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Event:** \`${{ github.event_name }}\`" >> $GITHUB_STEP_SUMMARY

# Add PR information if available
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "### πŸ”€ Pull Request Information" >> $GITHUB_STEP_SUMMARY
echo "- **PR Number:** #${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY
echo "- **PR Title:** ${{ github.event.pull_request.title }}" >> $GITHUB_STEP_SUMMARY
echo "- **Base Branch:** \`${{ github.event.pull_request.base.ref }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Head Branch:** \`${{ github.event.pull_request.head.ref }}\`" >> $GITHUB_STEP_SUMMARY
fi
52 changes: 50 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
node-version: 24

- name: Yarn
run: yarn install --frozen-lockfile
Expand All @@ -49,9 +49,57 @@ jobs:
yarn preparemetadata
yarn test

- name: Build
run: yarn build

- name: Release
id: semantic_release
run: |
git config --global user.email "support@dev.me"
git config --global user.name "DEV.ME Team"
npm i -g semantic-release @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits
npx semantic-release --no-ci --debug
npx semantic-release --no-ci --debug 2>&1 | tee release-output.txt

# Extract version and tag info from release output
if grep -q "Published release" release-output.txt; then
echo "release_published=true" >> $GITHUB_OUTPUT
VERSION=$(grep -oP 'Published release \K[0-9]+\.[0-9]+\.[0-9]+' release-output.txt | head -1)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
else
echo "release_published=false" >> $GITHUB_OUTPUT
fi

- name: Add Release Summary
if: always()
run: |
echo "## πŸ“¦ Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if [[ "${{ steps.semantic_release.outputs.release_published }}" == "true" ]]; then
echo "### βœ… Release Published Successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** \`${{ steps.semantic_release.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Tag:** \`${{ steps.semantic_release.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### πŸ”— Links" >> $GITHUB_STEP_SUMMARY
echo "- [NPM Package](https://www.npmjs.com/package/@devmehq/email-validator-js/v/${{ steps.semantic_release.outputs.version }})" >> $GITHUB_STEP_SUMMARY
echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.semantic_release.outputs.tag }})" >> $GITHUB_STEP_SUMMARY
else
echo "### ℹ️ No Release Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "No release was created. This could be because:" >> $GITHUB_STEP_SUMMARY
echo "- No relevant commits found for release" >> $GITHUB_STEP_SUMMARY
echo "- Commits don't follow conventional commit format" >> $GITHUB_STEP_SUMMARY
echo "- Release conditions not met" >> $GITHUB_STEP_SUMMARY
fi

echo "" >> $GITHUB_STEP_SUMMARY
echo "### πŸ“Š Build Information" >> $GITHUB_STEP_SUMMARY
echo "- **Workflow:** \`${{ github.workflow }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Run ID:** \`${{ github.run_id }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Run Number:** \`${{ github.run_number }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Actor:** \`${{ github.actor }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Event:** \`${{ github.event_name }}\`" >> $GITHUB_STEP_SUMMARY
4 changes: 0 additions & 4 deletions .prettierrc.yaml

This file was deleted.

30 changes: 7 additions & 23 deletions .scripts/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
* This script loads the geocoder and carrier data from the libphonenumber repository,
* creates bson files from them and autogenerated the types in src/locales.ts
*/
const {
readdirSync,
writeFileSync,
lstatSync,
createReadStream,
mkdirSync,
} = require('fs')
const { readdirSync, writeFileSync, lstatSync, createReadStream, mkdirSync } = require('fs')
const { join, basename } = require('path')
const { createInterface } = require('readline')
const { execSync } = require('child_process')
Expand All @@ -21,7 +15,7 @@ async function prepareLocale(localePath, locale, type) {
const files = readdirSync(localePath).filter((source) => fileRe.test(source))
const lineRe = /^([0-9]+)\|(.*)$/
for (let i = 0; i < files.length; ++i) {
let data = {}
const data = {}
const file = files[i]
const countryCode = basename(file, '.txt')
const ccRe = new RegExp(`^${countryCode}`)
Expand Down Expand Up @@ -49,9 +43,7 @@ async function prepareLocale(localePath, locale, type) {
}

async function preparePath(dataPath, type) {
const locales = readdirSync(dataPath).filter((source) =>
isDir(join(dataPath, source))
)
const locales = readdirSync(dataPath).filter((source) => isDir(join(dataPath, source)))
const promises = []
for (let i = 0; i < locales.length; ++i) {
const locale = locales[i]
Expand All @@ -65,11 +57,8 @@ async function preparePath(dataPath, type) {

async function prepareTimezones() {
const lineRe = /^([0-9]+)\|(.*)$/
let data = {}
const file = join(
__dirname,
'/../resources/libphonenumber/resources/timezones/map_data.txt'
)
const data = {}
const file = join(__dirname, '/../resources/libphonenumber/resources/timezones/map_data.txt')
const fileStream = createReadStream(file)
const rl = createInterface({
input: fileStream,
Expand All @@ -93,20 +82,15 @@ const prepare = async () => {
mkdirSync(join(__dirname, '/../resources/geocodes'), { recursive: true })
mkdirSync(join(__dirname, '/../resources/carrier'), { recursive: true })
execSync(
`cd ${join(
__dirname,
'/../resources'
)} && git clone https://github.com/google/libphonenumber`
`cd ${join(__dirname, '/../resources')} && git clone https://github.com/google/libphonenumber`
)
console.log('Preparing metadata...')
const dataBasePath = join(__dirname, '/../resources/libphonenumber/resources')
let generatedTypes = '/* THIS FILE IS AUTOGENERATED. */\n'

const geocodingPath = join(dataBasePath, 'geocoding')
const { locales: geoLocales } = await preparePath(geocodingPath, 'geocodes')
generatedTypes += `export type GeocoderLocale = ${geoLocales
.map((l) => `'${l}'`)
.join(' | ')};\n`
generatedTypes += `export type GeocoderLocale = ${geoLocales.map((l) => `'${l}'`).join(' | ')};\n`

const carrierPath = join(dataBasePath, 'carrier')
const { locales: carrierLocales } = await preparePath(carrierPath, 'carrier')
Expand Down
Loading