Skip to content

Do not commit release artefacts by default#1183

Merged
gouttegd merged 7 commits intomasterfrom
dont-commit-release-artefacts
Feb 20, 2025
Merged

Do not commit release artefacts by default#1183
gouttegd merged 7 commits intomasterfrom
dont-commit-release-artefacts

Conversation

@gouttegd
Copy link
Contributor

This PR updates the seeding process so that, by default, release artefacts are not committed to the repository.

It adds a project-level option named commit_release_artefacts that can be set to True to restore the previous behaviour of committing the artefacts.

closes #1144

The `prepare_initial_release` rule does exactly the same thing as the
`prepare_release` rule, except that it also adds the release assets to
Git's staging area (so that they will be tracked by Git and later
committed).

Instead of duplicating the code of the `prepare_release` rule, we simply
make `prepare_initial_release` rule dependendent on `prepare_release`,
so that the only thing the rule specifically does is adding the release
assets to the staging area.
Add a project-level option `commit_release_artefacts` (disabled by
default). When enabled, it makes the seeding process automatically
commit the release artefacts to the repository.

As part of this change, the git step of the seeding process is
simplified:

* the name of the main branch is set at `git init` time, rather than a
  posteriori (relatedly, we no longer show the instruction for renaming
  the branch, since the branch does not need to be renamed);
* we create an initial commit containing only the instantiated template
  files;
* we invoke a single build target (prepare_release or
  prepare_initial_release, depending on whether release artefacts should
  be committed or not);
* we commit the resulting modified files to create the 'initial
  release'.
If release artefacts are not to be committed (as is the case by
default), then we instruct Git to ignore them so that they are not later
inadvertently committed.
@gouttegd gouttegd self-assigned this Feb 19, 2025
When we are not committing the release artefacts, it could happen that
`make prepare_release` does not modify any of the tracked files (e.g. if
there are no import modules that would normally be refreshed as part of
the release preparation), and in that case we should not attempt to
create a commit (otherwise Git would error out, complaining that there
is nothing to commit).
@gouttegd gouttegd requested a review from matentzn February 20, 2025 02:00
Copy link
Contributor

@matentzn matentzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial thoughts on this. In a nutshell:

  1. obliterate prepare_initial_release entirely
  2. make commit_release_artefacts a parameter to odk.py rather than a config option

See comments for details

Unconditionally ignore the top-level release artefacts, so that they can
never be committed inadvertently.

If the user chooses to commit release artefacts at commit time (using
the to-be-introduced `--commit-artefacts` option for the `seed`
command), we will forcefully add the artefacts so that Git will start
tracking them anyway.
Remove the `prepare_initial_release` target from the Makefile. Instead,
add a helper `show_release_assets` target that simply prints the list of
release assets; that target is used by the seeding command to know which
files should be forcefully added to the repository if the user chooses
to commit the release artefacts.

Replace the `commit_release_artefacts` project-level option by a
`--commit-artefacts` command-line option at the level of the `seed`
command.
@gouttegd gouttegd requested a review from matentzn February 20, 2025 14:07
Copy link
Contributor

@matentzn matentzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seeding process should not default to commit release artefacts

2 participants