Skip to content

Commit 98a2c87

Browse files
committed
NEW Create action
1 parent 74f5614 commit 98a2c87

File tree

3 files changed

+10
-42
lines changed

3 files changed

+10
-42
lines changed

.github/workflows/auto-tag.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
name: Auto-tag
12
on:
23
push:
34
tags:
@@ -8,7 +9,4 @@ jobs:
89
runs-on: ubuntu-latest
910
steps:
1011
- name: Auto-tag
11-
uses: emteknetnz/gha-auto-tag@main
12-
with:
13-
ref: ${{ github.ref }}
14-
sha: ${{ github.sha }}
12+
uses: silverstripe/gha-auto-tag@main

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Using the 'v' prefix to avoid confusion with the '2' branch naming convention th
1414

1515
## Usage
1616

17-
.github/workflows/auto-tag.yml
17+
This action has no configuration or inputs - just add the following workflow verbatim.
18+
19+
**.github/workflows/auto-tag.yml**
1820
```yml
1921
on:
2022
push:
@@ -27,8 +29,4 @@ jobs:
2729
steps:
2830
- name: Auto-tag
2931
uses: silverstripe/gha-auto-tag@main
30-
with:
31-
ref: ${{ github.ref }}
32-
sha: ${{ github.sha }}
33-
3432
```

action.yml

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,21 @@
11
name: Auto-tag
22
description: Automatically delete and re-release tags so that other github action modules can use something similar to carets e.g. v0.1 or v3
3-
inputs:
4-
ref:
5-
type: string
6-
required: true
7-
description: github.ref when workflow is triggered by x.y.z semver tag e.g. refs/tags/0.1.23
8-
sha:
9-
type: string
10-
required: true
11-
description: SHA of the tag
123

134
runs:
145
using: composite
156
steps:
16-
- name: Validate inputs
17-
shell: bash
18-
env:
19-
REF: ${{ inputs.ref }}
20-
SHA: ${{ inputs.sha }}
21-
run: |
22-
# refs/tags/0.1.23 => 0.1.23
23-
TAG=$(echo $REF | cut -c 11-)
24-
if [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
25-
echo "Valid tag $TAG"
26-
else
27-
echo "Invalid tag $TAG"
28-
exit 1
29-
fi
30-
if [[ "$SHA" =~ ^[0-9a-f]{40}$ ]]; then
31-
echo "Valid sha $SHA"
32-
else
33-
echo "Invalid sha $SHA"
34-
exit 1
35-
fi
36-
377
- name: Generate tag name
388
id: generate_tag_name
399
shell: bash
4010
env:
41-
REF: ${{ inputs.ref }}
11+
REF: ${{ github.ref }}
4212
run: |
4313
# refs/tags/0.1.23 => 0.1.23
4414
TAG=$(echo $REF | cut -c 11-)
45-
[[ $TAG =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]
15+
if ! [[ $TAG =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
16+
echo "Invalid semver tag $TAG"
17+
exit 1
18+
fi
4619
MAJOR="${BASH_REMATCH[1]}"
4720
MINOR="${BASH_REMATCH[2]}"
4821
PATCH="${BASH_REMATCH[3]}"
@@ -56,7 +29,6 @@ runs:
5629
- name: Add tag to repo
5730
uses: silverstripe/gha-tag-release@main
5831
with:
59-
sha: ${{ github.sha }}
6032
tag: ${{ steps.generate_tag_name.outputs.tag }}
6133
delete_existing: true
6234
release: false

0 commit comments

Comments
 (0)