Skip to content

Commit 2f628ad

Browse files
authored
feat(ci): create reusable changelog generation (aws-powertools#1418)
1 parent 5dfc459 commit 2f628ad

File tree

4 files changed

+67
-12
lines changed

4 files changed

+67
-12
lines changed

.github/workflows/publish.yml

+24-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ name: Publish to PyPi
1414
# 3. Bump package version and generate latest Changelog
1515
# 4. Publish package to PyPi test and prod repository
1616
# 5. Kick off SAR App pipeline to publish latest version with minimal and extra dependencies
17-
# 6. Builds a new user guide and API docs with release version; update /latest pointing to newly released version
18-
# 7. Close all issues labeled "pending-release" and notify customers about the release
17+
# 6. Builds and publish latest changelog from tip of the branch
18+
# 7. Builds a new user guide and API docs with release version; update /latest pointing to newly released version
19+
# 8. Close all issues labeled "pending-release" and notify customers about the release
1920

2021
# See MAINTAINERS.md "Releasing a new version" for release mechanisms
2122

@@ -33,6 +34,11 @@ on:
3334
default: false
3435
type: boolean
3536
required: false
37+
skip_code_quality:
38+
description: "Skip tests, linting, and baseline. Only use if release fail for reasons beyond our control and you need a quick release."
39+
default: false
40+
type: boolean
41+
required: false
3642

3743
jobs:
3844
release:
@@ -66,7 +72,7 @@ jobs:
6672
- name: Install dependencies
6773
run: make dev
6874
- name: Run all tests, linting and baselines
69-
if: ${{ !inputs.skip_pypi }}
75+
if: ${{ !inputs.skip_code_quality }}
7076
run: make pr
7177
- name: Bump package version
7278
run: poetry version ${RELEASE_VERSION}
@@ -95,8 +101,17 @@ jobs:
95101
aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_VERSION --overwrite
96102
aws codepipeline start-pipeline-execution --name ${{ secrets.AWS_SAR_PIPELINE_NAME }}
97103
98-
docs:
104+
changelog:
99105
needs: release
106+
permissions:
107+
contents: write
108+
uses: ./.github/workflows/reusable_publish_changelog.yml
109+
110+
docs:
111+
needs: [release, changelog]
112+
permissions:
113+
contents: write
114+
pages: write
100115
runs-on: ubuntu-latest
101116
env:
102117
RELEASE_VERSION: ${{ needs.release.outputs.RELEASE_VERSION }}
@@ -138,6 +153,11 @@ jobs:
138153

139154
post_release:
140155
needs: release
156+
permissions:
157+
contents: read
158+
issues: write
159+
discussions: write
160+
pull-requests: write
141161
runs-on: ubuntu-latest
142162
env:
143163
RELEASE_VERSION: ${{ needs.release.outputs.RELEASE_VERSION }}

.github/workflows/python_docs.yml

+6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ on:
1313
- "examples/**"
1414

1515
jobs:
16+
changelog:
17+
permissions:
18+
contents: write
19+
uses: ./.github/workflows/reusable_publish_changelog.yml
20+
1621
docs:
22+
needs: changelog
1723
# Force Github action to run only a single job at a time (based on the group name)
1824
# This is to prevent "race-condition" in publishing a new version of doc to `gh-pages`
1925
concurrency:

.github/workflows/rebuild_latest_docs.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ on:
1616
required: true
1717

1818
jobs:
19+
changelog:
20+
permissions:
21+
contents: write
22+
uses: ./.github/workflows/reusable_publish_changelog.yml
23+
1924
release:
25+
needs: changelog
2026
# Force Github action to run only a single job at a time (based on the group name)
2127
# This is to prevent "race-condition" in publishing a new version of doc to `gh-pages`
2228
concurrency:
@@ -43,14 +49,6 @@ jobs:
4349
run: |
4450
git config --global user.name Docs deploy
4551
git config --global user.email [email protected]
46-
- name: Generate latest CHANGELOG
47-
run: make changelog
48-
- name: Push project metadata and changelog to trunk
49-
run: |
50-
git add CHANGELOG.md
51-
git add pyproject.toml
52-
git commit -m "chore(ci): update project with version ${RELEASE_TAG_VERSION}"
53-
git push origin HEAD:refs/heads/develop
5452
- name: Build docs website and API reference
5553
run: |
5654
make release-docs VERSION=${RELEASE_TAG_VERSION} ALIAS="latest"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build and publish latest changelog
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
publish_changelog:
11+
# Force Github action to run only a single job at a time (based on the group name)
12+
# This is to prevent race-condition and inconsistencies with changelog push
13+
concurrency:
14+
group: changelog-build
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository # reusable workflows start clean, so we need to checkout again
18+
uses: actions/checkout@v3
19+
- name: Git client setup and refresh tip
20+
run: |
21+
git config user.name "Release bot"
22+
git config user.email "[email protected]"
23+
git config pull.rebase true
24+
git pull --rebase
25+
- name: "Generate latest changelog"
26+
run: make changelog
27+
- name: Update Changelog in trunk
28+
run: |
29+
git add CHANGELOG.md
30+
git commit -m "chore(ci): update changelog with latest changes"
31+
git push origin HEAD:refs/heads/develop

0 commit comments

Comments
 (0)