Skip to content

Commit 4bd566f

Browse files
authored
Adding a download step for getting the official wheels for releases. (#91)
* Adding a download step for getting the official wheels for releases. * Moving release steps into it's own module and removing unused imports in setup. * Updating default action. * Adding new line for flake. * Moving all release related steps to release.py * Update release guide. * Fixing format of release guide. * Adding table of contents.
1 parent beeb296 commit 4bd566f

File tree

4 files changed

+241
-136
lines changed

4 files changed

+241
-136
lines changed

build.py

Lines changed: 1 addition & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
from __future__ import print_function
2-
from azure.storage.blob import BlockBlobService, ContentSettings
32
import os
43
import sys
54
import utility
65
import mssqlcli.mssqltoolsservice.externals as mssqltoolsservice
76

8-
AZURE_STORAGE_CONNECTION_STRING = os.environ.get(
9-
'AZURE_STORAGE_CONNECTION_STRING')
10-
BLOB_CONTAINER_NAME = 'daily'
11-
UPLOADED_PACKAGE_LINKS = []
12-
13-
supported_platforms = [
14-
'win32',
15-
'win_amd64',
16-
'macosx_10_11_intel',
17-
'manylinux1_x86_64']
18-
197

208
def print_heading(heading, f=None):
219
print('{0}\n{1}\n{0}'.format('=' * len(heading), heading), file=f)
@@ -82,53 +70,6 @@ def build():
8270
clean_and_copy_sqltoolsservice(utility.get_current_platform())
8371

8472

85-
def _upload_index_file(service, blob_name, title, links):
86-
print('Uploading index file {}'.format(blob_name))
87-
service.create_blob_from_text(
88-
container_name=BLOB_CONTAINER_NAME,
89-
blob_name=blob_name,
90-
text="<html><head><title>{0}</title></head><body><h1>{0}</h1>{1}</body></html>"
91-
.format(title, '\n'.join(
92-
['<a href="{0}">{0}</a><br/>'.format(link) for link in links])),
93-
content_settings=ContentSettings(
94-
content_type='text/html',
95-
content_disposition=None,
96-
content_encoding=None,
97-
content_language=None,
98-
content_md5=None,
99-
cache_control=None
100-
)
101-
)
102-
103-
104-
def _gen_pkg_index_html(service, pkg_name):
105-
links = []
106-
index_file_name = pkg_name + '/'
107-
for blob in list(service.list_blobs(
108-
BLOB_CONTAINER_NAME, prefix=index_file_name)):
109-
if blob.name == index_file_name:
110-
# Exclude the index file from being added to the list
111-
continue
112-
links.append(blob.name.replace(index_file_name, ''))
113-
_upload_index_file(
114-
service,
115-
index_file_name,
116-
'Links for {}'.format(pkg_name),
117-
links)
118-
UPLOADED_PACKAGE_LINKS.append(index_file_name)
119-
120-
121-
def _upload_package(service, file_path, pkg_name):
122-
print('Uploading {}'.format(file_path))
123-
file_name = os.path.basename(file_path)
124-
blob_name = '{}/{}'.format(pkg_name, file_name)
125-
service.create_blob_from_path(
126-
container_name=BLOB_CONTAINER_NAME,
127-
blob_name=blob_name,
128-
file_path=file_path
129-
)
130-
131-
13273
def validate_package():
13374
"""
13475
Install mssql-cli package locally.
@@ -149,44 +90,6 @@ def validate_package():
14990
)
15091

15192

152-
def publish_daily():
153-
"""
154-
Publish mssql-cli package to daily storage account.
155-
"""
156-
print('Publishing to daily container within storage account.')
157-
assert AZURE_STORAGE_CONNECTION_STRING, 'Set AZURE_STORAGE_CONNECTION_STRING environment variable'
158-
159-
blob_service = BlockBlobService(
160-
connection_string=AZURE_STORAGE_CONNECTION_STRING)
161-
162-
print_heading('Uploading packages to blob storage ')
163-
for pkg in os.listdir(utility.MSSQLCLI_DIST_DIRECTORY):
164-
pkg_path = os.path.join(utility.MSSQLCLI_DIST_DIRECTORY, pkg)
165-
print('Uploading package {}'.format(pkg_path))
166-
_upload_package(blob_service, pkg_path, 'mssql-cli')
167-
168-
_gen_pkg_index_html(blob_service, 'mssql-cli')
169-
_upload_index_file(
170-
blob_service,
171-
'index.html',
172-
'Simple Index',
173-
UPLOADED_PACKAGE_LINKS)
174-
175-
176-
def publish_official():
177-
"""
178-
Publish mssql-cli package to PyPi.
179-
"""
180-
mssqlcli_wheel_dir = os.listdir(utility.MSSQLCLI_DIST_DIRECTORY)
181-
# Run twine action for mssql-cli.
182-
# Only authorized users with credentials will be able to upload this package.
183-
# Credentials will be stored in a .pypirc file.
184-
for wheel in mssqlcli_wheel_dir:
185-
utility.exec_command(
186-
'twine upload {}'.format(wheel),
187-
utility.MSSQLCLI_DIST_DIRECTORY)
188-
189-
19093
def unit_test():
19194
"""
19295
Run all unit tests.
@@ -225,9 +128,7 @@ def test():
225128
'validate_package': validate_package,
226129
'unit_test': unit_test,
227130
'integration_test': integration_test,
228-
'test': test,
229-
'publish_daily': publish_daily,
230-
'publish_official': publish_official
131+
'test': test
231132
}
232133
actions = sys.argv[1:] or default_actions
233134

doc/release_guide.md

