Skip to content

Commit

Permalink
feat(autoversion): iss 591/viv 349 version auto bump (#594)
Browse files Browse the repository at this point in the history
* issue #591: wip

* feat(autobump): version automation

* feat: testing stuff

* chore(release): 1.1.0

* chore(release): 1.0.5

* chore(release): 1.0.6

* issue #591: wip

* issue #591: added script to get suggestion

* issue #591: dry run

* issue #591: dry run

* issue #591: dry run

* issue #591: dry run

* issue #591: dry run

* issue #591: see logs

* issue #591: see logs

* issue #591: see logs

* issue #591: see logs

* issue #591: see logs

* issue #591: see logs

* issue #591: see logs

* issue #591: see logs

* issue #591: fixing remarks and adding doc

* issue #591: fixing remarks and adding doc
  • Loading branch information
gullerya authored Jan 20, 2021
1 parent d53e3bc commit 81e5875
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 28 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Prepare Vivid for release
on:
push:
tags:
- release-*
- release

jobs:
prepare-verify:
Expand All @@ -19,6 +19,9 @@ jobs:
ref: master
token: ${{ secrets.CI_AT }}

- name: Delete temporary trigger tag
run: git push origin --delete release

- name: Use Node.js 14
uses: actions/setup-node@v2
with:
Expand All @@ -27,29 +30,12 @@ jobs:
- name: Install yarn
run: npm install -g yarn

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- name: Cache yarn dependencies
uses: actions/cache@v2
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: vivid-cache-yarn-${{ hashFiles('**/package.json') }}

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install

# Update to a new version
- name: Extract release version
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF##*/release-})" >> $GITHUB_ENV

- name: Delete temporary trigger tag
run: git push origin --delete release-${{ env.RELEASE_VERSION }}
- name: Obtain release version
run: echo "RELEASE_VERSION=$(node ./scripts/suggest-bump.mjs)" >> $GITHUB_ENV

- name: Bump version to ${{ env.RELEASE_VERSION }}
run: |
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.0",
"concurrently": "^5.2.0",
"conventional-changelog-cli": "^2.0.34",
"conventional-changelog-cli": "^2.1.0",
"deepmerge": "^4.2.2",
"depcheck": "YonatanKra/depcheck#vivid-version",
"es-dev-server": "^1.50.8",
Expand Down Expand Up @@ -113,6 +113,7 @@
"semver-diff": "^3.1.1",
"showdown": "^1.9.1",
"spech": "^0.2.1",
"standard-version": "^9.1.0",
"tar-stream": "^2.1.4",
"tslib": "^2.0.3",
"typescript": "^4.1.3",
Expand Down Expand Up @@ -142,4 +143,4 @@
"engines": {
"node": ">=12.18.4"
}
}
}
45 changes: 45 additions & 0 deletions scripts/suggest-bump.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* CLI utility to suggest the next Vivid version based on conventional commits since last release (tag)
*
* - uses `standard-version` library as engine
* - uses `lerna.json` as base version
* - adheres to the semver versioning as per `standard-version`
* - result (next version) is printed to the stdout
*/
import fs from 'fs';
import standardVersion from 'standard-version';

// execution
//
main();

// definitions
//
async function main() {
const TMP_VERSION_HOLDER = 'autogenerated.version.json';
const CURRENT_VERSION_SOURCE = 'lerna.json';

try {
fs.writeFileSync(TMP_VERSION_HOLDER, JSON.stringify({}), { encoding: 'utf-8' });
await injectVersion(TMP_VERSION_HOLDER, CURRENT_VERSION_SOURCE);
const result = extractVersion(TMP_VERSION_HOLDER);
console.log(result);
} finally {
fs.unlinkSync(TMP_VERSION_HOLDER);
}
}

async function injectVersion(tmpTarget, verSource) {
return standardVersion({
bumpFiles: [{ filename: tmpTarget, type: 'json' }],
packageFiles: [{ filename: verSource, type: 'json' }],
dryRun: false,
silent: true,
skip: { changelog: true, commit: true, tag: true }
});
}

function extractVersion(tmpVersionHolder) {
const tmpVersionHolderRaw = fs.readFileSync(tmpVersionHolder, { encoding: 'utf-8' });
return JSON.parse(tmpVersionHolderRaw).version;
}
87 changes: 81 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6704,7 +6704,7 @@ conventional-changelog-atom@^2.0.8:
dependencies:
q "^1.5.1"

