Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

rules_docker release github workflow #2106

Merged
merged 12 commits into from Jun 21, 2022
Merged

Conversation

kriscfoster
Copy link
Contributor

@kriscfoster kriscfoster commented Jun 8, 2022

Here's a demo.

Here's an example release.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Automatic release process with GitHub actions.

What is the current behavior?

Issue Number: #2102

What is the new behavior?

On a tag push, the workflow will be triggered & release will be created.

git tag -a v0.25.0 -m ""
git push origin v0.25.0
# this will trigger a github workflow which will create the desired release with a relevant description etc

Screen Shot 2022-06-08 at 16 23 57

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@google-cla
Copy link

google-cla bot commented Jun 8, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

name = "io_bazel_rules_docker",
sha256 = "${{ steps.get_sha.outputs.sha }}",
strip_prefix = "rules_docker-${{ env.VERSION }}",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/${{ steps.get_tag.outputs.TAG }}/rules_docker-${{ steps.get_tag.outputs.TAG }}.tar.gz"],
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
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/${{ steps.get_tag.outputs.TAG }}/rules_docker-${{ steps.get_tag.outputs.TAG }}.tar.gz"],
urls = ["https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases/download/${{ steps.get_tag.outputs.TAG }}/rules_docker-${{ steps.get_tag.outputs.TAG }}.tar.gz"],

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, updated to be more dynamic. The generated release information works automatically for forks now as-well.

@uhthomas
Copy link
Collaborator

Thank you for the contribution! Looks good to me, bar one comment.

http_archive(
name = "io_bazel_rules_docker",
sha256 = "${{ steps.get_sha.outputs.sha }}",
strip_prefix = "rules_docker-${{ env.VERSION }}",
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 we may be able to remove the need for the strip_prefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @uhthomas, I actually think I prefer to leave it in so we don't need to extract/recpompress things as that feels a little unnatural. However, if we want to remove it at a later stage we would just need to:

  1. After https://github.com/bazelbuild/rules_docker/pull/2106/files#diff-87db21a973eed4fef5f32b267aa60fcee5cbdf03c67fafdc2a9b553bb0b15f34R21 is downloaded, extract the contents.
  2. Move into the top level directory & compress the contents of that instead of the parent directory.
  3. Use this new tar.gz instead of the other one for generating SHA, uploading etc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm.

We could use git archive?

- uses: actions/checkout@v3
- run: git archive --output=rules_docker-${{ steps.get_tag.outputs.TAG }}.tar.gz ${{ steps.get_tag.outputs.TAG }}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Even better, we could make tar.zst archives. Smaller and faster to compress/decompress. Though this would require Bazel 5.2.0. Maybe both? I guess we can do this in a follow up PR. Just wanted to write this down somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah doing that in a follow up makes sense. I can probably look at it, but won't get a chance this week. Could be good to try what we have here so far with the next release anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you happy to try the git archive thing? It would be really nice to remove the requirement for strip_prefix as most other rulesets don't for major releases. If you don't have time, I'm happy to add a commit?

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 can probably get to this next week but if you'd like to try it in the meantime, feel free to add a commit. Otherwise, I'll try next week.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@uhthomas actually had some time this evening & pushed the change so strip_prefix isn't needed. Your suggestion worked. Basically, the extracted parent dir just needs to match the name of the tar & then strip_prefix isn't needed so git archive works a treat. Thank you!

@uhthomas uhthomas merged commit ed321b3 into bazelbuild:master Jun 21, 2022
@kriscfoster
Copy link
Contributor Author

Whoever is releasing using this, it should just be a case of doing this from master:

git tag -a v0.25.0 -m ""
git push origin v0.25.0

@uhthomas
Copy link
Collaborator

Damn, didn't mean to rebase and merge. Should have squashed.

Thanks again @kriscfoster, will make a release later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants