generated from tktcorporation/.github
-
Notifications
You must be signed in to change notification settings - Fork 1
47 lines (42 loc) · 1.43 KB
/
push-tag.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Push Tag
on:
push:
branches:
- master
- main
jobs:
create_git_tag:
runs-on: ubuntu-latest
name: Push Tag
outputs:
is_new_release: ${{ steps.check_push.outputs.is_push }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# NOTE @v2 uses the token as an auth http header. Set it to
# a Personal Access Token instead of secrets.GITHUB_TOKEN
# so that tag pushes trigger repo push events.
token: ${{ secrets.MY_PERSONAL_ACCESS_TOKEN }}
- name: set tagname
id: tag_name
run: echo ::set-output name=tag_name::v$(cat Cargo.toml | grep -m1 "version" | cut -d " " -f 3 | tr -d '"')
- name: "Get Previous tag"
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 0.0.1 # Optional fallback tag to use when no tag can be found
- name: Check push
id: check_push
run: |
if [ ${{ steps.previoustag.outputs.tag }} != ${{ steps.tag_name.outputs.tag_name }} ] ; then
echo ::set-output name=is_push::true
else
echo ::set-output name=is_push::false
fi
- name: Push Tag
if: steps.check_push.outputs.is_push == 'true'
run: |
git tag ${{ steps.tag_name.outputs.tag_name }}
git push origin ${{ steps.tag_name.outputs.tag_name }}