Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pre-release versions in sync_release #2149

Merged
merged 1 commit into from Nov 20, 2023
Merged

Conversation

nforro
Copy link
Member

@nforro nforro commented Nov 6, 2023

There are two ways how to support pre-releases in a spec file.

The simpler way relies on the %version_no_tilde macro from rust-srpm-macros (not present on EL < 9) that converts a pre-release version with ~ back to upstream version. An optional argument defines upstream delimiter that defaults to -.
Here is an example of a spec file using this macro:

Version:        3.28.0~rc3

...

Source0:        https://example.com/files/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz

...

%prep
%autosetup -p1 -n %{name}-%{version_no_tilde}

If upstream version doesn't have a delimiter, for example 3.28.0b5, you can use %{version_no_tilde %{quote:%nil}}.

The second, more complex way requires you to define a macro, typically called prerelease or prerel, and package version (value of the Version tag) and upstream version are constructed depending on whether it is defined or commented out.
Here is an example of such a spec file:

%global base_version 3.28.0
%global prerelease rc3

%global package_version %{base_version}%{?prerelease:~%{prerelease}}
%global upstream_version %{base_version}%{?prerelease:-%{prerelease}}

...

Version:        %{package_version}

...

Source0:        https://example.com/files/v%{upstream_version}/%{name}-%{upstream_version}.tar.gz

...

%prep
%autosetup -p1 -n %{name}-%{upstream_version}

And a little more complex example that achieves the same (but this time there is no delimiter in upstream version and tarball URL is slightly different):

%global majorver 3
%global minorver 28
%global patchver 0
%global prerel rc3

%if 0%{?prerel:1}
%global package_version %{majorver}.%{minorver}.%{patchver}~%{prerel}
%global upstream_version %{majorver}.%{minorver}.%{patchver}%{prerel}
%else
%global package_version %{majorver}.%{minorver}.%{patchver}
%global upstream_version %{majorver}.%{minorver}.%{patchver}
%endif

...

Version:        %{package_version}

...

Source0:        https://example.com/files/v%{majorver}.%{minorver}/%{name}-%{upstream_version}.tar.gz

...

%prep
%autosetup -p1 -n %{name}-%{upstream_version}

Packit supports both ways. There is a new config option prerelease_suffix_pattern that defines a regex that is used to determine if a version is a pre-release or not. It defaults to ([.\-_~^]?)(alpha|beta|rc|pre(view)?)([.\-_]?\d+)? and you can adjust it if your project uses a different versioning scheme or undefine it to opt-out from pre-release processing. The first capturing group of the regex should capture the delimiter (and can be empty if there is none).
If a pre-release is detected, the delimiter is replaced with ~. You can also configure the prerelease_suffix_macro option to correspond to a pre-release macro in your spec file and this macro will be commented out or uncommented accordingly.


TODO:

  • Make the above a documentation article
  • Document the new config options

Merge after packit/specfile#317.

Fixes #2013.

RELEASE NOTES BEGIN

Packit now supports pre-release version in propose_downstream and pull_from_upstream. A spec file update might be required, see the documentation for more details.

RELEASE NOTES END

Copy link
Contributor

Build failed.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/fcc7553585b242a4be4b233461fb3603

✔️ pre-commit SUCCESS in 1m 48s
packit-tests-rpm FAILURE in 2m 16s
packit-tests-pip-deps FAILURE in 2m 18s
✔️ packit-tests-git-main SUCCESS in 19m 13s
packit-tests-pip-deps-sess-rec FAILURE in 2m 19s
✔️ packit-tests-git-main-sess-rec SUCCESS in 3m 05s
✔️ reverse-dep-packit-service-tests SUCCESS in 3m 42s

@nforro
Copy link
Member Author

nforro commented Nov 6, 2023

/packit build

@nforro
Copy link
Member Author

nforro commented Nov 6, 2023

/packit-stg build

@nforro
Copy link
Member Author

nforro commented Nov 6, 2023

recheck

Copy link
Contributor

