-
Notifications
You must be signed in to change notification settings - Fork 347
191 lines (166 loc) · 7.27 KB
/
Copy path_generate-changelog.yml
File metadata and controls
191 lines (166 loc) · 7.27 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# **what?**
# Generates changelog files from unreleased changelog entries using changie.
# **why?**
# Automates the process of consolidating individual changelog entries into versioned changelog files for releases.
# **when?**
# This workflow is called by other workflows (like publish-oss.yml) during the release process or can be manually triggered via workflow_dispatch.
name: "# Changelog generation"
run-name: "Changelog generation - ${{ github.actor }} - package:${{ inputs.package }} merge:${{ inputs.merge }} branch:${{ inputs.branch }}"
on:
workflow_call:
inputs:
package:
description: "Choose the package getting published"
type: string
default: "dbt-adapters"
branch:
description: "Choose the branch to use"
type: string
default: "main"
secrets:
FISHTOWN_BOT_PAT:
description: "Token to commit/merge changes into branches"
required: true
IT_TEAM_MEMBERSHIP:
description: "Token that can view org level teams"
required: true
workflow_dispatch:
inputs:
package:
description: "Choose the package getting published"
type: choice
options:
- "dbt-adapters"
- "dbt-tests-adapter"
- "dbt-athena"
- "dbt-bigquery"
- "dbt-postgres"
- "dbt-redshift"
- "dbt-snowflake"
- "dbt-spark"
branch:
description: "Choose the branch to use"
type: string
default: "main"
permissions:
contents: write
jobs:
version:
runs-on: ${{ vars.DEFAULT_RUNNER }}
outputs:
raw: ${{ steps.version.outputs.raw }}
base: ${{ steps.semver.outputs.base-version }}
prerelease: ${{ steps.semver.outputs.pre-release }}
is-prerelease: ${{ steps.semver.outputs.is-pre-release }}
steps:
- name: "Checkout ${{ inputs.branch }}"
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: "Set up Python"
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # actions/setup-python@v6
with:
python-version: ${{ vars.DEFAULT_PYTHON_VERSION }}
- name: "Install hatch"
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc # pypa/hatch@install
- name: "Get package version"
id: version
run: echo "raw=$(hatch version)" >> $GITHUB_OUTPUT
working-directory: ./${{ inputs.package }}
- name: "Parse semantic version"
id: semver
uses: dbt-labs/actions/parse-semver@v1
with:
version: ${{ steps.version.outputs.raw }}
changelog:
needs: version
runs-on: ${{ vars.DEFAULT_RUNNER }}
outputs:
path: ${{ steps.changelog.outputs.path }}
exists: ${{ steps.changelog.outputs.exists }}
steps:
- name: "Checkout ${{ inputs.branch }}"
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: "Check if changelog exists"
id: changelog
run: |
path=".changes/${{ needs.version.outputs.base }}"
if [[ ${{ needs.version.outputs.is-prerelease }} -eq 1 ]]
then
path+="-${{ needs.version.outputs.prerelease }}"
fi
path+=".md"
echo "path=$path" >> $GITHUB_OUTPUT
exists=false
if test -f $path
then
exists=true
fi
echo "exists=$exists">> $GITHUB_OUTPUT
working-directory: ./${{ inputs.package }}
dbt-membership:
needs: changelog
if: needs.changelog.outputs.exists == 'false'
runs-on: ${{ vars.DEFAULT_RUNNER }}
outputs:
team: ${{ steps.team.outputs.team }}
steps:
- name: "Generate temp file name"
id: temp-file
run: echo "name=output_$GITHUB_RUN_ID.json" >> $GITHUB_OUTPUT
- name: "Fetch core team members"
run: |
gh api -H "Accept: application/vnd.github+json" orgs/dbt-labs/teams/core-group/members > ${{ steps.temp-file.outputs.name }}
env:
GH_TOKEN: ${{ secrets.IT_TEAM_MEMBERSHIP }}
- name: "Parse team members"
id: team
run: |
team_list=$(jq -r '.[].login' ${{ steps.temp-file.outputs.name }})
team_list_single=$(echo $team_list | tr '\n' ' ')
echo "team=$team_list_single" >> $GITHUB_OUTPUT
- name: "Clean up temp file"
run: rm ${{ steps.temp-file.outputs.name }}
generate-changelog:
needs:
- version
- changelog
- dbt-membership
if: needs.changelog.outputs.exists == 'false'
runs-on: ${{ vars.DEFAULT_RUNNER }}
steps:
- name: "Checkout ${{ inputs.branch }}"
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: "Add Homebrew to PATH"
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
- name: "Install changie"
run: |
brew tap miniscruff/changie https://github.com/miniscruff/changie
brew install changie
- name: "Generate changelog"
run: |
if [[ ${{ needs.version.outputs.is-prerelease }} -eq 1 ]]
then
changie batch ${{ needs.version.outputs.base }} --move-dir '${{ needs.version.outputs.base }}' --prerelease ${{ needs.version.outputs.prerelease }}
elif [[ -d ".changes/${{ needs.version.outputs.base }}" ]]
then
changie batch ${{ needs.version.outputs.base }} --include '${{ needs.version.outputs.base }}' --remove-prereleases
else # releasing a final patch with no prereleases
changie batch ${{ needs.version.outputs.base }}
fi
changie merge
git add .
working-directory: ./${{ inputs.package }}
env:
CHANGIE_CORE_TEAM: ${{ needs.dbt-membership.outputs.team }}
- name: "Run pre-commit hooks"
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # pre-commit/action@v3.0.1
continue-on-error: true
- name: "Commit changelog"
uses: ./.github/actions/bot-commit
with:
message: "Generate changelog for ${{ needs.version.outputs.raw }}"