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

Upload binaries to github release in actions #208

Merged
merged 2 commits into from
Dec 18, 2022

Conversation

staniewzki
Copy link
Collaborator

Added new release workflow, and made the ci workflow to trigger it when the publishing should happen.

There has been problems with openssl-sys crate. When cross compiling, openssl built for target is needed. Thus, I enabled vendored-openssl feature in crates-index, to make that simpler.

@staniewzki
Copy link
Collaborator Author

Not sure how to test the workflow. The simplified version is working on my fork.
https://github.com/staniewzki/cargo-semver-check/actions/runs/3630752868
https://github.com/staniewzki/cargo-semver-check/actions/runs/3630772995

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

Excellent! Thanks for putting this together, excited to ship it 🚀

@@ -186,10 +186,10 @@ jobs:
git tag "v$CURRENT_VERSION"
git push origin "v$CURRENT_VERSION"

- name: Publish
- name: Trigger release workflow
run: gh workflow run release.yml --ref refs/tags/v${{ env.CURRENT_VERSION }}
Copy link
Owner

Choose a reason for hiding this comment

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

Workflows can call other workflows directly, without needing to go through the gh client.

Here's an example from the Trustfall publish steps: https://github.com/obi1kenobi/trustfall/blob/main/.github/workflows/ci.yml#L282

@@ -186,10 +186,10 @@ jobs:
git tag "v$CURRENT_VERSION"
git push origin "v$CURRENT_VERSION"
Copy link
Owner

Choose a reason for hiding this comment

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

If moving publishing to a workflow, I think it's better to move the tagging into that workflow too. For bonus points, maybe tag the version after cargo publish rather than before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The issue here is that the jobs that happen in the release workflow must be passed a ref to a tag. It could be speified for every job as an argument, but then the tag name (version) must be calculated or stored somewhere and I had problems with that.

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure I understand. Where do the jobs in the release workflow use the tag?

The only uses of a tag I see are the gh workflow run and the on: push: tags: trigger in the workflow file, both of which I'm suggesting we move away from by instead using a direct workflow-to-workflow call like how the Trustfall repo builds the platform-specific binaries for the Python bindings: https://github.com/obi1kenobi/trustfall/blob/main/.github/workflows/ci.yml#L294

Even if the tag name is needed, it can be a job output and I'd be happy to help you figure out any issues with that. Let me know if you'd like to pair-program this!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both taiki-e/create-gh-release-action@v1 and taiki-e/upload-rust-binary-action@v1 must run on the tag ref.

I tried to set a enviormental variable and use it later on, but this somehow failed on Windows.

Actually, the pair programming sounds like a cool idea, as I have spent some time already on trial and error with moderate success.

Copy link
Owner

Choose a reason for hiding this comment

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

It seems like they would accept a ref argument though:
https://github.com/taiki-e/create-gh-release-action/blob/main/action.yml#L45-L49
https://github.com/taiki-e/upload-rust-binary-action/blob/main/action.yml#L61-L66

If we git tag and push the tag before running those actions, and set their ref to the tag name, I think that should work.

Let me know over Zulip what times are best for pair-programming for you in the next few days, and we can make something work.

Comment on lines 4 to 7
push:
tags:
- v[0-9]+.*
workflow_dispatch:
Copy link
Owner

Choose a reason for hiding this comment

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

Use workflow_call only here: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_call

We don't want to run on tags because then we'll get duplicate runs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Workflows don't trigger off events happening in github actions, so there wouldn't be any duplicates

Copy link
Owner

Choose a reason for hiding this comment

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

Neat, TIL! Even so, if we use workflow_call we still don't need this to run on tags.

Copy link
Contributor

Choose a reason for hiding this comment

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

Workflows don't trigger off events happening in github actions, so there wouldn't be any duplicates

Just FYI: They can if you use a Personal Access Token.

- target: aarch64-unknown-linux-gnu
- target: aarch64-unknown-linux-musl
- target: aarch64-apple-darwin
os: macos-11
Copy link
Owner

Choose a reason for hiding this comment

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

Not macos-latest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Copy link
Owner

Choose a reason for hiding this comment

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

I'd put the git tag step here, between the cargo publish and the GitHub release.

- target: x86_64-apple-darwin
os: macos-10.15
- target: x86_64-pc-windows-msvc
os: windows-2019
Copy link
Owner

Choose a reason for hiding this comment

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

Not windows-latest?

@@ -31,7 +31,7 @@ ignore = "0.4.18"
clap-verbosity-flag = "2.0.0"
log = "0.4.17"
git2 = { version = "0.15.0", default-features = false }
crates-index = "0.18.9"
crates-index = { version = "0.18.9", features = ["vendored-openssl"] }
Copy link
Owner

Choose a reason for hiding this comment

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

@epage any concerns with adding this feature? It seems to make the build simpler and more reliable, but I wanted to double-check with you in case there were any downsides I'm not familiar with.

.github/workflows/release.yml Show resolved Hide resolved
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

Broadly looks good! I'm just not sure why some of the caching is removed.

I also highly recommend doing a self-review of the PR in the GitHub PR interface. The change of perspective will usually let you find most of the kinds of things reviewers will also flag, and the fewer comments a PR has, the faster it'll merge.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
@staniewzki
Copy link
Collaborator Author

Ah, sorry for that, no idea how those changes made it to the PR. Thanks for the GitHub PR interface tip!

@obi1kenobi obi1kenobi merged commit 37667f6 into obi1kenobi:main Dec 18, 2022
@obi1kenobi
Copy link
Owner

Planning to make a new release either later today or tomorrow morning to test this out. Great job putting it together!

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.

3 participants