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
9 changes: 9 additions & 0 deletions .github/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ on:
- kind: regexp
file: README.md
pattern: '(?<=semver-cli@).*(?=\/main.ts)'
- kind: regexp
file: README.md
pattern: "(?<=semver-cli@).*$"
- kind: regexp
file: Dockerfile
pattern: '(?<=VERSION=).*(?=; \\)'
- kind: regexp
file: setup/action.yml
pattern: "(?<=default: ).*"
- kind: regexp
file: action.yml
pattern: "(?<=default: ).*"
- kind: regexp
file: Dockerfile.action
pattern: "(?<=semver-cli:).*"
35 changes: 33 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.parse_version.outputs.version }}
major: ${{ steps.parse_version.outputs.major }}
minor: ${{ steps.parse_version.outputs.minor }}
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
Expand All @@ -22,8 +24,10 @@ jobs:
- id: parse_version
name: Parse the Version
run: deno run -A main.ts parse

assets:
runs-on: ubuntu-latest
needs: version
permissions:
contents: write
strategy:
Expand All @@ -37,7 +41,6 @@ jobs:
extension: ""
- name: "aarch64-apple-darwin"
extension: ""
needs: version
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
Expand Down Expand Up @@ -115,5 +118,33 @@ jobs:
uses: docker/build-push-action@v4
with:
push: true
tags: optum/semver-cli:${{ needs.version.outputs.version }}
tags: latest,optum/semver-cli:${{ needs.version.outputs.version }},optum/semver-cli:v${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }},optum/semver-cli:v${{ needs.version.outputs.major }}
platforms: linux/amd64

tags:
runs-on: ubuntu-latest
needs:
- version
- assets
- docker
permissions:
contents: write
id-token: write
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
gh auth setup-git

- uses: actions/checkout@v4
- name: Create Tags
run: |
git tag "v${{ needs.version.outputs.version }}"
git tag "v${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}"
git tag "v${{ needs.version.outputs.major }}"
git push origin --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ LABEL maintainer="Justin Chase <justin.chase@optum.com>"
LABEL repository="https://github.com/optum/semver-cli"
LABEL homepage="https://github.com/optum/semver-cli"

# Label as GitHub action
LABEL com.github.actions.name="semver-cli"

# Limit to 160 characters
LABEL com.github.actions.description="Get, set and increment your project version"

# See branding:
# https://docs.github.com/actions/creating-actions/metadata-syntax-for-github-actions#branding
LABEL com.github.actions.icon="activity"
LABEL com.github.actions.color="orange"

WORKDIR /app
ENV PATH="/app/bin:${PATH}"
RUN mkdir -p /app/bin
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.action
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM optum/semver-cli:0.9.20
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,69 @@ on:
pattern: '^(?<=export const version = ").*(?=";)$'
```

## Actions

This repository has two actions available, either a basic setup action or a
single docker based action.

#### example

```yml
name: Publish
on:
workflow_dispatch:
inputs:
pre:
type: boolean
default: true
release:
types: [published]

jobs:
publish:
steps:
- if: inputs.pre
name: Increment Pre-Release Version
uses: optum/semver-cli@0.9.20
with:
action: inc
pre: true
name: pr
value: ${{ github.run_number }}
build: ${{ github.run_id }}

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

- run: echo "The calculated ${{ steps.version.outputs.version }}"
```

#### example of setup action

```yml
name: Publish
on:
release:
types: [published]

jobs:
publish:
steps:
- name: Increment Pre-Release Version
uses: optum/semver-cli/setup@0.9.20

- id: version
name: Parse Version
run: |
echo "version=$(semver parse | jq -r '.version')" > $GITHUB_OUTPUT
echo "major=$(semver parse | jq -r '.major')" > $GITHUB_OUTPUT
echo "minor=$(semver parse | jq -r '.minor')" > $GITHUB_OUTPUT
echo "patch=$(semver parse | jq -r '.patch')" > $GITHUB_OUTPUT

- run: echo "The calculated ${{ steps.version.outputs.version }}"
```

# Contributing

Contributions are what make the open source community such an amazing place to
Expand Down
63 changes: 63 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "semver-cli"
description: "Semver utility action"
branding:
icon: activity
color: orange
inputs:
action:
description: "A versioning action to perform (get|set|inc|parse)"
required: false
command:
type: choice
description: "The kind of increment (major|minor|patch|none) for (get|inc) actions"
required: false
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"
required: false
value:
description: "If pre is set, you may optionally specify a prerelease number"
build:
description: "Optional build metadata"
required: false
current:
description: "The version for the set command"

outputs:
version:
description: "The resulting version change"
version_docker:
description: "The resulting version change formatted to be compatible with docker tags"
version_dotnet:
description: "The resulting version change formatted to be compatible with dotnet"
major:
description: "If parsing, the major version"
minor:
description: "If parsing, the minor version"
patch:
description: "If parsing, the patch version"
prerelease:
description: "If parsing, the prerelease version"
build:
description: "If parsing, the build version"
runs:
using: "docker"
image: "Dockerfile.action"
args:
- ${{ inputs.action || 'get' }}
- ${{ inputs.command }}
- ${{ inputs.pre && '--pre' || ''}}
- ${{ inputs.name && '--name' || '' }}
- ${{ inputs.name || '' }}
- ${{ inputs.value && '--value' || '' }}
- ${{ inputs.value || '' }}
- ${{ inputs.build && '--build' || '' }}
- ${{ inputs.build || '' }}
- ${{ inputs.current }}
Loading