@@ -44,6 +44,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.plugins.golang</code>
44
44
from continuous_delivery_scripts.utils.language_specifics_base import BaseLanguage, get_language_from_file_name
45
45
from continuous_delivery_scripts.spdx_report.spdx_project import SpdxProject
46
46
from continuous_delivery_scripts.utils.configuration import configuration, ConfigurationVariable
47
+ from continuous_delivery_scripts.utils.git_helpers import LocalProjectRepository
47
48
48
49
logger = logging.getLogger(__name__)
49
50
@@ -101,18 +102,6 @@ <h1 class="title">Module <code>continuous_delivery_scripts.plugins.golang</code>
101
102
check_call(_generate_goreleaser_check_command_list(), cwd=ROOT_DIR)
102
103
103
104
104
- def _call_goreleaser_release(version: str) -> None:
105
- """Calls go releaser release to upload packages."""
106
- logger.info("Installing GoReleaser if missing.")
107
- check_call(_install_goreleaser_command_list())
108
- logger.info("Release package.")
109
- changelogPath = configuration.get_value(ConfigurationVariable.CHANGELOG_FILE_PATH)
110
- env = os.environ
111
- env[ENVVAR_GORELEASER_CUSTOMISED_TAG] = version
112
- env[ENVVAR_GORELEASER_GIT_TOKEN] = configuration.get_value(ConfigurationVariable.GIT_TOKEN)
113
- check_call(_generate_goreleaser_release_command_list(changelogPath), cwd=ROOT_DIR, env=env)
114
-
115
-
116
105
class Go(BaseLanguage):
117
106
"""Specific actions for a Golang project."""
118
107
@@ -133,7 +122,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.plugins.golang</code>
133
122
def release_package_to_repository(self, version: str) -> None:
134
123
"""No operation."""
135
124
super().release_package_to_repository(version)
136
- _call_goreleaser_release(version)
125
+ self. _call_goreleaser_release(version)
137
126
138
127
def check_credentials(self) -> None:
139
128
"""Checks any credentials."""
@@ -160,7 +149,26 @@ <h1 class="title">Module <code>continuous_delivery_scripts.plugins.golang</code>
160
149
161
150
def should_clean_before_packaging(self) -> bool:
162
151
"""States whether the repository must be cleaned before packaging happens."""
163
- return True</ code > </ pre >
152
+ return True
153
+
154
+ def _call_goreleaser_release(self, version: str) -> None:
155
+ """Calls go releaser release to upload packages."""
156
+ logger.info("Installing GoReleaser if missing.")
157
+ check_call(_install_goreleaser_command_list())
158
+ tag = self.get_version_tag(version)
159
+ # The tag of the release must be retrieved
160
+ # See https://github.com/goreleaser/goreleaser/discussions/1426
161
+ logger.info(f"Checking out tag: {tag}.")
162
+ with LocalProjectRepository() as git:
163
+ git.configure_for_github()
164
+ git.fetch()
165
+ git.checkout(f"tags/{tag}")
166
+ logger.info("Release package.")
167
+ changelogPath = configuration.get_value(ConfigurationVariable.CHANGELOG_FILE_PATH)
168
+ env = os.environ
169
+ env[ENVVAR_GORELEASER_CUSTOMISED_TAG] = version
170
+ env[ENVVAR_GORELEASER_GIT_TOKEN] = configuration.get_value(ConfigurationVariable.GIT_TOKEN)
171
+ check_call(_generate_goreleaser_release_command_list(changelogPath), cwd=ROOT_DIR, env=env)</ code > </ pre >
164
172
</ details >
165
173
</ section >
166
174
< section >
@@ -201,7 +209,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
201
209
def release_package_to_repository(self, version: str) -> None:
202
210
"""No operation."""
203
211
super().release_package_to_repository(version)
204
- _call_goreleaser_release(version)
212
+ self. _call_goreleaser_release(version)
205
213
206
214
def check_credentials(self) -> None:
207
215
"""Checks any credentials."""
@@ -228,7 +236,26 @@ <h2 class="section-title" id="header-classes">Classes</h2>
228
236
229
237
def should_clean_before_packaging(self) -> bool:
230
238
"""States whether the repository must be cleaned before packaging happens."""
231
- return True</ code > </ pre >
239
+ return True
240
+
241
+ def _call_goreleaser_release(self, version: str) -> None:
242
+ """Calls go releaser release to upload packages."""
243
+ logger.info("Installing GoReleaser if missing.")
244
+ check_call(_install_goreleaser_command_list())
245
+ tag = self.get_version_tag(version)
246
+ # The tag of the release must be retrieved
247
+ # See https://github.com/goreleaser/goreleaser/discussions/1426
248
+ logger.info(f"Checking out tag: {tag}.")
249
+ with LocalProjectRepository() as git:
250
+ git.configure_for_github()
251
+ git.fetch()
252
+ git.checkout(f"tags/{tag}")
253
+ logger.info("Release package.")
254
+ changelogPath = configuration.get_value(ConfigurationVariable.CHANGELOG_FILE_PATH)
255
+ env = os.environ
256
+ env[ENVVAR_GORELEASER_CUSTOMISED_TAG] = version
257
+ env[ENVVAR_GORELEASER_GIT_TOKEN] = configuration.get_value(ConfigurationVariable.GIT_TOKEN)
258
+ check_call(_generate_goreleaser_release_command_list(changelogPath), cwd=ROOT_DIR, env=env)</ code > </ pre >
232
259
</ details >
233
260
< h3 > Ancestors</ h3 >
234
261
< ul class ="hlist ">
@@ -337,7 +364,7 @@ <h3>Methods</h3>
337
364
< pre > < code class ="python "> def release_package_to_repository(self, version: str) -> None:
338
365
"""No operation."""
339
366
super().release_package_to_repository(version)
340
- _call_goreleaser_release(version)</ code > </ pre >
367
+ self. _call_goreleaser_release(version)</ code > </ pre >
341
368
</ details >
342
369
</ dd >
343
370
</ dl >
0 commit comments