Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/main' into suan/update-java-buil…
Browse files Browse the repository at this point in the history
…dpack

Signed-off-by: Andrew Su <[email protected]>
  • Loading branch information
andrew-su committed May 16, 2022
2 parents 930671e + 977a61c commit 3169439
Show file tree
Hide file tree
Showing 33 changed files with 13,729 additions and 31 deletions.
34 changes: 34 additions & 0 deletions .github/actions/semver-bump/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SemVer Bump Action

This action reads a file for the semver version and increment it based on the release type.

## Inputs

### `path`
**Required** The path to the file containing the semantic version.

### `release-type`
**Required** The type of release. Acceptable values are: `major`, `minor`, `patch`

### `pre-release`
The pre-release label. This will still cause a bump to the appropriate semver component specified by `release-type`.

## Outputs

### `previous-version`
This is the version stored in the file at time of execution.

### `version`
This is the version we are moving to.

## Usage

You can now consume the action by referencing the v1 branch

```yaml
uses: ./.github/actions/semver-bump
with:
path: ./path/to/VERSION
release-type: patch
pre-release: my-pre-release-label
```
22 changes: 22 additions & 0 deletions .github/actions/semver-bump/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2021-2022 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause

name: 'Semver Bump'
description: 'Bump the designated semver component in a file.'
inputs:
path:
description: 'path to file containing semver to bump'
required: true
release-type:
description: 'semver component [major, minor, patch] to modify'
required: true
pre-release:
description: 'pre-release label'
outputs: # output will be available to future steps
previous-version:
description: 'The previous version'
version:
description: 'The current version'
runs:
using: 'node12'
main: 'dist/index.js'
45 changes: 45 additions & 0 deletions .github/actions/semver-bump/bump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2021-2022 VMware, Inc.
* SPDX-License-Identifier: BSD-2-Clause
*/

const semver = require("semver");

let isValidSemver = function (version) {
return new Promise((resolve)=>{
resolve(semver.valid(version) !== null)
})
}

let incMajor = function (version, preReleaseLabel) {
return new Promise((resolve) => {
let type = 'major'
if (preReleaseLabel) {
type = 'premajor'
}
resolve(semver.inc(version, type, preReleaseLabel))
})
}

let incMinor = function (version, preReleaseLabel) {
return new Promise((resolve) => {
let type = 'minor'
if (preReleaseLabel) {
type = 'preminor'
}
resolve(semver.inc(version, type, preReleaseLabel))
})
}

let incPatch = function (version, preReleaseLabel) {
return new Promise((resolve) => {
let type = 'patch'
if (preReleaseLabel) {
type = 'prepatch'
}
resolve(semver.inc(version, type, preReleaseLabel))
})
}


module.exports = {incMajor, incMinor, incPatch, isValidSemver};
Loading

0 comments on commit 3169439

Please sign in to comment.