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

Automate publishing crates to crates.io #1364

Merged
merged 6 commits into from
Jul 13, 2024

Conversation

musicinmybrain
Copy link
Contributor

@musicinmybrain musicinmybrain commented Jul 11, 2024

This mostly reverts 5085c5b, and attempts to support publishing workspace crates onefetch-ascii, onefetch-image, and onefetch-manifest. This would fix #1363 by ensuring crates are published on a platform that fully supports symbolic links.

I have little to no experience with GitHub Workflows, and I am unable to test this PR, but it still seems like it should do the job.

Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

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

This looks mostly good. Could you use cargo publish -p PACKAGE-NAME instead of setting the working directory? I know I suggested changing the working directories in 5085c5b, but I think using cargo publish -p PACKAGE-NAME is slightly cleaner. As an added bonus one could just copy+paste the steps and run them from the project's root to publish manually if we avoid modifying the working directory.

.github/workflows/cd.yml Show resolved Hide resolved
@spenserblack
Copy link
Collaborator

I am unable to test this PR

Honestly when it comes to situations like this I think it's fine to basically test in production. In other words, just trigger the workflow when we're ready and expect it to work. If there's anything to fix we can make a new patch release to re-trigger the workflow. I've even seen big projects like Vue make new patches just to re-trigger a previously broken CD.

Though of course we would never merge in a broken CD workflow 😉

Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

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

Sorry, went through this again and had a few more comments.

CARGO_TERM_COLOR: always

steps:
- uses: actions/checkout@v3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- uses: actions/checkout@v3
- uses: actions/checkout@v4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Comment on lines 67 to 68
env:
CARGO_TERM_COLOR: always
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that this environment variable can actually be set on the workflow level (root level), not the job level. That way it will be set for all jobs, which should help on build steps for other jobs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ll give it a try! This is how it was done in the “old” implementation, but that doesn’t make it optimal. Documentation supports your claim: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#env

Comment on lines 73 to 80
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: clippy

Copy link
Collaborator

Choose a reason for hiding this comment

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

All of actions-rs is deprecated right now. TBH I'm wondering if we actually need a step to install Rust here. GitHub Actions have Rust and cargo installed by default, and typically a pretty recent version AFAIK. I never bothered to explicitly install the Rust toolchain in some personal projects, and I've never had a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. Looking more closely, the existing deploy job has the following “Install Rust” step:

- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: clippy

I suppose it makes sense to either match that in cargo-publish, or remove both “Install Rust” steps. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add dtolnay's action for consistency.

This mostly reverts commit 5085c5b.

The goal is to restore `cargo-publish` automation, and fix handling of
workspace crates in a follow-up commit.
Fixes o2sh#1363 by ensuring crates are published on a platform that fully
supports symbolic links.

Based on a suggestion in
o2sh@5085c5b#commitcomment-91354413.
@musicinmybrain
Copy link
Contributor Author

This looks mostly good. Could you use cargo publish -p PACKAGE-NAME instead of setting the working directory? I know I suggested changing the working directories in 5085c5b, but I think using cargo publish -p PACKAGE-NAME is slightly cleaner. As an added bonus one could just copy+paste the steps and run them from the project's root to publish manually if we avoid modifying the working directory.

I’ll follow up with this change next. $ cargo publish -p onefetch-ascii --dry-run works, so it should be fine.

@musicinmybrain
Copy link
Contributor Author

I think I handled all the feedback except for #1364 (comment). Let me know what you think about #1364 (comment), and I’ll be back to this in a few hours.

@spenserblack
Copy link
Collaborator

I think I handled all the feedback except for #1364 (comment). Let me know what you think about #1364 (comment), and I’ll be back to this in a few hours.

Great! Once you resolve #1364 (comment) this will be good to me.

@musicinmybrain
Copy link
Contributor Author

I think I handled all the feedback except for #1364 (comment). Let me know what you think about #1364 (comment), and I’ll be back to this in a few hours.

Great! Once you resolve #1364 (comment) this will be good to me.

Done! Thank you for the thorough and helpful review.

musicinmybrain referenced this pull request Jul 12, 2024
Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

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

Looks good! Congrats on getting some experience with GH Workflows!

@spenserblack spenserblack changed the title Restore CD automation for publishing crates, and support workspace crates Automate publishing crates to crates.io Jul 12, 2024
@o2sh o2sh merged commit 21af7c9 into o2sh:main Jul 13, 2024
11 checks passed
@o2sh o2sh added the feat label Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LICENSE.md in published crates contains symlink path instead of license text
3 participants