-
Notifications
You must be signed in to change notification settings - Fork 651
135 lines (115 loc) · 4.45 KB
/
release.yml
File metadata and controls
135 lines (115 loc) · 4.45 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
name: Release Preswald
on:
workflow_dispatch:
inputs:
run_tests:
description: "Run tests"
required: true
default: true
type: boolean
permissions:
contents: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build setuptools wheel twine
pip install -e .
- name: Install bc for version calculations
run: sudo apt-get install -y bc zip
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
install_components: "gsutil"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: "3.12"
- name: Run Release process
run: |
if [ "${{ inputs.run_tests }}" == "true" ]; then
make release
else
# Skip tests by running individual targets
make update-version build-frontend build-wheel build-docker upload-to-gcs upload-static-to-gcs upload-to-pypi
fi
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
PRESWALD_DEPLOYER_DEV_SA: ${{ secrets.PRESWALD_DEPLOYER_DEV_SA }}
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
- name: Upload wheel as artifact
uses: actions/upload-artifact@v4
with:
name: preswald-wheel
path: dist/*.whl
if-no-files-found: error
- name: Get version info
id: get_version
run: echo "VERSION=$(grep 'version' pyproject.toml | grep -v '^#' | head -1 | sed -E 's/.*version = "([^"]+)".*/\1/')" >> $GITHUB_OUTPUT
- name: Configure Git
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Commit version change
run: |
git add pyproject.toml
git commit -m "Release v${{ steps.get_version.outputs.VERSION }}"
git push origin HEAD:main
- name: Create and push tag
run: |
git tag -f v${{ steps.get_version.outputs.VERSION }}
git push origin -f v${{ steps.get_version.outputs.VERSION }}
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
tag_name: v${{ steps.get_version.outputs.VERSION }}
release_name: Release v${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
body: |
## Preswald v${{ steps.get_version.outputs.VERSION }} Release
### Installation
```
pip install preswald==${{ steps.get_version.outputs.VERSION }}
```
- name: Upload wheel to GitHub Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/preswald-${{ steps.get_version.outputs.VERSION }}-py3-none-any.whl
asset_name: preswald-${{ steps.get_version.outputs.VERSION }}-py3-none-any.whl
asset_content_type: application/octet-stream
- name: Summary
run: |
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "- Version: ${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- Wheel: $(ls -t dist/preswald-*.whl | head -1)" >> $GITHUB_STEP_SUMMARY
echo "- Docker Image: structuredlabs/preswald-base:latest" >> $GITHUB_STEP_SUMMARY
echo "- GitHub Release: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY