generated from xmidt-org/.go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #3 from xmidt-org/tag
Create tag.yml
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
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,28 @@ | ||
name: tag | ||
|
||
on: | ||
push: | ||
paths: | ||
- "CHANGELOG.md" # only try to tag if the CHANGELOG has been updated. | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: [ ubuntu-latest ] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}' | ||
fetch-depth: 0 | ||
- name: set up bot | ||
run: | | ||
git config --global user.name "xmidt-bot" | ||
git config --global user.email "$BOT_EMAIL" | ||
- name: export variables and tag commit | ||
run: | | ||
export OLD_VERSION=$(git describe --tags `git rev-list --tags --max-count=1` | tail -1) | ||
export TAG=$(cat CHANGELOG.md | perl -0777 -ne 'print "$1" if /.*## \[Unreleased\]\s+## \[(v\d+.\d+.\d+)\].*/s') | ||
export TODAY=`date +'%m/%d/%Y'` | ||
export NOTES=$(cat CHANGELOG.md | perl -0777 -ne 'print "$ENV{TODAY}\n\n$1\n" if /.*## \[$ENV{TAG}\]\s(.*?)\s+## \[(v\d+.\d+.\d+)\].*/s') | ||
if [[ "$TAG" != "" && "$TAG" != "$OLD_VERSION" ]]; then git tag -a "$TAG" -m "$NOTES"; git push origin --tags; echo $?; fi |