Skip to content

Commit 39f16a4

Browse files
authored
Fix golang packaging and releasing (#25)
1 parent 633d6aa commit 39f16a4

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

continuous_delivery_scripts/plugins/golang.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
logger = logging.getLogger(__name__)
1616

1717
SRC_DIR = configuration.get_value(ConfigurationVariable.SOURCE_DIR)
18+
ROOT_DIR = configuration.get_value(ConfigurationVariable.PROJECT_ROOT)
1819
ENVVAR_GORELEASER_GIT_TOKEN = "GITHUB_TOKEN"
1920
ENVVAR_GORELEASER_CUSTOMISED_TAG = "GORELEASER_CURRENT_TAG"
2021

@@ -64,7 +65,7 @@ def _call_goreleaser_check(version: str) -> None:
6465
env = os.environ
6566
env[ENVVAR_GORELEASER_CUSTOMISED_TAG] = version
6667
env[ENVVAR_GORELEASER_GIT_TOKEN] = configuration.get_value(ConfigurationVariable.GIT_TOKEN)
67-
check_call(_generate_goreleaser_check_command_list(), cwd=SRC_DIR)
68+
check_call(_generate_goreleaser_check_command_list(), cwd=ROOT_DIR)
6869

6970

7071
def _call_goreleaser_release(version: str) -> None:
@@ -76,7 +77,7 @@ def _call_goreleaser_release(version: str) -> None:
7677
env = os.environ
7778
env[ENVVAR_GORELEASER_CUSTOMISED_TAG] = version
7879
env[ENVVAR_GORELEASER_GIT_TOKEN] = configuration.get_value(ConfigurationVariable.GIT_TOKEN)
79-
check_call(_generate_goreleaser_release_command_list(changelogPath), cwd=SRC_DIR, env=env)
80+
check_call(_generate_goreleaser_release_command_list(changelogPath), cwd=ROOT_DIR, env=env)
8081

8182

8283
class Go(BaseLanguage):

continuous_delivery_scripts/tag_and_release.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from continuous_delivery_scripts.report_third_party_ip import generate_spdx_project_reports, SpdxProject
1818
from continuous_delivery_scripts.utils.configuration import configuration, ConfigurationVariable
1919
from continuous_delivery_scripts.utils.definitions import CommitType
20-
from continuous_delivery_scripts.utils.git_helpers import ProjectTempClone, GitWrapper
20+
from continuous_delivery_scripts.utils.git_helpers import ProjectTempClone, LocalProjectRepository, GitWrapper
2121
from continuous_delivery_scripts.utils.logging import log_exception, set_log_level
2222

2323
SPDX_REPORTS_DIRECTORY = "licensing"
@@ -50,6 +50,7 @@ def tag_and_release(mode: CommitType, current_branch: Optional[str] = None) -> N
5050
insert_licence_header(0)
5151
_update_repository(mode, is_new_version, version, current_branch)
5252
if is_new_version:
53+
_clean_repository()
5354
if spdx_project and get_language_specifics().should_include_spdx_in_package():
5455
_generate_spdx_reports(spdx_project)
5556
get_language_specifics().package_software(version)
@@ -98,6 +99,15 @@ def _update_repository(mode: CommitType, is_new_version: bool, version: str, cur
9899
git.clean()
99100

100101

102+
def _clean_repository() -> None:
103+
"""Cleans the local repository."""
104+
with LocalProjectRepository() as git:
105+
logger.info("Cleaning repository")
106+
git.fetch()
107+
git.pull()
108+
git.clean()
109+
110+
101111
def _generate_spdx_reports(project: SpdxProject) -> None:
102112
report_directory = Path(configuration.get_value(ConfigurationVariable.PROJECT_ROOT)).joinpath(
103113
SPDX_REPORTS_DIRECTORY

news/202108241747.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed Golang packaging

0 commit comments

Comments
 (0)