-
Notifications
You must be signed in to change notification settings - Fork 82
chore(release): 4.0.1 #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| name: release-on-version-change | ||
|
|
||
| # Creates a GitHub Release automatically whenever the package version in | ||
| # awslambdaric/__init__.py changes on main. The release notes are taken from | ||
| # the matching section of RELEASE.CHANGELOG.md. | ||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| paths: | ||
| - 'awslambdaric/__init__.py' | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Read version | ||
| id: version | ||
| run: | | ||
| VERSION="$(grep -Po '__version__\s*=\s*"\K[^"]+' awslambdaric/__init__.py)" | ||
| if [ -z "$VERSION" ]; then | ||
| echo "Could not determine version from awslambdaric/__init__.py" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "Detected version: $VERSION" | ||
|
|
||
| - name: Check if release already exists | ||
| id: check | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the release check lives with reading the version and no need for a separate step for it and we could drop the extra check if version exists or not |
||
| run: | | ||
| if gh release view "$VERSION" >/dev/null 2>&1; then | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Nit-pick): I'd rename it to (release_exists or something like that) |
||
| echo "Release $VERSION already exists; skipping." | ||
| else | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Extract changelog notes | ||
| if: steps.check.outputs.exists == 'false' | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| # Write notes to a file (never interpolated into the shell) so that | ||
| # special characters in the changelog (backticks, parentheses, etc.) | ||
| # are passed verbatim to gh via --notes-file. | ||
| awk -v ver="$VERSION" ' | ||
| index($0, "`" ver "`") == 1 { capture = 1; next } | ||
| capture && /^### / { exit } | ||
| capture { print } | ||
| ' RELEASE.CHANGELOG.md > release-notes.md | ||
| # Trim leading/trailing blank lines. | ||
| sed -i -e '/./,$!d' release-notes.md | ||
| if [ ! -s release-notes.md ]; then | ||
| echo "Release $VERSION" > release-notes.md | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a version bump always means something changed, having the release body be just the version number isn't useful. I'd prefer the workflow to fail here, forcing the contributor to add a changelog entry before the release is created |
||
| fi | ||
| echo "----- release notes -----" | ||
| cat release-notes.md | ||
|
|
||
| - name: Create GitHub Release | ||
| if: steps.check.outputs.exists == 'false' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| gh release create "$VERSION" \ | ||
| --target "$GITHUB_SHA" \ | ||
| --title "AWS Lambda Runtime Interface Client for Python v$VERSION" \ | ||
| --notes-file release-notes.md \ | ||
| --latest | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use sed/aws instead (-Po is not posix)