Lines changed: 90 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
PYPI Test mssql-cli upload
1+
mssql-cli release guide
22
========================================
3-
4-
### Requirements:
3+
## Table of Contents
4+
1. [Requirements](#Requirements)
5+
2. [Version bump](#BumpVersion)
6+
2. [Local builds](#Local)
7+
3. [Daily builds](#Daily)
8+
4. [Official builds](#Official)
9+
10+
### <a name="Requirements"></a> Requirements:
511
1. Add `<clone_root>` to your PYTHONPATH environment variable:
612
##### Windows
713
```
@@ -15,9 +21,23 @@ PYPI Test mssql-cli upload
1521
```
1622
python <clone_root>/dev_setup.py
1723
```
24+
### Requirements for daily and official builds:
25+
1. A azure storage account with a container named **daily**.
1826
27+
2. A sub folder named **mssql-cli** under the previous container.
1928
20-
## Bump Version
29+
3. Set Azure storage account connection string via environment variable, this will be the storage account we are publishing to.
30+
#### Windows
31+
```
32+
set AZURE_STORAGE_CONNECTION_STRING=<connection string>
33+
```
34+
35+
#### MacOS/Linux
36+
```
37+
export AZURE_STORAGE_CONNECTION_STRING='<connection_string>'
38+
```
39+
40+
## <a name="BumpVersion"></a>Bump Version
2141
2242
Versioning schema: {major}.{minor}.{patch}
2343
Example: 1.0.0
@@ -30,15 +50,45 @@ bumpversion patch              -> 1.0.<b>1</b>
3050
</pre>
3151
3252
**Note**: bumpversion does not allow version bumping if your workspace has pending changes.This is to protect against any manual updates that may have been made which can lead to inconsistent versions across files. If you know what you are doing you can override this by appending `--allow-dirty` to the bumpversion command.
33-
34-
## Build
35-
1. Build mssql-cli wheel:
3653
54+
# <a name="Local"></a>Local builds
55+
The steps below outline how to build mssql-cli locally on your dev environment.
56+
## 1. Build
57+
1. Build mssql-cli wheel for the current platform:
3758
```
3859
Python build.by build
3960
```
4061
41-
2. Add a .pypirc configuration file:
62+
## 2. Install
63+
1. Test install locally:
64+
65+
To install the local mssql-scripter wheel package, from `<clone_root>` execute:
66+
```
67+
sudo pip install --no-index -i ./dist/mssql_scripter-1.0.0a1-py2.py3-none-win32.whl
68+
```
69+
70+
# <a name="Daily"></a>Daily builds
71+
The steps below outline how daily builds of mssql-cli are generated. These steps are ran on each supported platform via Visual Studio Team Services.
72+
## 1. Build
73+
1. Build mssql-cli:
74+
```
75+
python build.py build
76+
```
77+
78+
2. Publish build to daily storage account:
79+
```
80+
python build.py publish_daily
81+
```
82+
## 2. Install
83+
3. Test install from daily storage account:
84+
```
85+
pip install --pre --no-cache --extra-index-url https://mssqlcli.blob.core.windows.net/daily mssql-cli
86+
```
87+
88+
# <a name="Official"></a>Official builds
89+
The steps below outline how to build official builds and publish to PYPI.
90+
## 1. Create a .pypirc configuration file
91+
1. Add a .pypirc configuration file:
4292
4393
- Create a .pypirc file in your user directory:
4494
#### Windows:
@@ -48,37 +98,43 @@ bumpversion patch              -> 1.0.<b>1</b>
4898
4999
- Add the following content to the .pypirc file, replace `your_username` and `your_passsword` with your account information created from step 1:
50100
```
51-
[distutils]
52-
index-servers=
53-
    pypitest
54-
 
55-
[pypitest]
56-
repository = https://test.pypi.org/legacy/
57-
username = your_username
58-
password = your_password
101+
[distutils]
102+
index-servers=
103+
pypi
104+
105+
[pypi]
106+
username = sqlcli
107+
password = <Get Password from Azure Key Vault>
108+
59109
```
60-
4. Publish to Azure storage account
110+
2. Set env var to indicate a official build:
111+
#### Windows
61112
```
62-
python build.py publish_daily
113+
set MSSQL_CLI_OFFICIAL_BUILD=True
63114
```
64-
65-
5. Test install locally
66-
67-
To install the local mssql-scripter wheel package, from `<clone_root>` execute:
115+
116+
#### MacOS/Linux
68117
```
69-
sudo pip install --no-index -i ./dist/mssql_scripter-1.0.0a1-py2.py3-none-win32.whl
118+
export MSSQL_CLI_OFFICIAL_BUILD=True
70119
```
71-
72-
6. Test install via pypi server:
73-
74-
**Note**: Specifying the test pypi server as the index to search for, pip will attempt to search for mssql-scripter's dependencies from the same server. This can result in a requirement not found error, but should not be a problem if dev_setup.py was ran during developer setup. If the error does occur, manually pip install the dependencies that are listed in setup.py and ensure the versions are correct.
75-
76-
Install the mssql-scripter package that was just uploaded:
120+
3. Build for the current platform:
121+
```
122+
python build.py build
77123
```
78-
pip install -i https://testpypi.python.org/pypi mssql-scripter
79-
```
80124
81-
Upgrade to the mssql-scripter that was uploaded:
82-
```
83-
pip install --upgrade -i https://testpypi.python.org/pypi mssql-scripter
125+
4. Publish to daily storage account:
126+
```
127+
python build.py publish_daily
128+
```
129+
130+
5. Download official wheels from storage account:
131+
```
132+
python release.py download_official_wheels
84133
```
134+
135+
6. Publish downloaded wheels to PYPI:
136+
```
137+
python release.py publish_official
138+
```
139+
140+

0 commit comments

Comments
 (0)