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

ci: refactor manual deployment CI config into 1 workflow #264

Closed
wants to merge 3 commits into from
Closed
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
24 changes: 22 additions & 2 deletions .github/workflows/deploy-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ on:
push:
branches: [beta, main] # all branches where deployments currently occur. Make sure this list matches list of branches in `.releaserc` file.

workflow_dispatch: # manually run this workflow. convenient way to retry a deployment.
inputs:
existing-git-tag:
description: 'Type name of existing git tag (example: 1.0.3) to checkout and manually deploy'
required: true
type: string

permissions:
contents: write # access to push the git tag
issues: write # Bot creates an issue if there is an issue during deployment process
Expand All @@ -16,6 +23,7 @@ jobs:
name: Deploy git tag
runs-on: ubuntu-latest
outputs:
new_release_git_head: ${{ steps.semantic-release.outputs.new_release_git_head }}
new_release_published: ${{ steps.semantic-release.outputs.new_release_published }}
new_release_version: ${{ steps.semantic-release.outputs.new_release_version }}
steps:
Expand Down Expand Up @@ -125,10 +133,22 @@ jobs:
deploy-sonatype:
name: Deploy SDK to Maven Central
needs: [deploy-git-tag]
Copy link
Contributor

@Shahroz16 Shahroz16 Sep 26, 2023

Choose a reason for hiding this comment

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

I don't think it will work in the case of manual workflow because it always needs a needs: [deploy-git-tag] job to work first.

Copy link
Contributor Author

@levibostian levibostian Sep 26, 2023

Choose a reason for hiding this comment

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

Great question. I understand how this can be confusing. This CI configuration would still work, but it might be confusing how.

needs specifies order of steps in the configuration. When a manual deployment is performed, the deploy-git-tag will indeed not create a new tag. It will run, see there is no tag needing to be made, then quit.

This PR works because of the modified if statement which says that deploy-sonatype step needs to wait for deploy-git-tag to run first, yes, but it will still run if a git tag is made or the deployment was manual.

The iOS SDK has the same needs and if statement as this PR and manual deployments work on that configuration.

Here is an example CI run of a manual deployment I did with this CI workflow. deploy-git-tag did run and it didn't create a tag. deploy to cocoapods checked out the git tag specified in the manual workflow input form and then proceeded to deploy to cocoapods.

Would it help if there were some comments added to the deploy-sdk.yml config file explaining this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the clarification Levi, I thought deploy-git-tag would fail hence leading up to deploy-sonatype not working. But seems like it triggers and skips and doesn't fail so it will not stop the deployment job from failing.

A couple of more things, in the case of manual workflow, if inputs.existing-git-tag is empty, it would result in using the ref branch as the source of checkout right? just want to make sure we have the latest version. in the manual script, I would fetch the latest tag in case none was mentioned while dispatching the workflow.

Secondly,

uses: ./.github/actions/setup-android
      - name: Push to Sonatype servers
        run: MODULE_VERSION=${{ needs.deploy-git-tag.outputs.new_release_version }} ./scripts/deploy-code.sh

This script is dependent on needs.deploy-git-tag.outputs.new_release_version but if the deploy-git-tag is skipped, would it populate this variable? i wouldn't believe so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I did not consider that since the iOS SDK doesn't update the version at compile-time.

Until we can test deployment CI workflows before merging PRs, I think this PR is not worth merging. Some copy/pasted code in the short-term is OK for now. I will close this PR to do the refactor another time.

if: needs.deploy-git-tag.outputs.new_release_published == 'true' # only run if a git tag was made.
# Only run if we can find a git tag to checkout.
if: ${{ needs.deploy-git-tag.outputs.new_release_published == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout git tag that got created in previous step
uses: actions/checkout@v4
if: ${{ needs.deploy-git-tag.outputs.new_release_published == 'true' }}
with:
ref: ${{ needs.deploy-git-tag.outputs.new_release_git_head }}

- name: Checkout git tag that was previously created
uses: actions/checkout@v4
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
ref: ${{ inputs.existing-git-tag }}

- uses: ./.github/actions/setup-android
- name: Push to Sonatype servers
run: MODULE_VERSION=${{ needs.deploy-git-tag.outputs.new_release_version }} ./scripts/deploy-code.sh
Expand Down
103 changes: 0 additions & 103 deletions .github/workflows/manual-deployment.yml

This file was deleted.

Loading