Build succeeded.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/243d0f70eeb84fc996ec8f237960274d

✔️ pre-commit SUCCESS in 1m 48s
✔️ packit-tests-rpm SUCCESS in 17m 23s
✔️ packit-tests-pip-deps SUCCESS in 18m 53s
✔️ packit-tests-git-main SUCCESS in 19m 09s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 3m 01s
✔️ packit-tests-git-main-sess-rec SUCCESS in 4m 15s
✔️ reverse-dep-packit-service-tests SUCCESS in 4m 20s

Copy link
Contributor

Build succeeded.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/a611fc1856c849419131e45e32c2af0f

✔️ pre-commit SUCCESS in 1m 47s
✔️ packit-tests-rpm SUCCESS in 18m 05s
✔️ packit-tests-pip-deps SUCCESS in 18m 35s
✔️ packit-tests-git-main SUCCESS in 18m 38s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 2m 50s
✔️ packit-tests-git-main-sess-rec SUCCESS in 3m 05s
✔️ reverse-dep-packit-service-tests SUCCESS in 3m 30s

Copy link
Member

@lbarcziova lbarcziova left a comment

Choose a reason for hiding this comment

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

this approach makes sense to me :) Did you have a chance to discuss this with anyone from the affected projects?

packit/base_git.py Outdated Show resolved Hide resolved
@nforro
Copy link
Member Author

nforro commented Nov 8, 2023

this approach makes sense to me :) Did you have a chance to discuss this with anyone from the affected projects?

Thanks. No, I haven't, but that's a good idea.
However, I just realized there is another way to support pre-releases in a spec file, a little simpler as it doesn't require any macro definitions. Let me update the description and the code.

Copy link
Contributor

Build succeeded.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/049e749f8d494019a49a8052719fbccf

✔️ pre-commit SUCCESS in 1m 59s
✔️ packit-tests-rpm SUCCESS in 17m 58s
✔️ packit-tests-pip-deps SUCCESS in 18m 06s
✔️ packit-tests-git-main SUCCESS in 18m 21s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 2m 58s
✔️ packit-tests-git-main-sess-rec SUCCESS in 3m 19s
✔️ reverse-dep-packit-service-tests SUCCESS in 3m 46s

Copy link
Contributor

Build succeeded.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/108aa928d38a4cb3ac1aa8f1cb903a9f

✔️ pre-commit SUCCESS in 1m 52s
✔️ packit-tests-rpm SUCCESS in 18m 48s
✔️ packit-tests-pip-deps SUCCESS in 18m 53s
✔️ packit-tests-git-main SUCCESS in 18m 26s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 2m 55s
✔️ packit-tests-git-main-sess-rec SUCCESS in 3m 12s
✔️ reverse-dep-packit-service-tests SUCCESS in 3m 53s

softwarefactory-project-zuul bot added a commit to packit/specfile that referenced this pull request Nov 13, 2023
Prepare spec files and configure Packit for pre-releases

Related to packit/packit#2149.

Reviewed-by: Laura Barcziová
@lsm5
Copy link

lsm5 commented Nov 13, 2023

@nforro Podman's RCs are tagged vX.Y.Z-rcN. So IIUC, version_no_tilde will handle both and vX.Y.Z and vX.Y.Z-rcN correctly, is that right? So, all I need to do as a packit user is update Source0 and add a dependency on rust-srpm-macros ? We'll be doing a podman v4.8.0-rc1 soon so it'll be cool to try this out.

@nforro
Copy link
Member Author

nforro commented Nov 13, 2023

Thanks for the feedback!

So IIUC, version_no_tilde will handle both and vX.Y.Z and vX.Y.Z-rcN correctly, is that right?

Yes.

So, all I need to do as a packit user is update Source0 and add a dependency on rust-srpm-macros?

Source0 and the name argument to %autosetup (top-level directory of the tarball has a dash - podman-4.7.0-rc1/ - so you need %version_no_tilde there). Dependency on rust-srpm-macros is not necessary, redhat-rpm-config requires it so it should be always present.

