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

Git tags when packaging #841

Closed
steveklabnik opened this issue Nov 11, 2014 · 8 comments
Closed

Git tags when packaging #841

steveklabnik opened this issue Nov 11, 2014 · 8 comments
Labels
Command-publish S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@steveklabnik
Copy link
Member

Bundler does some cool git stuff when publishing a package[1]. Conceptually, with cargo commands instead, and with error handling and rollback elided, it does this:

$ cargo build
$ git diff --exit-code == 0
$ git diff-index --quiet --cached HEAD == 0
$ git tag -a -m \"Version #{version}\" #{version_tag} 
$ git push
$ git push --tags
$ cargo publish

(version is like 1.2.3 and version_tag is like v1.2.3)

Having the tags automatically created at the same commit as was released, plus ensuring that what's on github/whatever is the same as what's on crates.io would be pretty great.

1: https://github.com/bundler/bundler/blob/master/lib/bundler/gem_helper.rb#L47-L50

@shadowmint
Copy link

I don't have much to add to this except 1) yes please, and 2) version_tag should not be prefixed with v; this is a left over from pre-2.0 of semver and no longer part of the spec.

@bluss
Copy link
Member

bluss commented Jan 17, 2016

packagename-VERSION may be a good tag name pattern. It works for those that have many cargo packages per repository (which is quite common: regex, quickcheck, rand, etc, many do).

I don't think cargo should push.

@sbeckeriv
Copy link
Contributor

@steveklabnik how important is the push tag step? @bluss doesnt think it should push.

I have auto tagging configurable via cargo config. Its not clear to me yet on how to push tags via libgit2-rs. Also should the config live in the cargo toml so its project wide? I thought Cargo.toml was loaded in the config object but my test say otherwise.

https://github.com/rust-lang/cargo/compare/master...sbeckeriv:git-auto-tag-841?expand=1

let me know your thoughts/concerns/comments.
thanks
Becker

@Nemo157
Copy link
Member

Nemo157 commented May 4, 2016

Just thought I'd mention that I use an inverse workflow, I tag (with PGP signature) and use that as a trigger that the CI service should publish that commit to crates.io. I feel it comes closer to ensuring reproducible builds, the exact build steps taken (modulo the setup of the CI container) are specified in the .travis.yml/.gitlab-ci.yml/... file with the code. Not sure how common this might be compared to publishing from your local dev machine though.

If this auto-tagging is configurable that would ensure this workflow still works, I'm not sure if there's any other way that this could interact better/worse with it.

sbeckeriv added a commit to sbeckeriv/cargo that referenced this issue May 20, 2016
Dearest reviewer,

This is part of rust-lang#841 which is about the publishing and tagging flow.
This pull request just prevents publishing with uncommitted or untracked
files. I have included a flag for turning this off. There are two new
test.

More details about the full flow at
rust-lang#2443 . I plan on doing more
work on the flow, however, I felt this was useful enough to do stand
alone. When I tried the flow before I was doing to much at once.

Thanks!
Becker

[Updated]
Moved from config to flag
Using open_ext to sub crates
Include the file names in error message
include flag in error
Move to discover off of open_ext
formatting
sbeckeriv added a commit to sbeckeriv/cargo that referenced this issue May 20, 2016
Dearest reviewer,

This is part of rust-lang#841 which is about the publishing and tagging flow.
This pull request just prevents publishing with uncommitted or untracked
files. I have included a flag for turning this off. There are two new
test.

More details about the full flow at
rust-lang#2443 . I plan on doing more
work on the flow, however, I felt this was useful enough to do stand
alone. When I tried the flow before I was doing to much at once.

Thanks!
Becker

[Updated]
Moved from config to flag
Using open_ext to sub crates
Include the file names in error message
include flag in error
Move to discover off of open_ext
formatting
cut back on unwraps
rework file check logic with a bail
bors added a commit that referenced this issue Jun 11, 2016
Prevent packaging a crate if any files are dirty

This commit alters Cargo's behavior to prevent publishing a crate by default if
any files in that crate are determined to be dirty, that is either modified or
not part of the working tree.

This can prevent common mistakes like many listed in #2063 and enables features like #841.

Closes #1597
Closes #2063
@matklad
Copy link
Member

matklad commented Nov 13, 2018

Automatic tagging and pushing to the repo do raise some design questions.

A possibly simpler solution is to check that a tag exists before publishing. This should be done over here:

fn check_repo_state(

That can be extended later with an opt-in ‘—tag’ flag later, and could probably be made a default after edition switch? Code for that should probably go either in that cargo_package.rs file, or here:

pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {

I don’t feel like adding taggging by default would work without opt-in at this moment, due to backwards compatibility requirements.

@dwijnand
Copy link
Member

This is available through https://github.com/sunng87/cargo-release.

Are we still interested in this being in cargo proper?

@steveklabnik
Copy link
Member Author

I very much am! I think being "standard" here is very helpful.

@epage epage added the S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. label May 3, 2023
@epage
Copy link
Contributor

epage commented Sep 26, 2023

We discussed this in the team meeting today in favor of closing this.

While we understand the desire for releases to follow best-practices, like tagging, we felt this shouldn't belong in a more purpose-focused command like cargo publish. An alternative would be for a new built-in command that covers the release process, but with varying workflows (tag triggered releases, bors workflows, changelog updating, etc), this seems like it'd be better for us to leave to the community to be developing in third-party tools.

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2023
epage added a commit to epage/cargo that referenced this issue Sep 26, 2023
Inspired by rust-lang#841 and conversations at RustConf.

At RustConf, someone was talking to me about the lack or inconsistent
use of best practices within the crate ecosystem.
We have a challenge of needing to help users get up and going who can't
research every last decision while not over-encouraging the status quo,
leading to stagnation.

I do have a bias in this conversation as the maintainer of one of these
tools which is why I decided to pick an ordering without judgement.
I picked alphabetical ordering before sorting and realizing this puts my
own crate first.
epage added a commit to epage/cargo that referenced this issue Sep 27, 2023
Inspired by rust-lang#841 and conversations at RustConf.

At RustConf, someone was talking to me about the lack or inconsistent
use of best practices within the crate ecosystem.
We have a challenge of needing to help users get up and going who can't
research every last decision while not over-encouraging the status quo,
leading to stagnation.

I do have a bias in this conversation as the maintainer of one of these
tools which is why I decided to pick an ordering without judgement.
I picked alphabetical ordering before sorting and realizing this puts my
own crate first.
bors added a commit that referenced this issue Sep 27, 2023
docs(ref): Establish publish best practices

Inspired by #841 and conversations at RustConf.

At RustConf, someone was talking to me about the lack or inconsistent use of best practices within the crate ecosystem.
We have a challenge of needing to help users get up and going who can't research every last decision while not over-encouraging the status quo, leading to stagnation.

The list of tools included was based on a mixture of
- Download counts
- Word of mouth exposure
- Unique aspects covered
- Maturity

I do have a bias in this conversation as the maintainer of one of these tools which is why I decided to pick an ordering without judgement. I picked alphabetical ordering before sorting and realizing this puts my own crate first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command-publish S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants