tag-publish 0.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2020-2024, Camptocamp SA
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.1
2
+ Name: tag-publish
3
+ Version: 0.7.1
4
+ Summary: Tools used to publish Python packages, Docker images and Helm charts for GitHub tag and branch
5
+ Home-page: https://github.com/camptocamp/tag-publish
6
+ License: FreeBSD
7
+ Keywords: ci
8
+ Author: Camptocamp
9
+ Author-email: info@camptocamp.com
10
+ Requires-Python: >=3.9
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: License :: Other/Proprietary License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Typing :: Typed
25
+ Requires-Dist: PyGithub (>=2.0.0,<3.0.0)
26
+ Requires-Dist: PyYAML (>=6.0.0,<7.0.0)
27
+ Requires-Dist: application-download (>=0.0.0,<2.0.0)
28
+ Requires-Dist: debian-inspector (>=31.0.0,<32.0.0)
29
+ Requires-Dist: id (>=1.0.0,<2.0.0)
30
+ Requires-Dist: multi-repo-automation (>=1.0.0,<2.0.0)
31
+ Requires-Dist: requests (>=2.0.0,<3.0.0)
32
+ Requires-Dist: security-md (>=0.0.0,<1.0.0)
33
+ Requires-Dist: twine (>=5.0.0,<6.0.0)
34
+ Project-URL: Repository, https://github.com/camptocamp/tag-publish
35
+ Description-Content-Type: text/markdown
36
+
37
+ # Tag Publish
38
+
39
+ ## Publishing
40
+
41
+ The main goals of Tag Publish offer the commands to publish the project,
42
+ see the [documentation](https://github.com/camptocamp/c2cciutils/wiki/Publishing).
43
+
44
+ ## New version
45
+
46
+ To create a new minor version you just should run `tag-publish-new --version=<version>`.
47
+
48
+ This will create the stabilization branch and will create a new pull request to update
49
+ the `SECURITY.md` file and the Renovate configuration.
50
+
51
+ This will also create the tags for the backport.
52
+
53
+ You are welcome to run `tag-publish-new --help` to see what's it's done.
54
+
55
+ Note that it didn't create a tag, you should do it manually.
56
+
57
+ To create a patch version you should just create tag.
58
+
59
+ ## SECURITY.md
60
+
61
+ The `SECURITY.md` file should contain the security policy of the repository, especially the end of
62
+ support dates.
63
+
64
+ For compatibility with [`security.md`](https://github.com/sbrunner/security.md/) it should contain an array
65
+ with at least the columns `Version` and `Supported Until`. The `Version` column will contain the concerned
66
+ version.
67
+ The `Supported Until` will contain the date of end of support `dd/mm/yyyy`.
68
+ It can also contain the following sentences:
69
+
70
+ - `Unsupported`: no longer supported => no audit, no rebuild.
71
+ - `Best effort`: the support is ended, it is still rebuilt and audited, but this can be stopped without any notice.
72
+ - `To be defined`: not yet released or the date will be set related of another project release date (like for GeoMapFish).
73
+
74
+ See also [GitHub Documentation](https://docs.github.com/en/github/managing-security-vulnerabilities/adding-a-security-policy-to-your-repository)
75
+
76
+ ## Configuration
77
+
78
+ ### Dry run
79
+
80
+ Dry run publish: `GITHUB_REF=... c2cciutils-publish --dry-run ...`
81
+
82
+ ### To pypi
83
+
84
+ The config is like this:
85
+
86
+ ```yaml
87
+ versions:
88
+ # List of kinds of versions you want to publish, that can be:
89
+ # rebuild (specified with --type),
90
+ # version_tag, version_branch, feature_branch, feature_tag (for pull request)
91
+ ```
92
+
93
+ It we have a `setup.py` file, we will be in legacy mode:
94
+ When publishing, the version computed from arguments or `GITHUB_REF` is put in environment variable `VERSION`, thus you should use it in `setup.py`, example:
95
+
96
+ ```python
97
+ VERSION = os.environ.get("VERSION", "1.0.0")
98
+ ```
99
+
100
+ Also we consider that we use `poetry` with [poetry-dynamic-versioning](https://pypi.org/project/poetry-dynamic-versioning/) to manage the version, and [poetry-plugin-tweak-dependencies-version](https://pypi.org/project/poetry-plugin-tweak-dependencies-version/) to manage the dependencies versions.
101
+
102
+ Example of configuration:
103
+
104
+ ```toml
105
+ [tool.poetry-dynamic-versioning]
106
+ enable = true
107
+ vcs = "git"
108
+ pattern = "^(?P<base>\\d+(\\.\\d+)*)"
109
+ format-jinja = """
110
+ {%- if env.get("VERSION_TYPE") == "version_branch" -%}
111
+ {{serialize_pep440(bump_version(base, 1 if env.get("IS_MASTER") == "TRUE" else 2), dev=distance)}}
112
+ {%- elif distance == 0 -%}
113
+ {{serialize_pep440(base)}}
114
+ {%- else -%}
115
+ {{serialize_pep440(bump_version(base), dev=distance)}}
116
+ {%- endif -%}
117
+ """
118
+
119
+ ```
120
+
121
+ Note that we can access to the environment variables `VERSION`,`VERSION_TYPE` and `IS_MASTER`.
122
+
123
+ Then by default:
124
+
125
+ - Tag with `1.2.3` => release `1.2.3`
126
+ - Commit on feature branch just do a validation
127
+ - Commit on `master` branch after the tag 1.3.0 => release `1.4.0.dev1`
128
+ - Commit on `1.3` branch after the tag 1.3.0 => release `1.3.1.dev1`
129
+
130
+ #### Authentication
131
+
132
+ If the file `~/.pypirc` exists we consider that we ar already logged in also
133
+ we will do the login with the `pypi` server with OpenID Connect (OIDC).
134
+
135
+ The OIDC login is recommended because it didn't needs any additional secrets,
136
+ but it need some configuration on pypi in the package,
137
+ see the [GitHub Documentation](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-pypi#adding-the-identity-provider-to-pypi).
138
+
139
+ #### Integration if the package directly in a Docker image
140
+
141
+ To make it working in the `Dockerfile` you should have in the `poetry` stage:
142
+
143
+ ```Dockerfile
144
+ ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
145
+ RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
146
+ && poetry export --with=dev --output=requirements-dev.txt
147
+ ```
148
+
149
+ And in the `run` stage
150
+
151
+ ```Dockerfile
152
+ ARG VERSION=dev
153
+ RUN --mount=type=cache,target=/root/.cache \
154
+ POETRY_DYNAMIC_VERSIONING_BYPASS=${VERSION} python3 -m pip install --disable-pip-version-check --no-deps --editable=.
155
+ ```
156
+
157
+ And in the `Makefile`:
158
+
159
+ ```Makefile
160
+ VERSION = $(strip $(shell poetry version --short))
161
+
162
+ .PHONY: build
163
+ build: ## Build the Docker images
164
+ docker build --build-arg=VERSION=$(VERSION) --tag=$(GITHUB_REPOSITORY) .
165
+ ```
166
+
167
+ ### To Docker registry
168
+
169
+ The config is like this:
170
+
171
+ ```yaml
172
+ latest: True
173
+ images:
174
+ - # The base name of the image we want to publish
175
+ name:
176
+ repository:
177
+ <internal_name>:
178
+ # The fqdn name of the server if not Docker hub
179
+ server:
180
+ # List of kinds of versions you want to publish, that can be: rebuild (specified using --type),
181
+ # version_tag, version_branch, feature_branch, feature_tag (for pull request)
182
+ version:
183
+ # List of tags we want to publish interpreted with `format(version=version)`
184
+ # e.g. if you use `{version}-lite` when you publish the version `1.2.3` the source tag
185
+ # (that should be built by the application build) is `latest-lite`, and it will be published
186
+ # with the tag `1.2.3-lite`.
187
+ tags:
188
+ # If your images are published by different jobs you can separate them in different groups
189
+ # and publish them with `tag-publish --group=<group>`
190
+ group:
191
+ ```
192
+
193
+ By default, the last line of the `SECURITY.md` file will be published (`docker`) with the tag
194
+ `latest`. Set `latest` to `False` to disable it.
195
+
196
+ ## Use Renovate to trigger a new build instead of the legacy rebuild
197
+
198
+ If the `ci/dpkg-versions.yaml` or `.github/dpkg-versions.yaml` file is present, the package list will be updated on publishing.
199
+
200
+ The versions will be updated by [GHCI](https://github.com/camptocamp/github-app-geo-project/) application.
201
+
202
+ ## Contributing
203
+
204
+ Install the pre-commit hooks:
205
+
206
+ ```bash
207
+ pip install pre-commit
208
+ pre-commit install --allow-missing-config
209
+ ```
210
+
@@ -0,0 +1,173 @@
1
+ # Tag Publish
2
+
3
+ ## Publishing
4
+
5
+ The main goals of Tag Publish offer the commands to publish the project,
6
+ see the [documentation](https://github.com/camptocamp/c2cciutils/wiki/Publishing).
7
+
8
+ ## New version
9
+
10
+ To create a new minor version you just should run `tag-publish-new --version=<version>`.
11
+
12
+ This will create the stabilization branch and will create a new pull request to update
13
+ the `SECURITY.md` file and the Renovate configuration.
14
+
15
+ This will also create the tags for the backport.
16
+
17
+ You are welcome to run `tag-publish-new --help` to see what's it's done.
18
+
19
+ Note that it didn't create a tag, you should do it manually.
20
+
21
+ To create a patch version you should just create tag.
22
+
23
+ ## SECURITY.md
24
+
25
+ The `SECURITY.md` file should contain the security policy of the repository, especially the end of
26
+ support dates.
27
+
28
+ For compatibility with [`security.md`](https://github.com/sbrunner/security.md/) it should contain an array
29
+ with at least the columns `Version` and `Supported Until`. The `Version` column will contain the concerned
30
+ version.
31
+ The `Supported Until` will contain the date of end of support `dd/mm/yyyy`.
32
+ It can also contain the following sentences:
33
+
34
+ - `Unsupported`: no longer supported => no audit, no rebuild.
35
+ - `Best effort`: the support is ended, it is still rebuilt and audited, but this can be stopped without any notice.
36
+ - `To be defined`: not yet released or the date will be set related of another project release date (like for GeoMapFish).
37
+
38
+ See also [GitHub Documentation](https://docs.github.com/en/github/managing-security-vulnerabilities/adding-a-security-policy-to-your-repository)
39
+
40
+ ## Configuration
41
+
42
+ ### Dry run
43
+
44
+ Dry run publish: `GITHUB_REF=... c2cciutils-publish --dry-run ...`
45
+
46
+ ### To pypi
47
+
48
+ The config is like this:
49
+
50
+ ```yaml
51
+ versions:
52
+ # List of kinds of versions you want to publish, that can be:
53
+ # rebuild (specified with --type),
54
+ # version_tag, version_branch, feature_branch, feature_tag (for pull request)
55
+ ```
56
+
57
+ It we have a `setup.py` file, we will be in legacy mode:
58
+ When publishing, the version computed from arguments or `GITHUB_REF` is put in environment variable `VERSION`, thus you should use it in `setup.py`, example:
59
+
60
+ ```python
61
+ VERSION = os.environ.get("VERSION", "1.0.0")
62
+ ```
63
+
64
+ Also we consider that we use `poetry` with [poetry-dynamic-versioning](https://pypi.org/project/poetry-dynamic-versioning/) to manage the version, and [poetry-plugin-tweak-dependencies-version](https://pypi.org/project/poetry-plugin-tweak-dependencies-version/) to manage the dependencies versions.
65
+
66
+ Example of configuration:
67
+
68
+ ```toml
69
+ [tool.poetry-dynamic-versioning]
70
+ enable = true
71
+ vcs = "git"
72
+ pattern = "^(?P<base>\\d+(\\.\\d+)*)"
73
+ format-jinja = """
74
+ {%- if env.get("VERSION_TYPE") == "version_branch" -%}
75
+ {{serialize_pep440(bump_version(base, 1 if env.get("IS_MASTER") == "TRUE" else 2), dev=distance)}}
76
+ {%- elif distance == 0 -%}
77
+ {{serialize_pep440(base)}}
78
+ {%- else -%}
79
+ {{serialize_pep440(bump_version(base), dev=distance)}}
80
+ {%- endif -%}
81
+ """
82
+
83
+ ```
84
+
85
+ Note that we can access to the environment variables `VERSION`,`VERSION_TYPE` and `IS_MASTER`.
86
+
87
+ Then by default:
88
+
89
+ - Tag with `1.2.3` => release `1.2.3`
90
+ - Commit on feature branch just do a validation
91
+ - Commit on `master` branch after the tag 1.3.0 => release `1.4.0.dev1`
92
+ - Commit on `1.3` branch after the tag 1.3.0 => release `1.3.1.dev1`
93
+
94
+ #### Authentication
95
+
96
+ If the file `~/.pypirc` exists we consider that we ar already logged in also
97
+ we will do the login with the `pypi` server with OpenID Connect (OIDC).
98
+
99
+ The OIDC login is recommended because it didn't needs any additional secrets,
100
+ but it need some configuration on pypi in the package,
101
+ see the [GitHub Documentation](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-pypi#adding-the-identity-provider-to-pypi).
102
+
103
+ #### Integration if the package directly in a Docker image
104
+
105
+ To make it working in the `Dockerfile` you should have in the `poetry` stage:
106
+
107
+ ```Dockerfile
108
+ ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
109
+ RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
110
+ && poetry export --with=dev --output=requirements-dev.txt
111
+ ```
112
+
113
+ And in the `run` stage
114
+
115
+ ```Dockerfile
116
+ ARG VERSION=dev
117
+ RUN --mount=type=cache,target=/root/.cache \
118
+ POETRY_DYNAMIC_VERSIONING_BYPASS=${VERSION} python3 -m pip install --disable-pip-version-check --no-deps --editable=.
119
+ ```
120
+
121
+ And in the `Makefile`:
122
+
123
+ ```Makefile
124
+ VERSION = $(strip $(shell poetry version --short))
125
+
126
+ .PHONY: build
127
+ build: ## Build the Docker images
128
+ docker build --build-arg=VERSION=$(VERSION) --tag=$(GITHUB_REPOSITORY) .
129
+ ```
130
+
131
+ ### To Docker registry
132
+
133
+ The config is like this:
134
+
135
+ ```yaml
136
+ latest: True
137
+ images:
138
+ - # The base name of the image we want to publish
139
+ name:
140
+ repository:
141
+ <internal_name>:
142
+ # The fqdn name of the server if not Docker hub
143
+ server:
144
+ # List of kinds of versions you want to publish, that can be: rebuild (specified using --type),
145
+ # version_tag, version_branch, feature_branch, feature_tag (for pull request)
146
+ version:
147
+ # List of tags we want to publish interpreted with `format(version=version)`
148
+ # e.g. if you use `{version}-lite` when you publish the version `1.2.3` the source tag
149
+ # (that should be built by the application build) is `latest-lite`, and it will be published
150
+ # with the tag `1.2.3-lite`.
151
+ tags:
152
+ # If your images are published by different jobs you can separate them in different groups
153
+ # and publish them with `tag-publish --group=<group>`
154
+ group:
155
+ ```
156
+
157
+ By default, the last line of the `SECURITY.md` file will be published (`docker`) with the tag
158
+ `latest`. Set `latest` to `False` to disable it.
159
+
160
+ ## Use Renovate to trigger a new build instead of the legacy rebuild
161
+
162
+ If the `ci/dpkg-versions.yaml` or `.github/dpkg-versions.yaml` file is present, the package list will be updated on publishing.
163
+
164
+ The versions will be updated by [GHCI](https://github.com/camptocamp/github-app-geo-project/) application.
165
+
166
+ ## Contributing
167
+
168
+ Install the pre-commit hooks:
169
+
170
+ ```bash
171
+ pip install pre-commit
172
+ pre-commit install --allow-missing-config
173
+ ```
@@ -0,0 +1,105 @@
1
+ [tool.ruff]
2
+ line-length = 110
3
+ target-version = "py39"
4
+
5
+ [tool.ruff.lint]
6
+ fixable = ["ALL"]
7
+ extend-select = [
8
+ "UP", # pyupgrade
9
+ "F", # Pyflakes
10
+ "E", "W", # Pycodestyle
11
+ "I", # isort
12
+ "S", # flake8-bandit
13
+ "SIM", # flake8-simplify
14
+ "B", # flake8-bugbear
15
+ # pydocstyle
16
+ "D213", "D214", "D215", "D405", "D406", "D407", "D408", "D409", "D410", "D411", "D413", "D416", "D417",
17
+ ]
18
+ ignore= [
19
+ "S101", # Use of assert detected
20
+ "S607", # start-process-with-partial-path
21
+ "S603", # subprocess-without-shell-equals-true
22
+ ]
23
+ exclude = ["tag_publish/configuration.py"]
24
+
25
+ [tool.mypy]
26
+ python_version = "3.9"
27
+ ignore_missing_imports = true
28
+ warn_redundant_casts = true
29
+ warn_unused_ignores = true
30
+ warn_return_any = true
31
+ strict = true
32
+
33
+ [tool.poetry]
34
+ name = "tag-publish"
35
+ version = "0.7.1"
36
+ description = "Tools used to publish Python packages, Docker images and Helm charts for GitHub tag and branch"
37
+ readme = "README.md"
38
+ authors = ["Camptocamp <info@camptocamp.com>"]
39
+ keywords = ["ci"]
40
+ repository = "https://github.com/camptocamp/tag-publish"
41
+ license = "FreeBSD"
42
+ packages = [{ include = "tag_publish" }]
43
+ classifiers = [
44
+ "Development Status :: 5 - Production/Stable",
45
+ "Environment :: Console",
46
+ "Operating System :: OS Independent",
47
+ "Programming Language :: Python",
48
+ "Intended Audience :: Developers",
49
+ "License :: OSI Approved :: MIT License",
50
+ "Typing :: Typed",
51
+ ]
52
+ include = [
53
+ "tag_publish/py.typed",
54
+ "tag_publish/*.json",
55
+ ]
56
+ exclude = ["tag_publish/node_modules/**/test"]
57
+
58
+ [tool.poetry.scripts]
59
+ tag-publish = "tag_publish.cli:main"
60
+ tag-publish-new = "tag_publish.new:main"
61
+
62
+ [tool.poetry.dependencies]
63
+ python = ">=3.9,<4.0"
64
+ requests = "2.32.3"
65
+ twine = "5.1.1"
66
+ PyYAML = "6.0.2"
67
+ id = "1.4.0"
68
+ security-md = "0.2.3"
69
+ application-download = "0.0.1.dev3"
70
+ PyGithub = "2.4.0"
71
+ debian-inspector = "31.1.0"
72
+ multi-repo-automation = "1.4.1"
73
+
74
+ [tool.poetry.group.dev.dependencies]
75
+ prospector = { version = "1.12.1", extras = ["with-bandit", "with-mypy", "with-pyroma"] }
76
+ prospector-profile-duplicated = "1.6.0"
77
+ prospector-profile-utils = "1.9.1"
78
+ types-requests = "2.32.0.20241016"
79
+ types-pyyaml = "6.0.12.20240917"
80
+
81
+ [build-system]
82
+ requires = [
83
+ "poetry-core>=1.0.0",
84
+ "poetry-dynamic-versioning[plugin]>=0.19.0",
85
+ "poetry-plugin-tweak-dependencies-version",
86
+ "poetry-plugin-drop-python-upper-constraint",
87
+ ]
88
+ build-backend = "poetry.core.masonry.api"
89
+
90
+ [tool.poetry-dynamic-versioning]
91
+ enable = false
92
+ vcs = "git"
93
+ pattern = "^(?P<base>\\d+(\\.\\d+)*)"
94
+ format-jinja = """
95
+ {%- if env.get("VERSION_TYPE") == "version_branch" -%}
96
+ {{serialize_pep440(bump_version(base, 1 if env.get("IS_MASTER") == "TRUE" else 2), dev=distance)}}
97
+ {%- elif distance == 0 -%}
98
+ {{serialize_pep440(base)}}
99
+ {%- else -%}
100
+ {{serialize_pep440(bump_version(base), dev=distance)}}
101
+ {%- endif -%}
102
+ """
103
+
104
+ [tool.poetry-plugin-tweak-dependencies-version]
105
+ default = "major"