Skip to content

Commit

Permalink
Update workflows (#135)
Browse files Browse the repository at this point in the history
* Chore: Implement (failing) tests for incrementing tags

Signed-off-by: Matthew Watkins <[email protected]>

* Chore: Implement (failing) tests for incrementing tags

Signed-off-by: Matthew Watkins <[email protected]>

---------

Signed-off-by: Matthew Watkins <[email protected]>
  • Loading branch information
ModeSevenIndustrialSolutions authored Aug 1, 2024
1 parent b054cab commit 8d00eea
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
8 changes: 2 additions & 6 deletions .github/actions/semantic-tag-increment/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ runs:
echo "Increment type: $TYPE"
if [[ "$TAG" == v* ]]; then
echo "Converting tag to purely numeric equivalent"
TAG="${TAG:1}"
fi
# Regular expression to match semantic tag
PATTERN="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$"
# Validate supplied tag
# Validate supplied (and parsed) tag
if ! [[ "$TAG" =~ $PATTERN ]]; then
echo "Invalid semantic tag"; exit 1
else
Expand All @@ -71,10 +70,7 @@ runs:
MAJOR=$(echo "$TAG" | sed -e "s#$REGEX#\1#")
MINOR=$(echo "$TAG" | sed -e "s#$REGEX#\2#")
PATCH=$(echo "$TAG" | sed -e "s#$REGEX#\3#")
echo "Extracted"
echo " Major: $MAJOR"
echo " Minor: $MINOR"
echo " Patch: $PATCH"
echo "Extracted: Major: $MAJOR Minor: $MINOR Patch: $PATCH""
### CONTENT RECENTLY ADDED ###
Expand Down
43 changes: 40 additions & 3 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,51 @@ jobs:
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/semantic-tag-latest@main

- name: "Action: semantic-tag-increment"
id: semantic-tag-increment
- name: "Action: semantic-tag-increment [patch]"
id: semantic-tag-increment-patch
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/semantic-tag-increment@main
with:
tag: "${{ steps.semantic-tag-latest.outputs.tag }}"
tag: "v2.9.6"
type: "patch"

- name: "Action: semantic-tag-increment [minor]"
id: semantic-tag-increment-minor
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/semantic-tag-increment@main
with:
tag: "v0.1.2"
type: "minor"

- name: "Action: semantic-tag-increment [major]"
id: semantic-tag-increment-major
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/semantic-tag-increment@main
with:
tag: "v1.2.3"
type: "major"

- name: "Validate Incremented Tags"
shell: bash
run: |
# Check output from: semantic-tag-increment
ERRORS="false"
if [ "${{ steps.semantic-tag-increment-patch.outputs.tag }}" != "v2.9.7" ]; then
echo "Errors with: semantic-tag-increment [patch]"
ERRORS="true"
fi
if [ "${{ steps.semantic-tag-increment-minor.outputs.tag }}" != "0.2.0" ]; then
echo "Errors with: semantic-tag-increment [minor]"
ERRORS="true"
fi
if [ "${{ steps.semantic-tag-increment-major.outputs.tag }}" != "1.0.0" ]; then
echo "Errors with: semantic-tag-increment [major]"
ERRORS="true"
fi
if [ "$ERRORS" = "true" ]; then
echo "Logic implementing tag handling needs checking"; exit 1
fi
- name: "Action: url-validity-check"
id: url-validity-check
# yamllint disable-line rule:line-length
Expand Down

0 comments on commit 8d00eea

Please sign in to comment.