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

Push a git tag after a VERSION change #1209

Merged
merged 2 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .expeditor/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ github:
# https://expeditor.chef.io/docs/getting-started/subscriptions/#merge-actions
# The `merge_actions` key is a shortcut for the
# `pull_request_merged:<GITHUB_REPO>:<RELEASE_BRANCH>:*` subscription.
#
merge_actions:
- bash:.expeditor/determine_version.sh:
ignore_labels:
Expand All @@ -39,6 +40,10 @@ merge_actions:
ignore_labels:
- "Expeditor: Skip Changelog"
- "Expeditor: Skip All"
# The git commit happens here
- bash:.expeditor/push-git-tag.sh:
Copy link
Contributor

Choose a reason for hiding this comment

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

The order in the config is the order the commands will be executed in, correct? I tried to confirm that in https://expeditor.chef.io/docs/getting-started/action-sets/ but I didn't see it.

If my understanding is correct, looks like BTM got this updated to run before the release.

However, the bash action is pre-commit by default (https://expeditor.chef.io/docs/reference/actions/#bash) so I think we need post_commit: true added back

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 think I actually had it here originally, but with the post-commit: true and expeditor had errored saying that the actions had to be listed in the order they would be executed, which had caused me to move it to the end.

It seems unlikely that the trigger_pipeline:omnibus/release action would be firing before a commit was finished, but it doesn't have a post-commit property on it.

I'm starting to get confused about what commit we're actually referring to.

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be before trigger_pipeline, and specified with a post_commit: true. I'll see if I can find out why it was giving you an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

I put your exact scenario into my spec tests and everything came up golden. Let's try your config with the following merge_actions:

            - bash:.expeditor/determine_version.sh:
                ignore_labels:
                  - "Expeditor: Skip Version Bump"
                  - "Expeditor: Skip All"
            - built_in:update_changelog:
                ignore_labels:
                  - "Expeditor: Skip Changelog"
                  - "Expeditor: Skip All"
            - bash:.expeditor/push-git-tag.sh:
                only_if: bash:.expeditor/determine_version.sh
                post_commit: true
            - trigger_pipeline:omnibus/release:
                ignore_labels:
                  - "Expeditor: Skip Omnibus"
                  - "Expeditor: Skip All"
                only_if: bash:.expeditor/determine_version.sh

Copy link
Contributor

Choose a reason for hiding this comment

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

As for "what commit we're actually referring to", there is an implicit commit between the pre-commit and post-commit phases. That's likely what we're referring to.

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 probably had it between bash:.expeditor/determine_version.sh: and built_in:update_changelog: before.

only_if: bash:.expeditor/determine_version.sh
post_commit: true
- trigger_pipeline:omnibus/release:
ignore_labels:
- "Expeditor: Skip Omnibus"
Expand Down
12 changes: 12 additions & 0 deletions .expeditor/push-git-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# This gets run as a post-commit hook after merge to add the version tag so it
# is easy to determine what changes are in a particular build.
#
# https://expeditor.chef.io/docs/reference/action-filters/#post-commit


VERSION=`cat VERSION`

git tag $VERSION
git push origin $VERSION