Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .github/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ on:
pattern: '(?<=export const version = ").*(?=";)'
- kind: regexp
file: README.md
pattern: '(?<=semver-cli@).*(?=\/main.ts)'
- kind: regexp
file: README.md
pattern: "(?<=semver-cli@).*$"
- kind: regexp
file: Dockerfile
pattern: '(?<=VERSION=).*(?=; \\)'
pattern: "(?<=semver-cli@).*"
flags: g
- kind: regexp
file: setup/action.yml
pattern: "(?<=default: ).*"
- kind: regexp
file: action.yml
pattern: "(?<=default: ).*"
- kind: regexp
file: Dockerfile.action
pattern: "(?<=semver-cli:).*"
format: docker
10 changes: 9 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ jobs:
with:
deno-version: v2.x

- run: deno --version
# When we develop this internally we have to go through the repo1 mirror
# When we run it in GitHub its running outside of the optum network and cant access repo1
# Ideally these lock files wouldn't store the repository in it but just the sha of the module
# For now we have to remove the lock file in order to install the dependencies in the ci server
- name: Install Dependencies
run: |
rm deno.lock
deno install --no-lock

- run: deno fmt --check
- run: deno lint
- run: deno task test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ bin
obj
.vscode
deno.zip
node_modules
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ WORKDIR /app
ENV PATH="/app/bin:${PATH}"
RUN mkdir -p /app/bin

# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
# Ideally cache deps.ts will download and compile _all_ external files used in main.ts.
COPY deps/ /app/deps
# Cache the dependencies as a layer (the following two steps are re-run only when deno.json/deno.lock is modified).
# Install dependencies from npm and JSR registries instead of copying deps folder
COPY deno.json /app/
COPY deno.lock /app/
RUN deno cache --allow-import deps/mod.ts
RUN rm deno.lock && \
deno install

# These steps will be re-run upon any file change in your working directory:
ADD src /app/src
ADD main.ts /app

# Compile the main app so that it doesn't need to be compiled each startup/entry.
RUN deno cache main.ts
RUN deno compile --allow-run --allow-env --allow-read --allow-write -o bin/semver main.ts
ENTRYPOINT ["semver"]
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,10 @@ semver parse 1.0.0 # {"major":1,"minor":1,"patch":0,"prerelease":[],"build":[]}

When calling the command `inc` the `VERSION` file will be updated based on the
sub command specified, `major`, `minor`, `patch`, `none`. Additional metadata
may be added to the version using the `--pre` and `--build` parameters. If the
`--name` parameter is specified then that will be used instead of the default
`pre`. If the same prerelease name is used multiple times the prerelease number
will be incremented and it defaults to `0` if set initially or changed to a new
name. If the argument `--value` is set then the prerelease number will be
specifically set to the value provided.
may be added to the version using the `--prerelease` and `--build` parameters.

`none` can be used to synchronize new or out of sync files with post hooks, and
also it can be used in conjunction with `--pre` and `--build` without
also it can be used in conjunction with `--prerelease` and `--build` without
incrementing the main version numbers.

#### examples
Expand All @@ -119,14 +114,10 @@ semver inc major # 2.0.0

```sh
semver set 1.2.3-pre.0
semver inc --pre # 1.2.3-pre.1
semver inc --pre --value 10 # 1.2.3-pre.10
semver inc --pre --name alpha # 1.2.3-alpha.0
semver inc --prerelease alpha # 1.2.3-alpha.0
semver inc --prerelease alpha # 1.2.3-alpha.1
semver inc --build 1 # 1.2.3-alpha.1+1
semver inc --pre \
--name alpha \
--value 11 \
--build abc123 # 1.2.3-alpha.11+abc123
semver inc --prerelease beta # 1.2.3-beta.0+1
```

### Increment Post Hooks
Expand Down Expand Up @@ -197,7 +188,7 @@ jobs:
steps:
- if: inputs.pre
name: Increment Pre-Release Version
uses: optum/semver-cli@0.9.20
uses: optum/semver-cli@0.9.27
with:
action: inc
pre: true
Expand All @@ -207,7 +198,7 @@ jobs:

