Skip to content

Commit

Permalink
Update branch snap to also incrememnt version.json
Browse files Browse the repository at this point in the history
  • Loading branch information
David Barbet authored and David Barbet committed Jul 15, 2024
1 parent 051cd12 commit 298a185
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 16 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/branch-snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@ jobs:
configuration_file_path: '.config/snap-flow.json'

create-pull-request:
if: github.ref == 'refs/heads/testing_action'
if: github.ref == 'refs/heads/action_inc_version'
steps:
- name: Check out
uses: actions/checkout@v2
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Install dependencies
run: |
npm ci
npm i -g gulp
- name: Update version.json
run: gulp incrementVersionJson
- name: Create version.json update PR
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update main version
title: 'Update main version'
branch: merge/update-main-version
# awk '/"version":/{split($2,a,/[.]/);$1=" \"version\":";$2=a[1]"."a[2]+1"$3"};1' version.json
1 change: 1 addition & 0 deletions gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ require('./tasks/backcompatTasks');
require('./tasks/localizationTasks');
require('./tasks/createTagsTasks');
require('./tasks/debuggerTasks');
require('./tasks/snapTasks');
26 changes: 26 additions & 0 deletions tasks/snapTasks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as gulp from 'gulp';
import * as fs from 'fs';
import * as path from 'path';

gulp.task('incrementVersionJson', async (): Promise<void> => {
let versionFilePath = path.join(path.resolve(__dirname, '..'), 'version.json');
let file = fs.readFileSync(versionFilePath, 'utf8');
let versionJson = JSON.parse(file);

let version = versionJson.version as string;
let split = version.split('.');
let newVersion = `${split[0]}.${parseInt(split[1]) + 1}`;

console.log(`Updating ${version} to ${newVersion}`);

versionJson.version = newVersion;
let newJson = JSON.stringify(versionJson, null, 4);
console.log(`New json: ${newJson}`);

fs.writeFileSync(versionFilePath, newJson);
});
28 changes: 14 additions & 14 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.39",
"publicReleaseRefSpec": [
"^refs/heads/release$",
"^refs/heads/prerelease$",
"^refs/heads/main$",
"^refs/heads/patch/.*$"
],
"cloudBuild": {
"buildNumber": {
"enabled": false
}
}
}
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.39",
"publicReleaseRefSpec": [
"^refs/heads/release$",
"^refs/heads/prerelease$",
"^refs/heads/main$",
"^refs/heads/patch/.*$"
],
"cloudBuild": {
"buildNumber": {
"enabled": false
}
}
}

0 comments on commit 298a185

Please sign in to comment.