-
Notifications
You must be signed in to change notification settings - Fork 129
158 lines (137 loc) · 4.5 KB
/
Copy pathrelease-publish.yml
File metadata and controls
158 lines (137 loc) · 4.5 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Release Publish
on:
pull_request:
types: [closed]
branches: [main]
permissions:
contents: write
jobs:
build:
name: Build from Main
if: >
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/v')
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Build and check package
run: |
uv venv
source .venv/bin/activate
uv pip install build twine
uv build
twine check dist/*
- name: Get version
id: version
run: |
VERSION=$(ls dist/*.whl | sed -n 's/.*-\([0-9.]*\)-.*/\1/p')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
release-approval:
name: Release Approval
needs: build
runs-on: ubuntu-latest
environment:
name: pypi-approval
steps:
- name: Approval checkpoint
env:
VERSION: ${{ needs.build.outputs.version }}
run: |
echo "✅ Build successful for v$VERSION"
echo "📦 Package ready for PyPI publication"
echo ""
echo "⚠️ MANUAL APPROVAL REQUIRED"
echo "Verify version and changelog before approving."
publish-pypi:
name: Publish to PyPI
needs: [build, release-approval]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/bedrock-agentcore/
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Verify PyPI token exists
env:
PYPI_TOKEN_SET: ${{ secrets.PYPI_API_TOKEN != '' }}
run: |
if [ "$PYPI_TOKEN_SET" != "true" ]; then
echo "❌ ERROR: PYPI_API_TOKEN not configured!"
exit 1
fi
echo "✓ PyPI token is configured"
- name: Check if version exists on PyPI
env:
VERSION: ${{ needs.build.outputs.version }}
run: |
if pip index versions bedrock-agentcore | grep -q "^Available versions.*$VERSION"; then
echo "❌ ERROR: Version $VERSION already exists on PyPI!"
exit 1
fi
echo "✓ Version $VERSION is not on PyPI, safe to publish"
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: false
verbose: true
- name: Wait for PyPI availability
env:
VERSION: ${{ needs.build.outputs.version }}
run: |
echo "Waiting for package to be available on PyPI..."
for i in {1..10}; do
if pip index versions bedrock-agentcore | grep -q "$VERSION"; then
echo "✓ Package version $VERSION is now available on PyPI"
break
fi
echo "Attempt $i/10: Package not yet available, waiting 30s..."
sleep 30
done
- name: Create and push tag
env:
VERSION: ${{ needs.build.outputs.version }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.build.outputs.version }}
name: Bedrock AgentCore SDK v${{ needs.build.outputs.version }}
files: dist/*
generate_release_notes: true
body: |
## Installation
```bash
pip install bedrock-agentcore==${{ needs.build.outputs.version }}
```
## What's Changed
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/v${{ needs.build.outputs.version }}/CHANGELOG.md) for details.