-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (99 loc) · 3.43 KB
/
Copy pathrelease.yml
File metadata and controls
122 lines (99 loc) · 3.43 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: release
on:
workflow_dispatch:
inputs:
release_kind:
description: "Release line to publish."
required: true
default: stable
type: choice
options:
- stable
- rc
permissions:
contents: write
concurrency:
group: release-pipeline
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
env:
RELEASE_KIND: ${{ inputs.release_kind }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 100
fetch-tags: true
- name: Install git-cliff
uses: taiki-e/install-action@git-cliff
- name: Create annotated tag
id: create_tag
shell: bash
run: |
set -euo pipefail
next_tag="$(python3 .github/scripts/compute_release_version.py --release-kind "${RELEASE_KIND}" --require-new-commits)"
release_name="${next_tag#v}"
if git ls-remote --exit-code --tags origin "refs/tags/${next_tag}" >/dev/null 2>&1; then
echo "Tag ${next_tag} already exists in origin." >&2
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${next_tag}" -m "Release ${next_tag#v}"
git push origin "${next_tag}"
commit_sha="$(git rev-parse HEAD)"
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
# Tag Created
- Release kind: \`${RELEASE_KIND}\`
- Tag: \`${next_tag}\`
- Commit: \`${commit_sha}\`
EOF
echo "next_tag=${next_tag}" >> "$GITHUB_OUTPUT"
echo "release_name=${release_name}" >> "$GITHUB_OUTPUT"
- name: Generate release notes
shell: bash
env:
NEXT_TAG: ${{ steps.create_tag.outputs.next_tag }}
run: |
set -euo pipefail
notes_path="${RUNNER_TEMP}/release-notes.md"
ignore_rc_tags='^v[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$'
if [[ "${NEXT_TAG}" =~ -rc\.[0-9]+$ ]]; then
git-cliff \
--current \
--output "${notes_path}"
else
git-cliff \
--current \
--ignore-tags "${ignore_rc_tags}" \
--output "${notes_path}"
fi
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
# Release Notes
EOF
cat "$notes_path" >> "$GITHUB_STEP_SUMMARY"
- name: Determine release flags
id: release_flags
shell: bash
env:
NEXT_TAG: ${{ steps.create_tag.outputs.next_tag }}
run: |
set -euo pipefail
if [[ "${NEXT_TAG}" =~ -rc\.[0-9]+$ ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
echo "make_latest=false" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
echo "make_latest=true" >> "$GITHUB_OUTPUT"
fi
- name: Publish GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.create_tag.outputs.next_tag }}
name: ${{ steps.create_tag.outputs.release_name }}
body_path: ${{ runner.temp }}/release-notes.md
prerelease: ${{ steps.release_flags.outputs.prerelease }}
make_latest: ${{ steps.release_flags.outputs.make_latest }}