Skip to content

Commit 94e3083

Browse files
authored
Merge pull request #23 from git-mastery/woojiahao/use-reusable-workflow
Use reusable workflow shared across repositories
2 parents 98b82d5 + cea8ccf commit 94e3083

File tree

1 file changed

+2
-64
lines changed

1 file changed

+2
-64
lines changed

.github/workflows/bump-version.yml

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,5 @@ on:
77

88
jobs:
99
tag:
10-
if: github.event.pull_request.merged == true
11-
runs-on: ubuntu-latest
12-
13-
concurrency:
14-
group: tag-main
15-
cancel-in-progress: false
16-
17-
permissions:
18-
contents: write
19-
20-
steps:
21-
- uses: actions/checkout@v4
22-
with:
23-
fetch-depth: 0
24-
25-
- name: Get latest tag
26-
id: latest
27-
run: |
28-
git fetch --tags
29-
tag=$(git tag --sort=-v:refname | head -n 1)
30-
echo "tag=${tag:-v0.0.0}" >> $GITHUB_OUTPUT
31-
32-
- name: Determine bump
33-
id: bump
34-
run: |
35-
labels='${{ toJson(github.event.pull_request.labels.*.name) }}'
36-
if echo "$labels" | grep -q "bump:major"; then
37-
echo "type=major" >> $GITHUB_OUTPUT
38-
elif echo "$labels" | grep -q "bump:minor"; then
39-
echo "type=minor" >> $GITHUB_OUTPUT
40-
elif echo "$labels" | grep -q "bump:patch"; then
41-
echo "type=patch" >> $GITHUB_OUTPUT
42-
else
43-
echo "No bump label found" >&2
44-
exit 1
45-
fi
46-
47-
- name: Calculate next version
48-
id: version
49-
run: |
50-
v=${{ steps.latest.outputs.tag }}
51-
v=${v#v}
52-
IFS=. read major minor patch <<< "$v"
53-
54-
case "${{ steps.bump.outputs.type }}" in
55-
major) major=$((major+1)); minor=0; patch=0 ;;
56-
minor) minor=$((minor+1)); patch=0 ;;
57-
patch) patch=$((patch+1)) ;;
58-
esac
59-
60-
echo "next=v$major.$minor.$patch" >> $GITHUB_OUTPUT
61-
62-
- name: Create and push tag
63-
env:
64-
PAT: ${{ secrets.ORG_PAT }}
65-
run: |
66-
git config --global user.name "GitHub Actions"
67-
git config --global user.email "[email protected]"
68-
69-
TAG=${{ steps.version.outputs.next }}
70-
71-
git tag "$TAG"
72-
73-
git push https://x-access-token:${PAT}@github.com/${{ github.repository }}.git refs/tags/$TAG
10+
uses: git-mastery/actions/.github/workflows/bump-version.yml@main
11+
secrets: inherit

0 commit comments

Comments
 (0)