-
Notifications
You must be signed in to change notification settings - Fork 82
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
move snapshot publishing into its own workflow #866
Conversation
b9dd37b
to
a4d30d2
Compare
.github/workflows/ci.yml
Outdated
|
||
publish-snapshot : | ||
runs-on : ubuntu-latest | ||
if : github.repository == 'square/anvil' && github.ref == 'refs/heads/main' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking around to see what other options we have since workflows can't reference each other and it seems like we lose some of the existing checks by moving this out of the main ci workflow; what do you think about us just modifying this branch condition as needed when making temporary snapshots? If I'm understanding correctly, it looks like we'd need to do something like that with the new workflow file anyway since it's still gating on main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new workflow does not need to be edited in order to publish other branches. Here's the on
block:
on:
workflow_dispatch:
push:
branches:
- main
With that logic, it will run automatically any time there's a push to main
. But the workflow_dispatch
node means that you can trigger it manually from the Actions
tab, then select the branch you want to target.
It winds up looking like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice, thanks for explaining! One last question/concern is differentiating the snapshots. My understanding right now is that running the workflow on a PR would clobber the existing snapshot generated from main unless someone first manually updated the version in gradle.properties, and not updating it could cause issues if someone was already relying on the existing snapshot. Is there a way we can guarantee the PR-initiated workflow would use a custom version name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do something like this https://github.com/freeletics/khonshu/blob/main/.github/workflows/publish-snapshot.yml#L36-L39 that would would publish the snapshot as <branch-name>-SNAPSHOT
if the workflow doesn't run on main. The env var takes precedence over VERSION_NAME
in gradle.properties
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 that setup looks awesome, thanks for sharing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed more with Rick offline, for now folks using pinned versions is sufficient for this concern. Maybe we'll look at updating the workflow logic later as well but for now this should be good
a4d30d2
to
2598187
Compare
2598187
to
9c4c06e
Compare
9c4c06e
to
f52073c
Compare
This allows us to manually trigger a publish-snapshot build against a different branch.