-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (95 loc) · 3.29 KB
/
auto-releaser.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# SPDX-FileCopyrightText: 2024 Comcast Cable Communications Management, LLC
# SPDX-License-Identifier: Apache-2.0
# @example=## Golang Automatic Patch Releaser Sample
## SPDX-FileCopyrightText: 2024 Comcast Cable Communications Management, LLC
## SPDX-License-Identifier: Apache-2.0
#---
#name: 'Automatically relase patch versions.'
#
# on:
# schedule: # Run every day at 12:00 UTC
# - cron: '0 12 * * *'
# workflow_dispatch:
#
# jobs:
# release:
# uses: xmidt-org/shared-go/.github/workflows/ci.yml@826aa545bb56f6c7c551d44febb420c0293c8bff # v4.2.0
# secrets: inherit
---
name: 'Auto Releaser'
on:
workflow_call:
inputs:
branch:
description: 'Branch to release from.'
type: string
required: false
default: 'main'
patch-list:
description: 'Comma separated list of commit types that should trigger a patch release.'
type: string
required: false
default: fix, Fix, FIX, bugfix, Bugfix, BugFix, BUGFIX, perf, refactor, Refactor, REFACTOR, test, Test, TEST, tests, Tests, TESTS, chore, Chore, CHORE
minor-list:
description: 'The specific minor prefix names to use for minors.'
type: string
required: false
default: feat, Feat, FEAT, feature, Feature, FEATURE
which:
description: Create a 'release' or 'tag'.
type: string
required: false
default: tag
jobs:
release:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get Next Version
id: semver
uses: ietf-tools/semver-action@1c7c3f023f427188333afc94c8b91c76d63ec799 # v1.9.0
with:
token: ${{ github.token }}
branch: ${{ inputs.branch }}
patchList: ${{ inputs.patch-list }}
minorList: ${{ inputs.minor-list }}
noVersionBumpBehavior: silent
noNewCommitBehavior: silent
- name: No Release Needed
if: |
steps.semver.outputs.next == ''
run: echo "No release needed."
- name: Create Release
if: |
steps.semver.outputs.next != '' &&
inputs.which == 'release'
uses: ncipollo/release-action@cdcc88a9acf3ca41c16c37bb7d21b9ad48560d87 # v1.15.0
with:
name: ${{ steps.semver.outputs.next }}
tag: ${{ steps.semver.outputs.next }}
commit: ${{ github.sha }}
token: ${{ github.token }}
- name: Create Tag
if: |
steps.semver.outputs.next != '' &&
inputs.which == 'tag'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.semver.outputs.next }}',
sha: context.sha
})
- name: Failure
if: |
steps.semver.outputs.next != '' &&
inputs.which != 'release' &&
inputs.which != 'tag'
run: |
echo "No new version found."
exit