- id: version
name: Get Version
uses: optum/semver-cli@0.9.20
uses: optum/semver-cli@0.9.27

- run: echo "The calculated ${{ steps.version.outputs.version }}"
```
Expand Down
51 changes: 31 additions & 20 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,43 @@ branding:
icon: activity
color: orange
inputs:
action:
description: "A versioning action to perform (get|set|inc|parse)"
required: false
command:
type: choice
description: Command
default: get
required: false
options:
- get
- set
- inc
- parse
sub-command:
type: choice
description: "The kind of increment (major|minor|patch|none) for (get|inc) actions"
required: false
default: none
options:
- none
- major
- minor
- patch
pre:
type: boolean
description: "Whether or not to create a pre-release version (inc|get)"
name:
description: "If pre is set, you may optionally specify a prerelease name"
- none
prerelease:
type: string
description: Optional Prerelease Metadata
required: false
value:
description: "If pre is set, you may optionally specify a prerelease number"
build:
description: "Optional build metadata"
type: string
description: Optional Build Metadata
required: false
value:
type: string
description: The Version (for set action or parse action)
required: false
config:
type: string
description: "Path to a configuration file"
required: false
current:
description: "The version for the set command"
default: .github/version.yml

outputs:
version:
Expand All @@ -51,13 +63,12 @@ runs:
using: "docker"
image: "Dockerfile.action"
args:
- ${{ inputs.action || 'get' }}
- ${{ inputs.command }}
- ${{ inputs.pre && '--pre' || ''}}
- ${{ inputs.name && '--name' || '' }}
- ${{ inputs.name || '' }}
- ${{ inputs.value && '--value' || '' }}
- ${{ inputs.sub-command }}
- ${{ inputs.value || '' }}
- ${{ inputs.prerelease && '--prerelease' || '' }}
- ${{ inputs.prerelease || '' }}
- ${{ inputs.build && '--build' || '' }}
- ${{ inputs.build || '' }}
- ${{ inputs.current }}
- ${{ inputs.config && '--config' || '' }}
- ${{ inputs.config || '' }}
23 changes: 18 additions & 5 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
{
"nodeModulesDir": "auto",
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.14",
"json5": "npm:json5@^2.2.3",
"jsonc-parser": "npm:jsonc-parser@^3.2.1",
"semver": "jsr:@std/semver@^1.0.3",
"path": "jsr:@std/path@^1.0.6",
"assert": "jsr:@std/assert@^1.0.6",
"testing/bdd": "jsr:@std/testing@^1.0.3/bdd",
"testing/mock": "jsr:@std/testing@^1.0.3/mock",
"yaml": "jsr:@std/yaml@^1.0.5",
"yargs": "npm:yargs@^17.7.2"
},
"tasks": {
"check": "deno fmt && deno lint && deno task test",
"check": "deno fmt && deno lint && deno task test && deno run -A main.ts parse",
"install": "deno install --allow-run --allow-env --allow-read --allow-write -f main.ts -n semver",
"test": "deno test && deno task test:node && deno task test:helm && deno task test:maven && deno task test:dotnet",
"test:node": "(cd test/node && deno run -A ../../main.ts inc minor --pre --name alpha --build xyz.987)",
"test:helm": "(cd test/helm && deno run -A ../../main.ts inc minor --pre --name beta --build abc.123)",
"test:maven": "(cd test/maven && deno run -A ../../main.ts inc minor --pre --name omega --build def.456)",
"test:dotnet": "(cd test/dotnet && deno run -A ../../main.ts inc minor --pre --name lambda --build ghi.789)"
"test:node": "(cd test/node && deno run -A ../../main.ts inc minor --prerelease alpha --build xyz.987)",
"test:helm": "(cd test/helm && deno run -A ../../main.ts inc minor --prerelease beta --build abc.123)",
"test:maven": "(cd test/maven && deno run -A ../../main.ts inc minor --prerelease omega --build def.456)",
"test:dotnet": "(cd test/dotnet && deno run -A ../../main.ts inc minor --prerelease lambda --build ghi.789)"
}
}
Loading
Loading