-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (63 loc) · 2.05 KB
/
Copy pathrelease.yml
File metadata and controls
68 lines (63 loc) · 2.05 KB
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
# SPDX-FileCopyrightText: Copyright (c) CloudZero, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
name: Release
on:
workflow_dispatch:
inputs:
versionIncrementLevel:
description: Increment level to use for the release
required: true
type: choice
default: patch
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
concurrency:
group: ${{ github.ref }}-release
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v4
- name: Version
id: version
uses: ./.github/actions/semver
with:
incrementLevel: ${{ github.event.inputs.versionIncrementLevel }}
source: tags
- name: Validate Release Notes
uses: ./
id: changelog
with:
version: ${{ steps.version.outputs.nextVersion }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.version.outputs.nextVersion }}
tag_name: ${{ steps.version.outputs.nextVersion }}
make_latest: true
target_commitish: ${{ github.sha }}
body_path: ${{ steps.changelog.outputs.releaseNotesFile }}
- name: Extract major version
id: major_version
run: echo "major=$(echo ${{ steps.version.outputs.nextVersion }} | sed 's/[^0-9]*\([0-9]*\).*/\1/')" >> $GITHUB_OUTPUT
- name: Tag major version
run: git tag -f v${{ steps.major_version.outputs.major }}
- name: Push major version tag
run: git push origin v${{ steps.major_version.outputs.major }} --force
failure:
runs-on: ubuntu-latest
if: ${{ github.ref != 'refs/heads/main' }}
steps:
- name: Fail If Branch Is Not Main
run: |
echo "This workflow can only be run from the 'main' branch. Current branch: ${{ github.ref }}"
exit 1