conventional-changelog-cli@^2.0.34:
conventional-changelog-cli@^2.1.0:
version "2.1.1"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/conventional-changelog-cli/-/conventional-changelog-cli-2.1.1.tgz#7a11980bc399938e0509d2adf8e7a0e213eb994e"
integrity sha1-ehGYC8OZk44FCdKt+Oeg4hPrmU4=
Expand All @@ -6722,7 +6722,12 @@ conventional-changelog-codemirror@^2.0.8:
dependencies:
q "^1.5.1"

conventional-changelog-conventionalcommits@^4.5.0:
[email protected]:
version "2.1.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/conventional-changelog-config-spec/-/conventional-changelog-config-spec-2.1.0.tgz#874a635287ef8b581fd8558532bf655d4fb59f2d"
integrity sha1-h0pjUofvi1gf2FWFMr9lXU+1ny0=

[email protected], conventional-changelog-conventionalcommits@^4.5.0:
version "4.5.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.5.0.tgz#a02e0b06d11d342fdc0f00c91d78265ed0bc0a62"
integrity sha1-oC4LBtEdNC/cDwDJHXgmXtC8CmI=
Expand Down Expand Up @@ -6828,7 +6833,7 @@ conventional-changelog-writer@^4.0.18, conventional-changelog-writer@^4.0.6:
split "^1.0.0"
through2 "^4.0.0"

conventional-changelog@^3.1.24:
conventional-changelog@3.1.24, conventional-changelog@^3.1.24:
version "3.1.24"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/conventional-changelog/-/conventional-changelog-3.1.24.tgz#ebd180b0fd1b2e1f0095c4b04fd088698348a464"
integrity sha1-69GAsP0bLh8AlcSwT9CIaYNIpGQ=
Expand Down Expand Up @@ -6866,6 +6871,20 @@ conventional-commits-parser@^3.0.3, conventional-commits-parser@^3.2.0:
through2 "^4.0.0"
trim-off-newlines "^1.0.0"

[email protected]:
version "6.0.11"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/conventional-recommended-bump/-/conventional-recommended-bump-6.0.11.tgz#fcc39acb51d1946b63fc478737d1e52712f36356"
integrity sha1-/MOay1HRlGtj/EeHN9HlJxLzY1Y=
dependencies:
concat-stream "^2.0.0"
conventional-changelog-preset-loader "^2.3.4"
conventional-commits-filter "^2.0.7"
conventional-commits-parser "^3.2.0"
git-raw-commits "2.0.0"
git-semver-tags "^4.1.1"
meow "^8.0.0"
q "^1.5.1"

conventional-recommended-bump@^5.0.0:
version "5.0.1"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/conventional-recommended-bump/-/conventional-recommended-bump-5.0.1.tgz#5af63903947b6e089e77767601cb592cabb106ba"
Expand Down Expand Up @@ -7466,11 +7485,21 @@ detect-indent@^5.0.0:
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d"
integrity sha1-OHHMCmoALow+Wzz38zYmRnXwa50=

detect-indent@^6.0.0:
version "6.0.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/detect-indent/-/detect-indent-6.0.0.tgz#0abd0f549f69fc6659a254fe96786186b6f528fd"
integrity sha1-Cr0PVJ9p/GZZolT+lnhhhrb1KP0=

detect-libc@^1.0.3:
version "1.0.3"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=

detect-newline@^3.1.0:
version "3.1.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
integrity sha1-V29d/GOuGhkv8ZLYrTr2MImRtlE=

[email protected]:
version "1.1.6"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/detect-port-alt/-/detect-port-alt-1.1.6.tgz#24707deabe932d4a3cf621302027c2b266568275"
Expand Down Expand Up @@ -7724,6 +7753,14 @@ dotenv@^8.0.0:
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha1-l+YZJZradQ7qPk6j4mvO6lQksWo=

dotgitignore@^2.1.0:
version "2.1.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/dotgitignore/-/dotgitignore-2.1.0.tgz#a4b15a4e4ef3cf383598aaf1dfa4a04bcc089b7b"
integrity sha1-pLFaTk7zzzg1mKrx36SgS8wIm3s=
dependencies:
find-up "^3.0.0"
minimatch "^3.0.4"

