Skip to content

Commit 0986ee1

Browse files
David Barbetdibarbet
authored andcommitted
Update branch snap to also incrememnt version.json
1 parent 051cd12 commit 0986ee1

File tree

4 files changed

+49
-16
lines changed

4 files changed

+49
-16
lines changed

.github/workflows/branch-snap.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,21 @@ jobs:
1313
configuration_file_path: '.config/snap-flow.json'
1414

1515
create-pull-request:
16-
if: github.ref == 'refs/heads/testing_action'
16+
if: github.ref == 'refs/heads/main'
17+
runs-on: ubuntu-latest
1718
steps:
1819
- name: Check out
1920
uses: actions/checkout@v2
21+
- name: Install NodeJS
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '18.x'
25+
- name: Update version.json
26+
run: npx gulp incrementVersionJson
2027
- name: Create version.json update PR
2128
uses: peter-evans/create-pull-request@v4
2229
with:
2330
token: ${{ secrets.GITHUB_TOKEN }}
2431
commit-message: Update main version
2532
title: 'Update main version'
2633
branch: merge/update-main-version
27-
# awk '/"version":/{split($2,a,/[.]/);$1=" \"version\":";$2=a[1]"."a[2]+1"$3"};1' version.json

gulpfile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ require('./tasks/backcompatTasks');
99
require('./tasks/localizationTasks');
1010
require('./tasks/createTagsTasks');
1111
require('./tasks/debuggerTasks');
12+
require('./tasks/snapTasks');

tasks/snapTasks.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as gulp from 'gulp';
7+
import * as fs from 'fs';
8+
import * as path from 'path';
9+
10+
gulp.task('incrementVersionJson', async (): Promise<void> => {
11+
let versionFilePath = path.join(path.resolve(__dirname, '..'), 'version.json');
12+
let file = fs.readFileSync(versionFilePath, 'utf8');
13+
let versionJson = JSON.parse(file);
14+
15+
let version = versionJson.version as string;
16+
let split = version.split('.');
17+
let newVersion = `${split[0]}.${parseInt(split[1]) + 1}`;
18+
19+
console.log(`Updating ${version} to ${newVersion}`);
20+
21+
versionJson.version = newVersion;
22+
let newJson = JSON.stringify(versionJson, null, 4);
23+
console.log(`New json: ${newJson}`);
24+
25+
fs.writeFileSync(versionFilePath, newJson);
26+
});

version.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "2.39",
4-
"publicReleaseRefSpec": [
5-
"^refs/heads/release$",
6-
"^refs/heads/prerelease$",
7-
"^refs/heads/main$",
8-
"^refs/heads/patch/.*$"
9-
],
10-
"cloudBuild": {
11-
"buildNumber": {
12-
"enabled": false
13-
}
14-
}
15-
}
2+
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3+
"version": "2.40",
4+
"publicReleaseRefSpec": [
5+
"^refs/heads/release$",
6+
"^refs/heads/prerelease$",
7+
"^refs/heads/main$",
8+
"^refs/heads/patch/.*$"
9+
],
10+
"cloudBuild": {
11+
"buildNumber": {
12+
"enabled": false
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)