Skip to content

Commit

Permalink
use a node script instead of sed, so it is cross platform (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrehault authored Apr 4, 2024
1 parent f8f1afd commit 82aeea9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ jobs:

- name: Set version in source
run: |-
sed -i "s#99999\.99999\.99999#${{ env.PACKAGE_VERSION }}#" electron-app/src/index.ts
sed -i "4s/0\.0\.0/${{ env.PACKAGE_VERSION }}/" electron-app/package.json
node utils/set-version.js electron-app/package.json ${{ env.PACKAGE_VERSION }}
node utils/set-version.js electron-app/src/index.ts ${{ env.PACKAGE_VERSION }}
- name: install dependencies electron-app
run: npm install
Expand Down Expand Up @@ -163,11 +163,6 @@ jobs:
- name: Get package version
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV

- name: Set version in source
run: |-
sed -i "s#99999\.99999\.99999#${{ env.PACKAGE_VERSION }}#" electron-app/src/index.ts
sed -i "4s/0\.0\.0/${{ env.PACKAGE_VERSION }}/" electron-app/package.json
- name: install dependencies electron-app
run: npm install
working-directory: electron-app
Expand All @@ -176,6 +171,11 @@ jobs:
run: npm install
working-directory: server

- name: Set version in source
run: |-
node utils/set-version.js electron-app/package.json ${{ env.PACKAGE_VERSION }}
node utils/set-version.js electron-app/src/index.ts ${{ env.PACKAGE_VERSION }}
- name: compile server
env:
CI: false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuclia-sync-agent-app",
"version": "1.2.10",
"version": "1.2.11",
"description": "This is a Nuclia Sync Agent App",
"main": "build/index.js",
"scripts": {
Expand Down
13 changes: 13 additions & 0 deletions utils/set-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require('fs');
function replaceStringInFile(filePath, version) {
const content = fs.readFileSync(filePath, 'utf8');
const version0 = /"version": "0\.0\.0"/;
const firstPass = content.replace(version0, `"version": "${version}"`);
const version9 = /99999\.99999\.99999/;
const secondPass = firstPass.replace(version9, version);
fs.writeFileSync(filePath, secondPass, 'utf8');
}

const filePath = process.argv[2];
const version = process.argv[3];
replaceStringInFile(filePath, version);

0 comments on commit 82aeea9

Please sign in to comment.