-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (127 loc) · 4.81 KB
/
Copy pathdeploy.yml
File metadata and controls
146 lines (127 loc) · 4.81 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
name: Build and Deploy JaSketch
on:
release:
types: [published]
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
publish-mcp:
if: startsWith(github.ref, 'refs/tags/jasketch-') || startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
published: ${{ steps.publish.outputs.published }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: pip install build twine requests
- name: Check if MCP version needs publishing
id: check
working-directory: mcp-server
run: |
LOCAL=$(python -c "import tomllib; f=open('pyproject.toml','rb'); d=tomllib.load(f); print(d['project']['version'])")
PUBLISHED=$(python -c "
import urllib.request, json
try:
r = urllib.request.urlopen('https://pypi.org/pypi/jasketch-mcp-server/json')
print(json.loads(r.read())['info']['version'])
except:
print('none')
")
echo "Local: $LOCAL | Published: $PUBLISHED"
if [ "$LOCAL" != "$PUBLISHED" ]; then
echo "needs_publish=true" >> $GITHUB_OUTPUT
else
echo "needs_publish=false" >> $GITHUB_OUTPUT
fi
- name: Build package
if: steps.check.outputs.needs_publish == 'true'
working-directory: mcp-server
run: python -m build
- name: Publish to PyPI
id: publish
if: steps.check.outputs.needs_publish == 'true'
working-directory: mcp-server
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*
echo "published=true" >> $GITHUB_OUTPUT
deploy-jasketch:
needs: [publish-mcp]
if: startsWith(github.ref, 'refs/tags/jasketch-') || startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.2.0
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::776241927220:role/GitHubActionsSharedECRRole
role-session-name: GitHubActions
audience: sts.amazonaws.com
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Get tag name
id: tag
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAG="manual-$(date +%Y%m%d-%H%M%S)"
elif [[ "${{ github.event_name }}" == "release" ]]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
if [[ $TAG_NAME =~ ^jasketch-(.+)$ ]]; then
TAG="${BASH_REMATCH[1]}"
elif [[ $TAG_NAME =~ ^v(.+)$ ]]; then
TAG="$TAG_NAME"
else
TAG="$TAG_NAME"
fi
else
TAG="latest"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Build and push Docker image
env:
ECR_REGISTRY: 776241927220.dkr.ecr.us-east-2.amazonaws.com
ECR_REPOSITORY: jasketch
IMAGE_TAG: ${{ steps.tag.outputs.tag }}
run: |
docker buildx build \
--platform linux/amd64 \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
-t $ECR_REGISTRY/$ECR_REPOSITORY:latest \
--push \
.
summary:
needs: [publish-mcp, deploy-jasketch]
runs-on: ubuntu-latest
if: always()
steps:
- name: Summary
run: |
echo "## JaSketch Release Summary" >> $GITHUB_STEP_SUMMARY
echo "- **MCP PyPI Published**: ${{ needs.publish-mcp.outputs.published || 'skipped (already up to date)' }}" >> $GITHUB_STEP_SUMMARY
echo "- **Image Tag**: ${{ needs.deploy-jasketch.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **ECR Repository**: 776241927220.dkr.ecr.us-east-2.amazonaws.com/jasketch" >> $GITHUB_STEP_SUMMARY
echo "- **Deploy Status**: ${{ needs.deploy-jasketch.result }}" >> $GITHUB_STEP_SUMMARY
echo "- **Application URL**: https://jasketch.jaseci.org" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Note**: Deployment will be handled automatically by Flux in the infrastructure repository." >> $GITHUB_STEP_SUMMARY