-
Notifications
You must be signed in to change notification settings - Fork 13
146 lines (123 loc) · 4.37 KB
/
prepare-release.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Prepare release
permissions:
contents: write
pull-requests: write
on:
workflow_dispatch:
inputs:
version:
description: "Release version (without leading 'v')"
required: true
type: string
release_branch:
description: "Release branch name"
required: true
type: string
default: "main"
pre_release:
description: "Pre-release? (Don't render changelog)"
required: true
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
pre_release_tasks:
runs-on: ubuntu-latest
steps:
- name: Validate input
run: |
if [[ ${{ inputs.version }} = v* ]]
then
echo "::error title=Invalid Version::Invalid version number given"
exit 1
fi
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
ref: "${{ inputs.release_branch }}"
- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Configure Git
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
- name: Install dkist
run: |
python -m pip install .
- name: Update attrs
run: |
python -c "from dkist.net.attrs_values import attempt_local_update; attempt_local_update(user_file='./dkist/data/api_search_values.json', silence_net_errors=False)"
- name: Commit Attrs
run: |
git update-index --refresh || true
git diff-index --quiet HEAD -- || git commit -m "Update attrs values before release [skip ci]" dkist/data/api_search_values.json
- name: Install towncrier
run: python -m pip install --upgrade towncrier pre-commit
- name: Run towncrier in draft to capture the output
run: towncrier build --draft --version ${{ inputs.version }} --yes > release-changelog.rst
- name: Convert to markdown with pandoc
uses: docker://pandoc/core:2.9
with:
args: >-
--wrap=none
-t markdown_strict
--output=release-changelog.md
release-changelog.rst
- name: Capture Markdown Changelog
id: markdown-changelog
run: |
{
echo 'content<<EOF'
cat release-changelog.md
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Cleanup Temporary Changelog Files
run: rm release-changelog.md release-changelog.rst
- name: Debug md changelog
run: |
echo "${{ steps.markdown-changelog.outputs.content }}"
- name: Run towncrier
if: ${{ ! inputs.pre_release }}
run: |
towncrier build --version ${{ inputs.version }} --yes
- name: Run pre-commit
run: |
git add .
pre-commit run || true
git add .
- name: Commit Changelog
run: |
git diff-index --quiet HEAD -- || git commit -m "Render changelog for v${{ inputs.version }}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: "prepare-v${{ inputs.version }}"
title: 'Prepare for release of v${{ inputs.version }}'
body: |
*This pull request will need to be closed and then re-opened to trigger the CI*
This PR renders the changelog and updates the JSON attrs before release of v${{ inputs.version }}.
A draft release has been made with the changelog, release it after merge to trigger the release.
labels: |
no changelog
- name: Create draft GitHub Release
uses: actions/github-script@v7
id: create-release
env:
RELEASE_BODY: "${{ steps.markdown-changelog.outputs.content }}"
with:
script: |
const { RELEASE_BODY } = process.env
return await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "v${{ inputs.version }}",
name: "v${{ inputs.version }}",
body: `${RELEASE_BODY}`,
draft: true,
prerelease: ${{ inputs.pre_release }}
});