moto/.github/workflows/release.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
3.8 KiB
YAML
Raw Normal View History

name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
2023-11-17 22:18:33 +00:00
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
2023-09-02 21:11:07 +00:00
permissions:
contents: write
2023-11-10 22:44:59 +00:00
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
2023-08-23 09:28:44 +00:00
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
2023-11-17 22:18:33 +00:00
if: ${{ inputs.current_release }}
run: |
docker build -t motoserver/moto . --tag moto:${{ env.VERSION }}
- name: Test Docker release
2023-11-17 22:18:33 +00:00
if: ${{ inputs.current_release }}
run: |
docker run -p 5000:5000 --name moto motoserver/moto &
2023-08-23 09:39:23 +00:00
TEST_SERVER_MODE=true pytest -sv tests/test_core tests/test_s3/test_s3.py
docker stop moto
- name: Publish to PyPI
2022-08-25 19:03:30 +00:00
uses: pypa/gh-action-pypi-publish@release/v1
- name: Tag version on Github
run: |
git tag ${{ env.VERSION }}
git push origin ${{ env.VERSION }}
2023-09-02 21:11:07 +00:00
- name: Create GitHub release
uses: softprops/action-gh-release@v2
2023-09-02 21:11:07 +00:00
with:
2023-09-02 21:25:26 +00:00
name: ${{ env.VERSION }}
tag_name: ${{ env.VERSION }}
2023-09-02 21:11:07 +00:00
files: dist/*
2022-02-18 11:54:58 +00:00
# Required to get the correct Digest
# See https://github.com/docker/build-push-action/issues/461
- name: Set up QEMU
2023-11-17 22:18:33 +00:00
if: ${{ inputs.current_release }}
uses: docker/setup-qemu-action@v3
2022-02-18 11:54:58 +00:00
- name: Set up Docker Buildx
2023-11-17 22:18:33 +00:00
if: ${{ inputs.current_release }}
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
2023-11-17 22:18:33 +00:00
if: ${{ inputs.current_release }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR
2023-11-17 22:18:33 +00:00
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
2023-11-17 22:18:33 +00:00
if: ${{ inputs.current_release }}
id: build_and_push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
push: true
tags: |
motoserver/moto:${{ env.VERSION }}
ghcr.io/getmoto/motoserver:${{ env.VERSION }}
- name: Increase patch version number
2023-11-17 22:18:33 +00:00
if: ${{ inputs.current_release }}
run: |
python update_version_from_git.py patch
2022-02-18 11:54:58 +00:00
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 "admin@getmoto.org"
git config --local user.name "Moto Admin"
git add moto/__init__.py
2022-02-18 11:54:58 +00:00
git add CHANGELOG.md
git commit -m "Post-release steps"
git push