Skip to content

Commit 97c6e60

Browse files
authored
One ish click deploy (#197)
* dep fix? * towncrier start * towncrier seems to work * Sample workflow with no real actions * more release * some more towncrier * more release * Fix borked link * fix version blerp https://github.com/saltstack/salt-ext-modules-vmware/runs/4988078936?check_suite_focus=true looks like installing importlib on an earlier version is no good. Also we're double-appending tests so... let's try this! * Better version This should work better - at least from what we had for docs
1 parent 903d954 commit 97c6e60

6 files changed

Lines changed: 556 additions & 120 deletions

File tree

changelog/.gitkeep

Whitespace-only changes.

docs/release.rst

Lines changed: 92 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Release
44
=======
55

66
The purpose of this document is to specify and outline the release process for
7-
the Salt Extension Modules for VMware. Initially for the beta releases, many of
8-
these steps will be manual. Over time the process will become more automated.
7+
the Salt Extension Modules for VMware. Previously many of the steps were
8+
manual, but the process is now mostly automatic.
99

1010
Overview
1111
--------
@@ -20,89 +20,37 @@ It's possible that days go by without changes happening, but these builds will
2020
still be called nightly builds.
2121

2222
The release cadence target for this module is every two weeks a release may be
23-
published. A release candidate (rcN) package will be published a week ahead of
24-
the release, allowing users time to test the upcoming packages against their
23+
published. A release candidate (rcN) package should be published a week ahead
24+
of the release, allowing users time to test the upcoming packages against their
2525
own environment.
2626

2727
Automated testing will happen against release artifacts, using at least the
2828
current version of Salt, along with the current main development branch of
29-
Salt. This will ensure that any breaking changes within Salt are detected
30-
ahead of time, and can either be accounted for within this module, or upstream
31-
bugs can be filed.
29+
Salt. This will ensure that any breaking changes within Salt are detected ahead
30+
of time, and can either be accounted for within this module, or upstream bugs
31+
can be filed.
3232

33-
.. _build:
33+
.. _dependencies:
3434

35-
Build
36-
-----
35+
Dependencies
36+
------------
3737

38-
To prepare for a release, the first step is to ensure you're on the latest
39-
commit on the main branch and build the release artifact, along with
40-
dependencies:
38+
In order to run the release script, you'll need to have gpg installed with
39+
gpg-agent. If you can run the following gpg command without having to type
40+
anything in you should be good to go:
4141

4242
.. code::
4343
44-
git fetch salt
45-
git stash # if needed
46-
git checkout salt/main
47-
# If pip and wheel are not already installed/up-to-date
48-
python -m pip install --upgrade pip wheel
49-
python -m pip wheel .\[dev,tests,release\] -w dist/
44+
echo 'hello' | gpg --armor --clear-sign | gpg --verify
5045
51-
This will create a ``.whl`` file for the extension module, as well as all of
52-
the dependencies, in the ``dist/`` directory.
46+
Obviously you'll need Python installed as well, and be able to run ``git push``
47+
in your clone directory without `entering a
48+
password <https://docs.github.com/en/authentication/connecting-to-github-with-ssh>`_.
49+
``tar`` is also required.
5350

54-
55-
Ensure Version
56-
--------------
57-
58-
When it comes time to build a release, ensure that
59-
``src/saltext/vmware/version.py`` contains the correct version. For an release
60-
candidate (RC) release the format should be ``YY.M.D.PATCHrcN``. Any subsequent RC
61-
releases should increment ``N``. The release manager should start cutting RCs
62-
far enough ahead of time to be able to cut a complete release on the target
63-
date. For a production release, the format should be ``YY.M.D.PATCH``. For
64-
instance, if we were going to release on 2010-08-14, we would start with
65-
66-
.. code::
67-
68-
__version__ = '10.8.14.0rc1'
69-
70-
When the release is deemed ready, the version would be ``10.8.14.0``.
71-
72-
If the incorrect version is present in the ``main`` branch, it should be
73-
updated, committed, and pushed before continuing this process.
74-
75-
Commit ``src/saltext/vmware/version.py``, rebuild and continue testing. Do **not** merge into https://github.com/saltstack/salt-ext-modules-vmware/.
76-
77-
Install and Test the Build
78-
--------------------------
79-
80-
To ensure that the virtual environment is pristine, create a new one. Then the
81-
package and necessary dependencies can be installed into the environment. By
82-
building the extension and dependencies locally, and using a pristine
83-
environment, this will help ensure that any missing dependencies are detected
84-
before release. Tests will be executed against the installed package, and not
85-
the local source, which helps to ensure the complete install process is tested.
86-
87-
.. code::
88-
89-
deactivate # if a venv is already activated
90-
python3 -m venv /tmp/test_saltext --prompt test-vmw-ext
91-
source /tmp/test_saltext/bin/activate
92-
python -m pip install --upgrade pip wheel
93-
python -m pip install --no-index --find-links dist/ saltext.vmware\[dev,tests,release\]
94-
pytest --cov=saltext.vmware tests/
95-
96-
This will run tests against the build artifact. If all tests pass this nightly
97-
build may be released.
98-
99-
The release process be tested by using Twine with the TestPyPI_
100-
101-
.. _TestPyPI: https://test.pypi.org/project/saltext.vmware/
102-
103-
In order to cut a release, you must be a project maintainer on TestPyPI and
104-
have a token configured for the project. Your ``~/.pypirc`` should contain your
105-
key like the following:
51+
In order to cut a release, you must be a project maintainer on TestPyPI as well
52+
as PyPI. You'll need to have a token configured for the project. Your
53+
``~/.pypirc`` should contain your key like the following:
10654

10755
.. code::
10856
@@ -115,78 +63,103 @@ key like the following:
11563
username = __token__
11664
password = pypi-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
11765
118-
Then you would run:
66+
You *must* have ``test_saltext_vmware`` and ``saltext_vmware`` sections in your
67+
distutils segment as well as have tokens configured.
68+
69+
.. _prebuild:
70+
71+
Pre-Build
72+
---------
73+
74+
Before running the script you'll want to ensure that all the tests are passing.
75+
With your activated venv, run the following command:
11976

12077
.. code::
12178
122-
twine upload --repository test_saltext_vmware dist/saltext.vmware-VERSION-py2.py3-none-any.whl
79+
python -m nox -e tests-3
12380
124-
Merge the Version Update into the Main Repo
125-
-------------------------------------------
81+
The result should be completely passing tests. If there are any failures,
82+
ensure that they are fixed before continuing. Because the only difference
83+
between this version and the actual deployed version will be the package
84+
version, we're banking on the fact that the tests should still pass if they
85+
already were here. But we *will* be testing the release artifact!
12686

127-
Now that the build has been tested and verified, create a merge request with the new ``__version__`` to https://github.com/saltstack/salt-ext-modules-vmware/.
87+
Ensure Version
88+
--------------
12889

129-
With the new version committed, go back and :ref:`build a new artifact<build>`.
90+
The first thing to do is ensure that ``src/saltext/vmware/version.py`` has the
91+
correct version for this release. In regards to version numbers, this project
92+
uses Calver_, with the ``YY.M.D.PATCH`` style. Breaking (and any other) changes
93+
should be communicated through the changelog_. Release candidate versions
94+
should be created with the **expected** release date with ``rcN`` modifier. For
95+
instance, if we planned to release 2010, August 14, we would set the version
96+
like so:
13097

131-
Versions, Tagging, and Changelog
132-
--------------------------------
98+
.. code::
13399
134-
In order to cut a release, you must be a maintainer of this project on PyPI.
135-
You should have a ``[saltext_vmware]`` section in your pypirc file, similar to
136-
the test setting.
100+
__version__ = "10.8.14rc1"
137101
138-
In regards to version numbers, this project uses Calver_, with the
139-
``YY.M.D.PATCH`` style. Breaking (and any other) changes should be
140-
communicated through the changelog_.
102+
Typically there will only be one RC build - though if bugs are found,
103+
especially severe bugs, new RC versions will be built, tagged, and released.
141104

142105
.. _CalVer: https://calver.org/
143106
.. _changelog: https://github.com/saltstack/salt-ext-modules-vmware/blob/main/CHANGELOG.md
144107

145-
For dev/nightly builds, tags will ONLY be used if the package gets uploaded to
146-
the production PyPI. At that point an annotated tag should be created with the
147-
current changelog for that particular version.
108+
The changelog will be automatically updated as part of this release process,
109+
but if corrections need to be made it's totally fine to make updates out of
110+
band.
111+
112+
Run the Release
113+
---------------
148114

149-
Release candidate builds will be tagged with the **expected** release date with
150-
``rcN`` modifier. For instance, if we planned to release 2010, August 14, we would tag like so:
115+
Assuming that your environment is properly configured, all you should need to
116+
do now is run:
151117

152118
.. code::
153119
154-
git tag 10.8.14rc1 -a
120+
python tools/release.py
155121
156-
Typically there will only be one RC build - though if bugs
157-
are found, especially severe bugs, new RC versions will be built, tagged, and
158-
released.
122+
The script will do several checks, ensuring that you have no outstanding
123+
changes in the repo, it can correctly run gpg, and that you're not running
124+
within a virtual environment (as it takes care of that for you).
159125

160-
To cut a final release, the repository will be tagged as above, the changelog
161-
added to the tag, and then a new package will be built, installed, and tested.
162-
This order is required because we use setuptools_scm to generate the version
163-
number from the latest tag. Tagging does not produce any code changes (other
164-
than the version number), so the tests should continue to pass. If they fail
165-
for any reason other than your Internet going out, this should be considered a
166-
critical issue! Flaky tests are undesirable, since they are often just
167-
misleading. If a test scenario is that flaky, it should be performed manually,
168-
or not at all.
126+
After running the checks, which shouldn't really make any serious changes to
127+
your system, you will be asked:
169128

170-
..
171-
That flaky bit could be a in a different document, and linked to from here.
129+
.. code::
172130
173-
Once the full test suite has passed, sign the production package with gpg and
174-
upload the package with twine:
131+
Continue to build and test saltext.vmware version 21.12.15.0rc1? [y/N]: y
175132
176-
.. code::
133+
The default is no. If you answer ``yes`` or ``y``, then a virtual environment
134+
will be created for testing the release, the package will be built, installed
135+
to the virtual environment, and then tested.
177136

178-
# SIGNING_KEY should be replaced with the signing key, and FINAL-VERSION
179-
# with the actual version number
180-
gpg --detach-sign -u SIGNING_KEY dist/saltext.vmware-FINAL-VERSION-py2.py3.none-any.whl
181-
twine upload --repository saltext_vmware dist/saltext.vmware-FINAL-VERSION-py2.py3.none-any.whl
137+
If anything fails up to this point then the release will bail out and you'll
138+
need to make changes.
182139

183-
Once the package has been uploaded to PyPI the tag should be pushed:
140+
If everything succeeds, and all looks OK then you will be given one last chance
141+
to bail out before pushing changes to PyPI and GitHub.
184142

185143
.. code::
186144
187-
git push salt 10.8.14 # to use the previous example
188-
189-
A release should also be created on GitHub, uploading both the package as well
190-
as the `.sig` file.
145+
WARNING: This will really upload saltext.vmware version 21.12.15.0rc1 to
146+
pypi. There is no going back from this point.
147+
Enter "deploy" without quotes to really deploy: deploy
148+
149+
If you enter anything besides ``deploy`` then the release will abort. Basically
150+
we want to be *very* sure that we're ready to release! If you are, cool - just
151+
type ``deploy`` and hit enter.
152+
153+
The release will then be pushed to
154+
https://test.pypi.org/project/saltext.vmware/ and
155+
https://pypi.org/project/saltext.vmware/ after the successful completion of
156+
which, the tag will be created and pushed to GitHub, suitable for `drafting a
157+
new
158+
release <https://github.com/saltstack/salt-ext-modules-vmware/releases/new>`_.
159+
160+
The finally part of the release script will create
161+
``/tmp/saltext.vmware-build-{version}.tar.gz`` that you can use to get the
162+
changelog, ``.whl``, and ``.whl.asc`` signature file to use for creating the
163+
GitHub release, as well as publishing notifications to social media/websites.
191164

192165
Congrats! You've just cut a new release!

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _install_requirements(
9595
if install_salt:
9696
session.install("--progress-bar=off", SALT_REQUIREMENT, silent=PIP_INSTALL_SILENT)
9797

98-
if install_test_requirements:
98+
if install_test_requirements and "tests" not in install_extras:
9999
install_extras.append("tests")
100100

101101
if EXTRA_REQUIREMENTS_INSTALL:

pyproject.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,41 @@ build-backend = "setuptools.build_meta"
44

55
[tool.black]
66
line-length = 100
7+
8+
[tool.towncrier]
9+
name = "saltext.vmware"
10+
title_format = "{name} {version}"
11+
package = "saltext.vmware"
12+
filename = "CHANGELOG.md"
13+
directory = "changelog/"
14+
start_string = "# Changelog\n"
15+
16+
[[tool.towncrier.type]]
17+
directory = "removed"
18+
name = "Removed"
19+
showcontent = true
20+
21+
[[tool.towncrier.type]]
22+
directory = "deprecated"
23+
name = "Deprecated"
24+
showcontent = true
25+
26+
[[tool.towncrier.type]]
27+
directory = "changed"
28+
name = "Changed"
29+
showcontent = true
30+
31+
[[tool.towncrier.type]]
32+
directory = "fixed"
33+
name = "Fixed"
34+
showcontent = true
35+
36+
[[tool.towncrier.type]]
37+
directory = "added"
38+
name = "Added"
39+
showcontent = true
40+
41+
[[tool.towncrier.type]]
42+
directory = "security"
43+
name = "Security"
44+
showcontent = true

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ setup_requires =
4242
install_requires =
4343
salt>=3002
4444
pyvmomi==7.0.2
45+
importlib_metadata; python_version < "3.8"
4546

4647
[options.extras_require]
4748
tests =
@@ -50,15 +51,18 @@ tests =
5051
pytest-salt-factories>=0.121.1
5152
dev =
5253
nox
54+
towncrier==21.9.0rc1
5355
release =
5456
twine
5557
wheel
58+
towncrier==21.9.0rc1
5659
docs =
5760
sphinx
5861
furo
5962
sphinx-prompt
6063
sphinxcontrib-spelling
6164
importlib_metadata; python_version < "3.8"
65+
towncrier==21.9.0rc1
6266

6367

6468
[options.packages.find]

0 commit comments

Comments
 (0)