Skip to content

Commit

Permalink
Core/auto update version env var (#1274)
Browse files Browse the repository at this point in the history
* break up env var

* add script

* export update core version func

* fix export

* test

* update func

* update func

* remove passing in global var and fix the func (checkout this commit to test the scripts)

* remove test comments

* apply review suggestions

* fix error

* Update scripts/update-version.js

Co-authored-by: Steven Murray <[email protected]>

* Revert "Update scripts/update-version.js"

This reverts commit bd720a8.

* Revert "apply review suggestions"

This reverts commit c55cec3.

Co-authored-by: Steven Murray <[email protected]>
  • Loading branch information
clairesunstudio and smurrayatwork authored Dec 2, 2020
1 parent 565bf08 commit 946ef7f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/core/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VERSION=@10.3.0
PKG=@massds/mayflower-assets
STORYBOOK_CDN=https://unpkg.com/
STORYBOOK_PKG=@massds/[email protected]
STORYBOOK_PKG=$PKG$VERSION
STORYBOOK_CDN_PATH=$STORYBOOK_CDN$STORYBOOK_PKG
7 changes: 4 additions & 3 deletions scripts/release-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const git = require('simple-git/promise')();

const { octokit } = require('./release-vars');
const { newLogsWithTitle, changelogs, version } = require('./compile-changelogs');
const updateCoreVersion = require('./update-version');

// Checkout the branch.
const releaseBranch = 'release/' + version;
Expand All @@ -18,17 +19,17 @@ const releaseBranch = 'release/' + version;
// This asynchronous logic will happen sequentially.
// If an error is thrown, it will break out of this
// asynchronous function immediately and exit 1.

// Create the release branch and push to Github.
shell.exec(`git branch -D ${releaseBranch}`)
updateCoreVersion(version)
await git.checkoutLocalBranch(releaseBranch)
await git.add('./*');
await git.commit('Changelog update and remove old changelog files');
await git.commit('Consolidate changelogs and update core version');
// Use a force-push so if we have an old version of the branch sitting around
// (eg: an unreleased one from last week), it gets updated regardless.
await git.push('origin', releaseBranch, {'--force': null});

// Create the pull request in GitHub
//Create the pull request in GitHub
await octokit.pulls.create({
owner: 'massgov',
repo: 'mayflower',
Expand Down
16 changes: 16 additions & 0 deletions scripts/update-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const path = require('path');
const fs = require('fs');

module.exports = function updateCoreVersion(newVer) {
const filePath = `${path.resolve(__dirname, '../packages/core')}/.env`;

const content = fs.readFileSync(filePath).toString();


const regex = /[0-9]+\.[0-9]+\.[0-9]+/g;
const newContent = content.replace(regex, newVer)

fs.writeFileSync(filePath, newContent, (err) => {
if (err) throw err;
})
}

0 comments on commit 946ef7f

Please sign in to comment.