Skip to content

Commit

Permalink
issue #47: add script
Browse files Browse the repository at this point in the history
  • Loading branch information
vivalareda committed Dec 11, 2023
1 parent e94543b commit 49684b9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/vercel-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@ on:
push:

env:
TYPESCRIPT_VERSION: 0.2.0
TYPESCRIPT_VERSION: 0.1.1
FILE_PATH: "src/_version.ts"

jobs:
find-version:
extract-version:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Find String
uses: nguyenvanuyn96/str-find-action@master
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v2
with:
find: "version: ${{ env.TYPESCRIPT_VERSION }}"
include: "${{ env.FILE_PATH }}"
node-version: '18'

- name: Extract Version
id: extract_version
run: node ./scripts/extract-version.js

- name: Check Version
run: |
if [ "${{ steps.extract_version.outputs.version }}" != "${{ env.TYPESCRIPT_VERSION }}" ]; then
echo "You should be using typescript version ${EXPECTED_VERSION} instead of ${{ steps.extract_version.outputs.version }} ";
exit 1;
fi
18 changes: 18 additions & 0 deletions scripts/extract-typescript-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const fs = require('fs');

const filePath = 'src/_version.ts';

fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading the file:', err);
return;
}

const versionMatch = data.match(/version: '([^']+)'/);
if (versionMatch && versionMatch[1]) {
console.log("Extracted Version:", versionMatch[1]);
process.stdout.write(`::set-output name=version::${versionMatch[1]}`);
} else {
console.error('Version could not be extracted');
}
});

0 comments on commit 49684b9

Please sign in to comment.