@@ -4,44 +4,38 @@ name: Publish to PyPi |
4 | 4 | # |
5 | 5 | # === Manual activities === |
6 | 6 | # |
7 | | -# 1. Document human readable changes in CHANGELOG (pre-generate unreleased changes with `make changelog`) |
8 | | -# 2. Bump package version using poetry version <major|minor|patch|specific version> |
9 | | -# 3. Merge version changes to develop branch |
10 | | -# 4. Edit the current draft release notes |
11 | | -# 5. If not already set, use `v<new version>` as a tag, and select develop as target branch |
| 7 | +# 1. Edit the current draft release notes |
| 8 | +# 2. If not already set, use `v<new version>` as a tag, e.g., v1.26.4, and select develop as target branch |
12 | 9 | # |
13 | 10 | # === Automated activities === |
14 | 11 | # |
15 | 12 | # 1. Extract release notes tag that was published |
16 | | -# 2. Ensure release notes tag match what's in CHANGELOG and pyproject |
17 | | -# 3. Run tests, linting, security and complexity base line |
18 | | -# 4. Publish package to PyPi test repository |
19 | | -# 5. Publish package to PyPi prod repository |
20 | | -# 6. Kick off Lambda Layer pipeline to publish latest version with minimal dependencies as a SAR App |
21 | | -# 7. Kick off Lambda Layer pipeline to publish latest version with extra dependencies as a SAR App |
22 | | -# 8. Builds a fresh version of docs including Changelog updates |
23 | | -# 9. Builds latest documentation for new release, and update latest alias pointing to the new release tag |
24 | | -# 10. Close and notify all issues labeled "pending-release" about the release details |
| 13 | +# 2. Run tests, linting, security and complexity base line |
| 14 | +# 3. Bump package version and generate latest Changelog |
| 15 | +# 4. Publish package to PyPi test and prod repository |
| 16 | +# 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 |
25 | 19 |
|
26 | | -# |
27 | | -# === Fallback mechanism due to external failures === |
28 | | -# |
29 | | -# 1. Trigger "Publish to PyPi" workflow manually: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow |
30 | | -# 2. Use the version released under Releases e.g. v1.13.0 |
31 | | -# |
32 | | - |
33 | | -# |
34 | | -# === Documentation hotfix === |
35 | | -# |
36 | | -# Look for rebuild latest docs workflow |
| 20 | +# See MAINTAINERS.md "Releasing a new version" for release mechanisms |
37 | 21 |
|
38 | 22 | on: |
39 | 23 | release: |
40 | 24 | types: [published] |
| 25 | + workflow_dispatch: |
| 26 | + inputs: |
| 27 | + version_to_publish: |
| 28 | + description: "Version to be released in PyPi, Docs, and Lambda Layer, e.g. v1.26.4" |
| 29 | + default: v1.26.4 |
| 30 | + required: true |
41 | 31 |
|
42 | 32 | jobs: |
43 | 33 | release: |
44 | 34 | runs-on: ubuntu-latest |
| 35 | + outputs: |
| 36 | + RELEASE_VERSION: ${{ steps.release_version.outputs.RELEASE_VERSION }} |
| 37 | + env: |
| 38 | + RELEASE_TAG_VERSION: ${{ github.event.release.tag_name || inputs.version_to_publish }} |
45 | 39 | steps: |
46 | 40 | - uses: actions/checkout@v3 |
47 | 41 | with: |
@@ -51,17 +45,30 @@ jobs: |
51 | 45 | with: |
52 | 46 | python-version: "3.8" |
53 | 47 | - name: Set release notes tag |
| 48 | + id: release_version |
| 49 | + # transform tag format `v<version` to `<version` |
54 | 50 | run: | |
55 | | - RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} |
56 | | - echo "RELEASE_TAG_VERSION=${RELEASE_TAG_VERSION:1}" >> $GITHUB_ENV |
57 | | - - name: Ensure new version is also set in pyproject and CHANGELOG |
58 | | - run: | |
59 | | - grep --regexp "${RELEASE_TAG_VERSION}" CHANGELOG.md |
60 | | - grep --regexp "version \= \"${RELEASE_TAG_VERSION}\"" pyproject.toml |
| 51 | + RELEASE_VERSION=${RELEASE_TAG_VERSION:1} |
| 52 | + echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV |
| 53 | + echo "::set-output name=RELEASE_VERSION::${RELEASE_VERSION}" |
61 | 54 | - name: Install dependencies |
62 | 55 | run: make dev |
63 | 56 | - name: Run all tests, linting and baselines |
64 | 57 | run: make pr |
| 58 | + - name: Bump package version |
| 59 | + run: poetry version ${RELEASE_VERSION} |
| 60 | + - name: Generate latest CHANGELOG |
| 61 | + run: make changelog |
| 62 | + - name: Setup git client |
| 63 | + run: | |
| 64 | + git config user.name "Release bot" |
| 65 | + |
| 66 | + - name: Push project metadata and changelog to trunk |
| 67 | + run: | |
| 68 | + git add CHANGELOG.md |
| 69 | + git add pyproject.toml |
| 70 | + git commit -m "chore(ci): update project with version ${RELEASE_VERSION}" |
| 71 | + git push origin HEAD:refs/heads/develop |
65 | 72 | - name: Build python package and wheel |
66 | 73 | run: poetry build |
67 | 74 | - name: Upload to PyPi test |
@@ -76,39 +83,58 @@ jobs: |
76 | 83 | PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |
77 | 84 | - name: publish lambda layer in SAR by triggering the internal codepipeline |
78 | 85 | run: | |
79 | | - aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION --overwrite |
| 86 | + aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_VERSION --overwrite |
80 | 87 | aws codepipeline start-pipeline-execution --name ${{ secrets.CODEPIPELINE_NAME }} |
81 | 88 | env: |
82 | 89 | # Maintenance: Migrate to new OAuth mechanism |
83 | 90 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
84 | 91 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
85 | 92 | AWS_DEFAULT_REGION: eu-west-1 |
86 | 93 | AWS_DEFAULT_OUTPUT: json |
87 | | - - name: Setup doc deploy |
| 94 | + |
| 95 | + docs: |
| 96 | + needs: release |
| 97 | + runs-on: ubuntu-latest |
| 98 | + env: |
| 99 | + RELEASE_VERSION: ${{ needs.release.outputs.RELEASE_VERSION }} |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@v3 |
| 102 | + with: |
| 103 | + fetch-depth: 0 |
| 104 | + - name: Setup git client |
88 | 105 | run: | |
89 | | - git config --global user.name Docs deploy |
90 | | - |
| 106 | + git config user.name "Release bot" |
| 107 | + |
91 | 108 | - name: Build docs website and API reference |
92 | 109 | run: | |
93 | | - make release-docs VERSION=${RELEASE_TAG_VERSION} ALIAS="latest" |
| 110 | + make release-docs VERSION=${RELEASE_VERSION} ALIAS="latest" |
94 | 111 | poetry run mike set-default --push latest |
95 | 112 | - name: Release API docs to release version |
96 | 113 | uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0 |
97 | 114 | with: |
98 | 115 | github_token: ${{ secrets.GITHUB_TOKEN }} |
99 | 116 | publish_dir: ./api |
100 | 117 | keep_files: true |
101 | | - destination_dir: ${{ env.RELEASE_TAG_VERSION }}/api |
| 118 | + destination_dir: ${{ env.RELEASE_VERSION }}/api |
102 | 119 | - name: Release API docs to latest |
103 | 120 | uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0 |
104 | 121 | with: |
105 | 122 | github_token: ${{ secrets.GITHUB_TOKEN }} |
106 | 123 | publish_dir: ./api |
107 | 124 | keep_files: true |
108 | 125 | destination_dir: latest/api |
| 126 | + |
| 127 | + post_release: |
| 128 | + needs: release |
| 129 | + runs-on: ubuntu-latest |
| 130 | + env: |
| 131 | + RELEASE_VERSION: ${{ needs.release.outputs.RELEASE_VERSION }} |
| 132 | + steps: |
| 133 | + - uses: actions/checkout@v3 |
109 | 134 | - name: Close issues related to this release |
110 | 135 | uses: actions/github-script@v6 |
111 | 136 | with: |
| 137 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
112 | 138 | script: | |
113 | 139 | const post_release = require('.github/scripts/post_release.js') |
114 | 140 | await post_release({github, context, core}) |