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

move snapshot publishing into its own workflow #866

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

RBusarow
Copy link
Collaborator

@RBusarow RBusarow commented Feb 5, 2024

This allows us to manually trigger a publish-snapshot build against a different branch.

@RBusarow RBusarow force-pushed the rick/publish-snapshots branch 2 times, most recently from b9dd37b to a4d30d2 Compare February 7, 2024 03:12
.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/publish-snapshot.yml Outdated Show resolved Hide resolved
.github/workflows/publish-snapshot.yml Show resolved Hide resolved

publish-snapshot :
runs-on : ubuntu-latest
if : github.repository == 'square/anvil' && github.ref == 'refs/heads/main'
Copy link
Member

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

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 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:

image

Copy link
Member

@JoelWilcox JoelWilcox Feb 9, 2024

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?

Copy link
Contributor

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.

Copy link
Member

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!

Copy link
Member

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

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