Release #140
This file contains 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
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version' | |
required: true | |
current_release: | |
description: 'True to release Docker and update version info in moto/__init__.py' | |
required: true | |
type: boolean | |
jobs: | |
release-moto-job: | |
runs-on: ubuntu-latest | |
name: Release Moto | |
permissions: | |
contents: write | |
id-token: write | |
packages: write | |
env: | |
VERSION: 0.0.0 | |
steps: | |
- name: Set Env | |
run: | | |
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install wheel setuptools packaging twine build --upgrade | |
pip install -r requirements-dev.txt | |
- name: Verify Tag does not exist | |
run: | | |
! git rev-parse ${{ env.VERSION }} || { echo "Ensure that no tag exists for ${{ env.VERSION }}" ; exit 1; } | |
- name: Verify supplied version exists in the CHANGELOG | |
run: | | |
grep ${{ env.VERSION }} CHANGELOG.md || { echo "Ensure that the CHANGELOG contains an entry for ${{ env.VERSION }}" ; exit 1; } | |
- name: Set version number | |
run: python update_version_from_git.py ${{ env.VERSION }} | |
- name: Build Python | |
run: python -m build | |
- name: Build Docker release | |
if: ${{ inputs.current_release }} | |
run: | | |
docker build -t motoserver/moto . --tag moto:${{ env.VERSION }} | |
- name: Test Docker release | |
if: ${{ inputs.current_release }} | |
run: | | |
docker run -p 5000:5000 --name moto motoserver/moto & | |
TEST_SERVER_MODE=true pytest -sv tests/test_core tests/test_s3/test_s3.py | |
docker stop moto | |
- name: Commit Version Change | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Moto Admin" | |
git add moto/__init__.py | |
git add setup.cfg | |
git commit -m "Pre-Release: Up Version Number" | |
git push | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: Tag version on Github | |
run: | | |
git tag ${{ env.VERSION }} | |
git push origin ${{ env.VERSION }} | |
- name: Create GitHub release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: ${{ env.VERSION }} | |
tag_name: ${{ env.VERSION }} | |
files: dist/* | |
# Required to get the correct Digest | |
# See https://github.com/docker/build-push-action/issues/461 | |
- name: Set up QEMU | |
if: ${{ inputs.current_release }} | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
if: ${{ inputs.current_release }} | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
if: ${{ inputs.current_release }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GHCR | |
if: ${{ inputs.current_release }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push to DockerHub and GHCR | |
if: ${{ inputs.current_release }} | |
id: build_and_push | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
motoserver/moto:${{ env.VERSION }} | |
ghcr.io/getmoto/motoserver:${{ env.VERSION }} | |
- name: Increase patch version number | |
if: ${{ inputs.current_release }} | |
run: | | |
python update_version_from_git.py patch | |
sed -i 's/Docker Digest for ${{ env.VERSION }}: <autopopulateddigest>/Docker Digest for ${{ env.VERSION }}: _${{ steps.build_and_push.outputs.digest }}_/' CHANGELOG.md | |
git config --local user.email "[email protected]" | |
git config --local user.name "Moto Admin" | |
git add moto/__init__.py | |
git add setup.cfg | |
git add CHANGELOG.md | |
git commit -m "Admin: Post-release steps" | |
git push |