We'll be doing a podman v4.8.0-rc1 soon so it'll be cool to try this out.

How soon? I'll try to get this PR merged this week so it can be deployed to production next Tuesday, would that be soon enough?

@lsm5
Copy link

lsm5 commented Nov 13, 2023

Thanks for the feedback!

So IIUC, version_no_tilde will handle both and vX.Y.Z and vX.Y.Z-rcN correctly, is that right?

Yes.

Ack.

So, all I need to do as a packit user is update Source0 and add a dependency on rust-srpm-macros?

Source0 and the name argument to %autosetup (top-level directory of the tarball has a dash - podman-4.7.0-rc1/ - so you need %version_no_tilde there). Dependency on rust-srpm-macros is not necessary, redhat-rpm-config requires it so it should be always present.

Good to know, thanks.

We'll be doing a podman v4.8.0-rc1 soon so it'll be cool to try this out.

How soon? I'll try to get this PR merged this week so it can be deployed to production next Tuesday, would that be soon enough?

We'll be likely releasing sometime next week so this should be fine. I can get the changes in to podman's spec file this week itself.

@nforro nforro marked this pull request as ready for review November 13, 2023 11:27
lsm5 added a commit to lsm5/podman that referenced this pull request Nov 13, 2023
The `version_no_tilde` rpm macro correctly handles both `vX.Y.Z` and
`vX.Y.Z-rcN` git tags. Using this macro instead of `version` will soon
allow Packit to handle RC builds correctly.

Accompanying change in Packit to land soon:
packit/packit#2149

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
lsm5 added a commit to lsm5/podman that referenced this pull request Nov 13, 2023
The `version_no_tilde` rpm macro correctly handles both `vX.Y.Z` and
`vX.Y.Z-rcN` git tags. Using this macro instead of `version` will soon
allow Packit to handle RC builds correctly.

Accompanying change in Packit to land soon:
packit/packit#2149

[NO NEW TESTS NEEDED]

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
@nforro
Copy link
Member Author

nforro commented Nov 13, 2023

I've factored out the pre-release handling code to a separate function in order to be able to use it in the prepare-release action.

Copy link
Contributor

Build succeeded.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/36d3326a428a42e5a688500d75e6e337

✔️ pre-commit SUCCESS in 1m 52s
✔️ packit-tests-rpm SUCCESS in 18m 05s
✔️ packit-tests-pip-deps SUCCESS in 21m 30s
✔️ packit-tests-git-main SUCCESS in 19m 43s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 3m 10s
✔️ packit-tests-git-main-sess-rec SUCCESS in 3m 19s
✔️ reverse-dep-packit-service-tests SUCCESS in 4m 51s

@nforro
Copy link
Member Author

nforro commented Nov 14, 2023

/packit rebuild-failed

@nforro
Copy link
Member Author

nforro commented Nov 14, 2023

/packit-stg rebuild-failed

Copy link
Contributor

Build succeeded.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/da8494cf4b334e1c81b13fd7e501e1bb

✔️ pre-commit SUCCESS in 1m 50s
✔️ packit-tests-rpm SUCCESS in 18m 55s
✔️ packit-tests-pip-deps SUCCESS in 18m 24s
✔️ packit-tests-git-main SUCCESS in 19m 02s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 4m 17s
✔️ packit-tests-git-main-sess-rec SUCCESS in 3m 24s
✔️ reverse-dep-packit-service-tests SUCCESS in 4m 11s

softwarefactory-project-zuul bot added a commit to packit/specfile that referenced this pull request Nov 14, 2023
Release 0.24.1-rc1

I've updated the prepare-release action, but it won't work until packit/packit#2149 is merged and a new Packit image is built, so I decided to do this pre-release manually in order to test the mentioned Packit PR.

Reviewed-by: Maja Massarini
Copy link
Contributor

Build succeeded.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/30e9a8c6dbe443598f9af233b478c04e

