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

GitHub action #21

Merged
merged 19 commits into from
Nov 11, 2024
Merged

GitHub action #21

merged 19 commits into from
Nov 11, 2024

Conversation

ll-nick
Copy link
Collaborator

@ll-nick ll-nick commented Nov 7, 2024

This adds GitHub Actions to the repository that do the following:

  • Run the unit tests on all pushes to any branch
  • On a merge to main:
    • Bump the version that's currently defined in the version file, add/commit the new version and git tag this commit. By default, this bumps the minor version but this can be adjusted using the #major, #minor, #patch keywords in the commit message.
    • Pulls the newly created tag and builds the deb package and archive releases.
    • Creates a new release on GitHub using the PR description as the release description.

@ll-nick ll-nick requested a review from orzechow November 7, 2024 16:20
@ll-nick ll-nick self-assigned this Nov 7, 2024
Copy link
Member

@orzechow orzechow left a comment

Choose a reason for hiding this comment

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

This is so awesome! 🤩

Two nitpicky points, but feel free to merge.

.github/workflows/bump-version-and-create-release.yaml Outdated Show resolved Hide resolved
Comment on lines 73 to 78
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "/tmp/artifacts/release/*"
tag: ${{ needs.bump-version.outputs.new_tag }}

Copy link
Member

Choose a reason for hiding this comment

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

It would be nice, if the release description would contain the corresponding PR description.
Currently, it's the version bump commit message 🙈

I imagine this could work:

  • save the merge commit message into a tmp file (must be an early github action step, before version bump commit)
  • pass this file to the ncipollo/release-action action as bodyFile

@ll-nick
Copy link
Collaborator Author

ll-nick commented Nov 8, 2024

Thanks for the review and nice idea with the release body, let me look into that.

A couple of other points that came to my mind:

  • The readme should now suggest using the deb package as the recommended way of installing it.
  • It would be nice to have multi-architecture builds/releases. If that's not too complicated, I'd integrate that as well.
  • Right now, the default version bump is set to patch. Do you think that's appropriate or should we set it to minor @orzechow ?

@orzechow orzechow self-requested a review November 8, 2024 14:35
Copy link
Member

@orzechow orzechow left a comment

Choose a reason for hiding this comment

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

Sorry, I found a bug:

The latest release v0.1.1 contains the v0.1.0 package 😢
https://github.com/KIT-MRT/util_caching/releases/tag/v0.1.1

@orzechow
Copy link
Member

orzechow commented Nov 8, 2024

The readme should now suggest using the deb package as the recommended way of installing it.

Good point!
Feel free to change it with this PR 👍

It would be nice to have multi-architecture builds/releases. If that's not too complicated, I'd integrate that as well.

Well, a header-only release is architecture independent – that's one of it's beauties.
But – I had a wrong CPack variable name which made CPack use the system architecture instead of setting architecture=all.
Fixed with #22

Right now, the default version bump is set to patch. Do you think that's appropriate or should we set it to minor @orzechow ?

Right. #minor would be more appropriate.

@ll-nick
Copy link
Collaborator Author

ll-nick commented Nov 11, 2024

Ok @orzechow, this one is ready for another review.

I did merge a dummy change again to test the workflow. This successfully created a new release like we want it to.
Before merging, I'll delete that release and the dummy changes I made in cd459d5 to trigger the workflow.

The readme should now suggest using the deb package as the recommended way of installing it.

Good point!
Feel free to change it with this PR 👍

Done in b7d01be

It would be nice to have multi-architecture builds/releases. If that's not too complicated, I'd integrate that as well.

Well, a header-only release is architecture independent – that's one of it's beauties.
But – I had a wrong CPack variable name which made CPack use the system architecture instead of setting architecture=all.
Fixed with #22

Very good point, did not think that through 😅

Right now, the default version bump is set to patch. Do you think that's appropriate or should we set it to minor @orzechow ?

Right. #minor would be more appropriate.

Changed the default bump to #minor in c1486df

It would be nice, if the release description would contain the corresponding PR description.

Done in 93676b7. We should be aware that this is vulnerable to script injections but I figured that we would probably notice malicious code in the PR description.

Sorry, I found a bug:

The latest release v0.1.1 contains the v0.1.0 package 😢

