-
-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (60 loc) · 1.83 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
name: publish-release-tag
on:
schedule:
- cron: '0 12 * * 5' # At 12:00 (12 PM) every Friday
workflow_dispatch:
inputs:
bump-level:
required: true
type: choice
description: 'The semver bump level'
options:
- 'major'
- 'minor'
- 'patch'
- 'premajor'
- 'preminor'
- 'prepatch'
- 'prerelease'
default: 'patch'
prerelease-tag:
required: false
description: 'The tag to use for prereleases'
default: 'alpha'
jobs:
publish-release-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.BOT_PAT_TOKEN }}
- name: Get Latest Tag
id: current
run: |
git fetch --tags
latest_tag=$(git tag | sort -V | tail -n 1)
echo "current version is: $latest_tag"
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
- name: Bump Version
id: bump-semver
uses: cbrgm/semver-bump-action@main
with:
current-version: ${{ env.latest_tag }}
bump-level: ${{ github.event.inputs.bump-level || 'patch' }}
prerelease-tag: ${{ github.event.inputs.prerelease-tag }}
- name: Publish Git Tag
run: |
git fetch --tags
latest_tag=$(git tag | sort -V | tail -n 1)
new_tag=${{ steps.bump-semver.outputs.new_version }}
if [[ $(git rev-list $latest_tag..HEAD --count) -gt 0 ]]; then
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag $new_tag
git push origin $new_tag
else
echo "No new commits since last tag. Skipping tag push. ($new_tag)"
fi
...