✔️ pre-commit SUCCESS in 1m 50s
✔️ packit-tests-rpm SUCCESS in 19m 37s
✔️ packit-tests-pip-deps SUCCESS in 19m 51s
✔️ packit-tests-git-main SUCCESS in 19m 45s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 4m 08s
✔️ packit-tests-git-main-sess-rec SUCCESS in 3m 25s
✔️ reverse-dep-packit-service-tests SUCCESS in 4m 26s

Copy link
Contributor

Build failed.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/a3a8dfe9b7ca4ffeab198acb850bf750

✔️ pre-commit SUCCESS in 1m 44s
packit-tests-rpm FAILURE in 17m 56s
packit-tests-pip-deps FAILURE in 18m 20s
packit-tests-git-main FAILURE in 18m 23s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 2m 49s
✔️ packit-tests-git-main-sess-rec SUCCESS in 2m 57s
✔️ reverse-dep-packit-service-tests SUCCESS in 3m 37s

softwarefactory-project-zuul bot added a commit to packit/specfile that referenced this pull request Nov 20, 2023
Implement updating version with support for pre-releases

Moved the implementation from packit/packit#2149 here and improved update_value().
Related to packit/packit#2013.
Merge before packit/packit#2149.
RELEASE NOTES BEGIN
There is a new method, Specfile.update_version(), that allows updating spec file version even if it is a pre-release.
RELEASE NOTES END

Reviewed-by: František Lachman <flachman@redhat.com>
Reviewed-by: Nikola Forró
Copy link
Contributor

Build failed.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/28bd09941bca46ab86611115767fbf4d

✔️ pre-commit SUCCESS in 1m 44s
packit-tests-rpm FAILURE in 18m 14s
packit-tests-pip-deps FAILURE in 18m 22s
✔️ packit-tests-git-main SUCCESS in 18m 25s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 2m 50s
✔️ packit-tests-git-main-sess-rec SUCCESS in 3m 14s
✔️ reverse-dep-packit-service-tests SUCCESS in 3m 37s

Signed-off-by: Nikola Forró <nforro@redhat.com>
Copy link
Contributor

Build failed.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/cc25ebe7d3e74ed38411a05114064acb

✔️ pre-commit SUCCESS in 1m 54s
packit-tests-rpm FAILURE in 18m 32s
packit-tests-pip-deps FAILURE in 19m 03s
✔️ packit-tests-git-main SUCCESS in 19m 06s
✔️ packit-tests-pip-deps-sess-rec SUCCESS in 3m 13s
✔️ packit-tests-git-main-sess-rec SUCCESS in 3m 27s
✔️ reverse-dep-packit-service-tests SUCCESS in 4m 06s

@nforro nforro merged commit 209847d into packit:main Nov 20, 2023
21 of 22 checks passed
@nforro nforro deleted the prerelease branch November 20, 2023 14:21
nforro added a commit to packit/prepare-release that referenced this pull request Nov 20, 2023
@nforro
Copy link
Member Author

nforro commented Nov 21, 2023

@lsm5 This is now in production, but I can see that podman 4.8.0-rc1 was released yesterday, which was unfortunately too soon and propose_downstream failed: https://github.com/containers/podman/runs/18862561453
Could you try to re-run it? Please ignore containers/podman#20730 for now and use the Re-run button in GitHub UI, as retriggering with a comment doesn't currently work with pre-releases.

@lsm5
Copy link

lsm5 commented Nov 27, 2023

@lsm5 This is now in production, but I can see that podman 4.8.0-rc1 was released yesterday, which was unfortunately too soon and propose_downstream failed: https://github.com/containers/podman/runs/18862561453 Could you try to re-run it? Please ignore containers/podman#20730 for now and use the Re-run button in GitHub UI, as retriggering with a comment doesn't currently work with pre-releases.

ugh whoops. Seeing this only after I manually bumped podman rpm. Never mind, there's always another RC down the line :) . Thanks a lot!

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.

Support pre-releases in propose-downstream/pull-from-upstream
3 participants