-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (83 loc) · 2.55 KB
/
_release.yaml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Tag and Release
on:
workflow_dispatch:
branches:
- main
inputs:
default-bump:
description: 'Version change type'
type: choice
required: false
default: patch
options:
- major
- minor
- patch
create-release:
description: 'Create release for tag'
type: boolean
required: false
default: false
dry-run:
description: 'Do not commit or tag anything.'
type: boolean
required: false
default: false
tag-annotated:
description: 'Annotated tag (not lightweight)'
type: boolean
required: false
default: false
tag-prefix:
description: 'Tag version prefix'
type: string
required: false
default: 'v'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Git User
shell: bash
# language="shell script"
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
- name: Bump version and push tag
id: tag_latest
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: ${{ inputs.default-bump }}
# custom_tag: ${{ inputs.custom-tag }}
create_annotated_tag: ${{ inputs.annotated-tag }}
tag_prefix: ${{ inputs.tag-prefix }}
- name: Create a GitHub release
id: create_release
if: ${{ ! inputs.dry-run && inputs.create-release }}
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_latest.outputs.new_tag }}
name: Release ${{ steps.tag_latest.outputs.new_tag }}
body: ${{ steps.tag_latest.outputs.changelog }}
- name: Move Major Version Tag
id: move_major
if: ${{ ! inputs.dry-run }}
shell: bash
env:
NEW_VERSION: ${{ steps.tag_latest.outputs.new_version }}
TAG_PREFIX: ${{ inputs.tag-prefix }}
# language="shell script"
run: |
MAJOR_TAG=""
MAJOR_VERSION="${NEW_VERSION%%.*}"
if [ -n "${MAJOR_VERSION}" ] ; then
MAJOR_TAG="${TAG_PREFIX}${MAJOR_VERSION}"
git tag -fa "${MAJOR_TAG}" -m 'Update major version tag'
git push origin "${MAJOR_TAG}" --force
fi
printf '%s\n' \
"major-tag=${MAJOR_TAG}" \
"major-version=${MAJOR_VERSION}" \
>> $GITHUB_OUTPUT