forked from getmoto/moto
-
Notifications
You must be signed in to change notification settings - Fork 40
Decouple sync and release actions #84
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
Merged
+167
−93
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7f6d107
Decouple sync and release actions
viren-nadkarni a6324fe
Use action to guess new version
viren-nadkarni a96d413
Fail workflow if there are no commits since the previous tag
viren-nadkarni 4e623d8
Rework condition into a prereq job
viren-nadkarni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Member
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: Might make sense to rename the workflows a bit. They don't have much to do with Continuous Integration anymore I guess 😅 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| # LocalStack specific workflow to implement a fully-integrated continuous integration pipeline for Moto-Ext | ||
| # - Guess next patch semantic version | ||
| # - Build source and wheel distributions | ||
| # - Publish the distributions to PyPi | ||
| # - Tag the commit with the new version | ||
| # - Create a GitHub release for the new version | ||
|
|
||
| name: Release moto-ext | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: 0 5 * * MON | ||
alexrashed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: 'Dry run' | ||
| default: true | ||
| required: true | ||
| type: boolean | ||
|
|
||
| # Limit concurrency to 1 | ||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
|
|
||
| jobs: | ||
| analyse-commit-log: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| is-release-required: ${{ steps.check.outputs.new_commits_made }} | ||
| last-tag: ${{ steps.last_tag.outputs.tag }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: localstack | ||
| persist-credentials: false | ||
|
|
||
| - name: Get last tag | ||
| id: last_tag | ||
| uses: "WyriHaximus/github-action-get-previous-tag@v1" | ||
| env: | ||
| GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
|
|
||
| - name: Check for new commits since the last tag | ||
| id: check | ||
| env: | ||
| LAST_TAG: ${{ steps.last_tag.outputs.tag }} | ||
| run: | | ||
| if [ $(git log --oneline $LAST_TAG..HEAD | wc -l) -eq "0" ]; then | ||
| echo "No commits since the last tag." | ||
| echo "new_commits_made=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "new_commits_made=true" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| build-release-moto-ext: | ||
| runs-on: ubuntu-latest | ||
| needs: analyse-commit-log | ||
| if: ${{ needs.analyse-commit-log.outputs.is-release-required == 'true' }} | ||
| environment: | ||
| name: pypi | ||
| url: https://pypi.org/project/moto-ext/ | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: localstack | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.13' | ||
|
|
||
| - name: Guess next version | ||
| id: semver | ||
| uses: "WyriHaximus/github-action-next-semvers@v1" | ||
| with: | ||
| version: ${{ needs.analyse-commit-log.outputs.last-tag }} | ||
|
|
||
| - name: Ensure guessed version does not exist | ||
| env: | ||
| NEW_VERSION: ${{ steps.semver.outputs.patch }} | ||
| run: | | ||
| ! git rev-parse $NEW_VERSION || { echo "A tag for $NEW_VERSION already exists" ; exit 1; } | ||
|
|
||
| - name: Build Python distributions | ||
| env: | ||
| NEW_VERSION: ${{ steps.semver.outputs.patch }} | ||
| # FYI: Checks in this script only work because the -e flag is enabled by default in GitHub actions | ||
| run: | | ||
| python3 -m pip install build | ||
|
|
||
| # make sure setup.cfg is not dirty yet | ||
| git diff --exit-code setup.cfg | ||
|
|
||
| echo "Setting new version in setup.cfg": | ||
| sed -i -E 's/^(version\s*=\s*)("?)[^"]+("?)/\1\2'"$NEW_VERSION"'\3/' setup.cfg | ||
|
|
||
| # make sure setup.cfg is dirty now | ||
| ! git diff --exit-code setup.cfg | ||
|
|
||
| echo "Building distributions" | ||
| python3 -m build | ||
|
|
||
| - name: Create and push tag | ||
| env: | ||
| NEW_VERSION: ${{ steps.semver.outputs.patch }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| if: ${{ github.event.inputs.dry_run != 'true' }} | ||
| run: | | ||
| git tag -a $NEW_VERSION -m $NEW_VERSION | ||
| git push --tags origin localstack | ||
|
|
||
| - name: Clean up | ||
| run: | | ||
| git reset --hard | ||
| git clean -df | ||
|
|
||
| - name: Upload distributions | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: moto-ext-dists | ||
| path: dist/*.* | ||
|
|
||
| # publish the package before pushing the tag (this might fail if the version already exists on PyPI) | ||
| - name: Publish package distributions to PyPI | ||
| if: ${{ github.event.inputs.dry_run != 'true' }} | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
|
||
| # Add a retry to avoid issues where the GH CLI fails because it does not yet detect the pushed tag. | ||
| - name: Create Release | ||
| uses: nick-fields/retry@v3 | ||
| if: ${{ github.event.inputs.dry_run != 'true' }} | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| max_attempts: 5 | ||
| retry_wait_seconds: 120 | ||
| timeout_minutes: 5 | ||
| command: gh release create $NEW_VERSION --repo localstack/moto --notes "automatic release" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
question: Does it make sense to even keep this pipeline? You mentioned in the description that there is no plan to sync the fork with upstream anymore? If this is the case, I guess we could just remove this part / this workflow?
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.
We seem to need another bump (see #sig-moto) so I'd like to keep it for a while.
I'll make a separate PR in the future which cleans up this and other unused workflows from upstream.
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.
Okay, sounds good! As a nitpick on the side I would in this case also opt for renaming this workflow as well 😛