downshift@^6.0.6:
version "6.0.15"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/downshift/-/downshift-6.0.15.tgz#e00f5fc046cfb82a3fdf47166acd4087b51636b2"
Expand Down Expand Up @@ -8655,7 +8692,7 @@ figures@^2.0.0:
dependencies:
escape-string-regexp "^1.0.5"

figures@^3.0.0, figures@^3.2.0:
figures@^3.0.0, figures@^3.1.0, figures@^3.2.0:
version "3.2.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af"
integrity sha1-YlwYvSk8YE3EqN2y/r8MiDQXRq8=
Expand Down Expand Up @@ -8944,6 +8981,13 @@ from2@^2.1.0:
inherits "^2.0.1"
readable-stream "^2.0.0"

fs-access@^1.0.1:
version "1.0.1"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a"
integrity sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=
dependencies:
null-check "^1.0.0"

fs-constants@^1.0.0:
version "1.0.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad"
Expand Down Expand Up @@ -9222,7 +9266,7 @@ git-semver-tags@^2.0.3:
meow "^4.0.0"
semver "^6.0.0"

git-semver-tags@^4.1.1:
git-semver-tags@^4.0.0, git-semver-tags@^4.1.1:
version "4.1.1"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/git-semver-tags/-/git-semver-tags-4.1.1.tgz#63191bcd809b0ec3e151ba4751c16c444e5b5780"
integrity sha1-YxkbzYCbDsPhUbpHUcFsRE5bV4A=
Expand Down Expand Up @@ -12685,6 +12729,11 @@ nth-check@^1.0.2:
dependencies:
boolbase "~1.0.0"

null-check@^1.0.0:
version "1.0.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd"
integrity sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=

num2fraction@^1.2.2:
version "1.2.2"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede"
Expand Down Expand Up @@ -14959,7 +15008,7 @@ semver@^6.0.0, semver@^6.2.0, semver@^6.3.0:
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0=

semver@^7.2.1, semver@^7.3.2:
semver@^7.1.1, semver@^7.2.1, semver@^7.3.2:
version "7.3.4"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
integrity sha1-J6qn0uTKdkUvmNOt0JOnLJQ+3Jc=
Expand Down Expand Up @@ -15474,6 +15523,27 @@ stackframe@^1.1.1:
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/stackframe/-/stackframe-1.2.0.tgz#52429492d63c62eb989804c11552e3d22e779303"
integrity sha1-UkKUktY8YuuYmATBFVLj0i53kwM=

standard-version@^9.1.0:
version "9.1.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/standard-version/-/standard-version-9.1.0.tgz#07589469324d967ffe665fa86ef612949a858a80"
integrity sha1-B1iUaTJNln/+Zl+obvYSlJqFioA=
dependencies:
chalk "^2.4.2"
conventional-changelog "3.1.24"
conventional-changelog-config-spec "2.1.0"
conventional-changelog-conventionalcommits "4.5.0"
conventional-recommended-bump "6.0.11"
detect-indent "^6.0.0"
detect-newline "^3.1.0"
dotgitignore "^2.1.0"
figures "^3.1.0"
find-up "^5.0.0"
fs-access "^1.0.1"
git-semver-tags "^4.0.0"
semver "^7.1.1"
stringify-package "^1.0.1"
yargs "^15.3.1"

state-toggle@^1.0.0:
version "1.0.3"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/state-toggle/-/state-toggle-1.0.3.tgz#e123b16a88e143139b09c6852221bc9815917dfe"
Expand Down Expand Up @@ -15683,6 +15753,11 @@ stringify-object@^3.3.0:
is-obj "^1.0.1"
is-regexp "^1.0.0"

stringify-package@^1.0.1:
version "1.0.1"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/stringify-package/-/stringify-package-1.0.1.tgz#e5aa3643e7f74d0f28628b72f3dad5cecfc3ba85"
integrity sha1-5ao2Q+f3TQ8oYoty89rVzs/DuoU=

[email protected], strip-ansi@^6.0.0:
version "6.0.0"
resolved "https://vonagecc.jfrog.io/vonagecc/api/npm/npm/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
Expand Down

0 comments on commit 81e5875

Please sign in to comment.