Good catch! This happened because the docker build-push-action will use the repository state that caused the workflow, so changes inside the workflow are not considered. This means that the deb package did contain all the changes of the new version except the bumped version file which consequently lead to the wrong name of the package.

I fixed it by explicitly checking out the tag we created in the first job in 5adc18d and by setting the docker context to . in 45d3b44. See here for reference on why this is necessary.

@ll-nick ll-nick requested a review from orzechow November 11, 2024 09:55
@orzechow orzechow linked an issue Nov 11, 2024 that may be closed by this pull request
2 tasks
@ll-nick
Copy link
Collaborator Author

ll-nick commented Nov 11, 2024

Since the PR description will now be the release description too, I updated the original description of the PR to be a little more concise and highlight the contributions of the PR.

Copy link
Member

@orzechow orzechow left a comment

Choose a reason for hiding this comment

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

Ok @orzechow, this one is ready for another review.

Beautiful, thanks a lot! 👏

Two suggestions, feel free to merge after considering these.

It would be nice, if the release description would contain the corresponding PR description.

Done in 93676b7. We should be aware that this is vulnerable to script injections but I figured that we would probably notice malicious code in the PR description.

Awesome, the test release v0.2.0 worked out great!

Conserning the vulnerability, I agree that we would probably notice such code.
But, I think we can avoid it altogether, see my code suggestions.

Sorry, I found a bug:
The latest release v0.1.1 contains the v0.1.0 package 😢

Good catch! This happened because the docker build-push-action will use the repository state that caused the workflow, so changes inside the workflow are not considered. This means that the deb package did contain all the changes of the new version except the bumped version file which consequently lead to the wrong name of the package.

I fixed it by explicitly checking out the tag we created in the first job in 5adc18d and by setting the docker context to . in 45d3b44. See here for reference on why this is necessary.

Nice and clean solution! 👍

.github/workflows/bump-version-and-create-release.yaml Outdated Show resolved Hide resolved
.github/workflows/bump-version-and-create-release.yaml Outdated Show resolved Hide resolved
README.md Outdated
Comment on lines 85 to 88
Download the latest `.deb` package from the [releases page](https://github.com/KIT-MRT/util_caching/releases) and install it with `dpkg`:

```bash
sudo dpkg -i util-caching*.deb
Copy link
Member

@orzechow orzechow Nov 11, 2024

Choose a reason for hiding this comment

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

Optional:
We could think of removing the version from the deb file name (by changing CPACK_DEBIAN_FILE_NAME).
That would enable a direct link here:

Suggested change
Download the latest `.deb` package from the [releases page](https://github.com/KIT-MRT/util_caching/releases) and install it with `dpkg`:
```bash
sudo dpkg -i util-caching*.deb
Download the [latest `.deb` package release](https://github.com/KIT-MRT/util_caching/releases/latest/download/util-caching_amd64.deb) and install it with `dpkg`:
```bash
sudo dpkg -i util-caching_amd64.deb

I've seen this in other projects, but not sure if that's good practise.
On the other hand, it also eases the integration in automated installs, like in docker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, let's do that. I think having a static link here is quite beneficial.

What about the architecture in the file name? As you mentioned, this is header only, so the deb file should work everywhere right?

Should I just set

set(CPACK_DEBIAN_FILE_NAME "${PROJECT_NAME}.deb")

in cpack_config.cmake?

Copy link
Member

@orzechow orzechow Nov 11, 2024

Choose a reason for hiding this comment

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

What about the architecture in the file name? As you mentioned, this is header only, so the deb file should work everywhere right?

Right, let's then call the packages and deb files -dev. That should follow the debian style as well (except for the dropped version).

I'll provide a change for that.

Copy link
Member

Choose a reason for hiding this comment

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

libutil-caching-dev?

Copy link
Member

Choose a reason for hiding this comment

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

See 490ded5 and 124f963

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that sounds about right. 👍

Simplify the way the release body is defined.

Co-authored-by: Piotr Spieker <[email protected]>
@ll-nick ll-nick merged commit 2688bd5 into main Nov 11, 2024
1 check passed
@ll-nick ll-nick deleted the github_action branch November 11, 2024 14:17
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.

Deploy as debian package
2 participants