-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from emteknetnz/main
NEW Create action
- Loading branch information
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Auto-tag | ||
on: | ||
push: | ||
tags: | ||
- '*.*.*' | ||
jobs: | ||
auto-tag: | ||
name: Auto-tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Auto-tag | ||
uses: silverstripe/gha-auto-tag@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
# gha-auto-tag | ||
# GitHub Actions - Auto-tag | ||
|
||
Delete and re-release tags so that other modules can use something similar to carets (^) | ||
|
||
Caret (^) requirements are not supported by github-action e.g. @^2 does not work | ||
|
||
The action will tag v2 when 2.5.0 is released and v0.3 when 0.3.5 is released | ||
|
||
The new 'v' tag will point to the same sha e.g. the sha of v2 will equal the sha of 2.5.0 | ||
|
||
This allows modules to include workflows using the @v2 or @v0.3 syntax | ||
|
||
Using the 'v' prefix to avoid confusion with the '2' branch naming convention that Silverstripe uses | ||
|
||
## Usage | ||
|
||
This action has no configuration or inputs - just add the following workflow verbatim. | ||
|
||
**.github/workflows/auto-tag.yml** | ||
```yml | ||
on: | ||
push: | ||
tags: | ||
- '*.*.*' | ||
jobs: | ||
auto-tag: | ||
name: Auto-tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Auto-tag | ||
uses: silverstripe/gha-auto-tag@main | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Auto-tag | ||
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 | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
|
||
- name: Generate tag name | ||
id: generate_tag_name | ||
shell: bash | ||
env: | ||
GITHUB_REF: ${{ github.ref }} | ||
run: | | ||
# refs/tags/0.1.23 => 0.1.23 | ||
TAG=$(echo $GITHUB_REF | cut -c 11-) | ||
if ! [[ $TAG =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | ||
echo "Invalid semver tag $TAG" | ||
exit 1 | ||
fi | ||
MAJOR="${BASH_REMATCH[1]}" | ||
MINOR="${BASH_REMATCH[2]}" | ||
PATCH="${BASH_REMATCH[3]}" | ||
NEW_TAG="v${MAJOR}" | ||
if [ "$MAJOR" == "0" ]; then | ||
NEW_TAG=("v${MAJOR}.${MINOR}") | ||
fi | ||
echo "Tag is $NEW_TAG" | ||
echo "::set-output name=tag::$NEW_TAG" | ||
- name: Add tag to repo | ||
uses: silverstripe/gha-tag-release@main | ||
with: | ||
tag: ${{ steps.generate_tag_name.outputs.tag }} | ||
delete_existing: true | ||
release: false |