-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
125 lines (123 loc) · 4.24 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
current_release:
description: 'Release Docker and update version info in moto/__init__.py'
default: true
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:latest
motoserver/moto:${{ env.VERSION }}
ghcr.io/getmoto/motoserver:latest
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