Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Create action #1

Merged
merged 2 commits into from
Jun 9, 2022
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
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
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
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

GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
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
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
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
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
with:
tag: ${{ steps.generate_tag_name.outputs.tag }}
delete_existing: true
release: false