Skip to content

Commit

Permalink
Merge pull request #1 from emteknetnz/main
Browse files Browse the repository at this point in the history
NEW Create action
  • Loading branch information
GuySartorelli authored Jun 9, 2022
2 parents e71a886 + b2ff281 commit 277edcf
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/auto-tag.yml
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
33 changes: 32 additions & 1 deletion README.md
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
```
35 changes: 35 additions & 0 deletions action.yml
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

0 comments on commit 277edcf

Please sign in to comment.