Skip to content

Commit 2ca35f8

Browse files
authored
Merge pull request #7346 from dotnet/dev/dibarbet/action_inc_version
Update main version in branch snap github action
2 parents 12c2fc9 + 2c5c972 commit 2ca35f8

File tree

4 files changed

+63
-14
lines changed

4 files changed

+63
-14
lines changed

.github/workflows/branch-snap.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,26 @@ jobs:
1010
check-script:
1111
uses: dotnet/arcade/.github/workflows/inter-branch-merge-base.yml@main
1212
with:
13-
configuration_file_path: '.config/snap-flow.json'
13+
configuration_file_path: '.config/snap-flow.json'
14+
15+
create-pull-request:
16+
if: github.ref == 'refs/heads/main'
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check out
20+
uses: actions/checkout@v2
21+
- name: Install NodeJS
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '18.x'
25+
- name: Install dependencies
26+
run: npm ci
27+
- name: Update version.json
28+
run: npx gulp incrementVersionJson
29+
- name: Create version.json update PR
30+
uses: peter-evans/create-pull-request@v4
31+
with:
32+
token: ${{ secrets.GITHUB_TOKEN }}
33+
commit-message: Update main version
34+
title: 'Update main version'
35+
branch: merge/update-main-version

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+
const versionFilePath = path.join(path.resolve(__dirname, '..'), 'version.json');
12+
const file = fs.readFileSync(versionFilePath, 'utf8');
13+
const versionJson = JSON.parse(file);
14+
15+
const version = versionJson.version as string;
16+
const split = version.split('.');
17+
const newVersion = `${split[0]}.${parseInt(split[1]) + 1}`;
18+
19+
console.log(`Updating ${version} to ${newVersion}`);
20+
21+
versionJson.version = newVersion;
22+
const newJson = JSON.stringify(versionJson, null, 4);
23+
console.log(`New json: ${newJson}`);
24+
25+
fs.writeFileSync(versionFilePath, newJson);
26+
});

version.json

Lines changed: 13 additions & 13 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.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-
}
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+
}
1515
}

0 commit comments

Comments
 (0)