Skip to content

Commit

Permalink
Merge master into 0.3-include-nonignored
Browse files Browse the repository at this point in the history
  • Loading branch information
jameinel committed Aug 13, 2020
2 parents 09443ad + b69391d commit 55cb3b0
Show file tree
Hide file tree
Showing 14 changed files with 329 additions and 37 deletions.
91 changes: 91 additions & 0 deletions HOWTO_RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Steps

Release early, release often. Don't be lazy.


## Preparation

- update master and run tests

git fetch upstream
git merge upstream/master
source venv/bin/activate
./run_tests

- create a new release branch

git checkout -b release-0.3.0

- create release notes after all main changes from last tag

git log --first-parent master --decorate

- tag the release (using those release notes)

git tag -s 0.3.0


## Check all is ready

- build a tarball to test

rm -rf dist/
./setup.py sdist bdist_wheel

- try the tarball

mkdir /tmp/testrelease
cp dist/charmcraft-0.3.0.tar.gz /tmp/testrelease/
cd /tmp/testrelease/
tar -xf charmcraft-0.3.0.tar.gz
cd ~ # wherever out of the project, to avoid any potential "file mispicking"
fades -v -d file:///tmp/testrelease/charmcraft-0.3.0/ -x charmcraft version

- back in the project, build all the snaps for different architectures

snapcraft remote-build

- try the snap (for your arch)

sudo snap install --dangerous charmcraft_0.3.0_amd64.snap
cd ~ # wherever out of the project, to avoid any potential "file mispicking"
charmcraft version


## Release

- push the tags to upstream

git push --tags upstream

- release in Github

xdg-open https://github.com/canonical/charmcraft/tags
(you should see all project tags, the top one should be this release's one)
In the menu at right of the tag tag you just created, choose 'create release'
Copy the release notes into the release description
Attach the `dist/` files
Click on "Publish release"

- release to PyPI

fades -d twine -x twine upload --verbose dist/*

- release to Snap Store (for all the archs)

snapcraft upload charmcraft_0.3.0_amd64.snap --release=edge,beta
snapcraft upload charmcraft_0.3.0_s390x.snap --release=edge,beta
...

- verify all archs are consistent:

snapcraft status charmcraft


## Final details

- update IRC channel topic

- finally change the version number in `charmcraft/version.py`

- commit, push, create a PR for the branch
61 changes: 61 additions & 0 deletions HOWTO_SNAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Steps:

- First check that snapcraft is able build something:

```
snapcraft
```

- Install it and try it, something like the following, replacing
the snap name with the one you just built:

```
sudo snap install --dangerous charmcraft_0.2.0+95.g6f8c4cc_amd64.snap
```

- If needs to be fixed, see section(s) below, GOTO 10


## How to add new Python dependencies

If trying a new snap fails because import errors, you need to include new
dependencies. Easiest way to do this is to open the snap, manually copy the
needed dependency, and try it: if it keeps failing, keep adding more dependencies,
else you're done and just update the `stage` section in `snapcraft.yaml`
with what you brought in.

Let's go on that procedure. First open the just built snap:

```
unsquashfs charmcraft_0.2.0+95.g6f8c4cc_amd64.snap
```

Copy the dependencies files you need. For example, for the `tabulate` lib
it needs to be included:

```
tabulate-0.8.7.dist-info
tabulate.py
```

Remember to not be *that* specific in `snapcraft.yaml`, where you could just
annotate:

```
- lib/tabulate-*.dist-info
- lib/tabulate.py
```

You can find these files in the project's virtualenv. So:

```
cp env/lib/python3.8/site-packages/tabulate* squashfs-root/lib/
```

Install the snap from the unsquashed dir...

```
sudo snap try squashfs-root/
```

...and try again.
3 changes: 2 additions & 1 deletion charmcraft/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
'metrics.yaml',
'actions.yaml',
'lxd-profile.yaml',
'version'
'templates',
'version',
]

# The file name and template for the dispatch script
Expand Down
14 changes: 10 additions & 4 deletions charmcraft/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
#
# For further info, check https://github.com/canonical/charmcraft

from datetime import date
import logging
import os
from pathlib import Path
import pwd
import re
from datetime import date
from pathlib import Path

import yaml
from jinja2 import Environment, PackageLoader, StrictUndefined

from charmcraft.cmdbase import BaseCommand, CommandError
Expand All @@ -39,12 +40,16 @@ def fill_parser(self, parser):
"--project-dir", type=Path, default=Path("."), metavar="DIR", dest="path",
help="the directory to initialize. Must be empty, or not exist; defaults to '.'")
parser.add_argument(
"--name", type=str,
"--name",
help="the name of the project; defaults to the directory name")
parser.add_argument(
"--author", type=str,
"--author",
help="the author of the project;"
" defaults to the current user's name as present in the GECOS field.")
parser.add_argument(
"--series", default="kubernetes",
help="the comma-separated list of series this charm will support;"
" defaults to 'kubernetes'.")

def run(self, args):
args.path = args.path.resolve()
Expand Down Expand Up @@ -77,6 +82,7 @@ def run(self, args):
"author": args.author,
"year": date.today().year,
"class_name": "".join(re.split(r"\W+", args.name.title())) + "Charm",
"series": yaml.dump(args.series.split(","), default_flow_style=True),
}

env = Environment(
Expand Down
7 changes: 5 additions & 2 deletions charmcraft/commands/store/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def list_registered_names(self):
"""Return names registered by the authenticated user."""
response = self._client.get('/v1/charm')
result = []
for item in response['charms']:
# XXX Facundo 20200804: Remove this duality when Store consolidates the new name in prod
for item in response.get('results', response.get('charms')):
result.append(Charm(name=item['name'], private=item['private'], status=item['status']))
return result

Expand Down Expand Up @@ -163,14 +164,16 @@ def list_releases(self, name):
channel_map.append(
Release(revision=item['revision'], channel=item['channel'], expires_at=expires_at))

# XXX Facundo 20200804: Remove this duality when Store consolidates the new name in prod
package = response.get('package', response.get('charm'))
channels = [
Channel(
name=item['name'],
fallback=item['fallback'],
track=item['track'],
risk=item['risk'],
branch=item['branch'],
) for item in response['charm']['channels']]
) for item in package['channels']]

revisions = [_build_revision(item) for item in response['revisions']]

Expand Down
2 changes: 2 additions & 0 deletions charmcraft/templates/init/metadata.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ description: |
TODO: fill out the charm's description
summary: |
TODO: fill out the charm's summary
series: {{ series }}

2 changes: 1 addition & 1 deletion charmcraft/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

__all__ = ('version',)

_FALLBACK = '0.2' # this gets bumped after release
_FALLBACK = '0.3.1' # this gets bumped after release


def _get_version():
Expand Down
6 changes: 6 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ parts:
- lib/google
- lib/protobuf-*.pth
- lib/protobuf-*.dist-info
- lib/tabulate.py
- lib/tabulate-*.dist-info
- lib/dateutil
- lib/python_dateutil-*.dist-info
- lib/requests_toolbelt
- lib/requests_toolbelt-*.dist-info
# this effectively means we're shipping pip and wheel twice (once above,
# and once below), but untangling that is probably not worth it.
- share/python-wheels
Expand Down

0 comments on commit 55cb3b0

Please sign in to comment.