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

chore(NODE-6243): move Node release tooling to drivers-github-tools #45

Merged

Conversation

baileympearson
Copy link
Collaborator

@baileympearson baileympearson commented Jun 24, 2024

Moves the signing action and the setup action to drivers-github-tools. This also creates a release action template and a generation script for js-only packages, to simplify generating release actions for each repo and to ensure that they're the same across all our repos.

It turns out that sharing workflows requires workflow files to be put in the .github/workflows folder. So unless we want to have node-specific release actions in the .github/workflows folder in drivers-github-tools, we can't re-use workflows as a whole. I chose not to shared workflows and instead generate release files (see the generation script in drivers-github-tools).

This tooling is working for the both native packages and non-native packages:

driver: mongodb/node-mongodb-native#4159
kerberos: mongodb-js/kerberos#179

Once this PR merges, I'll adjust PRs against the driver, bson and legacy driver main and open them for review.

@baileympearson baileympearson changed the title add node actions: chore(NODE-6243): move Node release tooling to drivers-github-tools Jun 25, 2024
@baileympearson baileympearson marked this pull request as ready for review June 25, 2024 16:56
- uses: actions/checkout@v4

- name: Install Node and dependencies
uses: baileympearson/drivers-github-tools/node/setup@add-signing-env-action-for-node
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just a reminder to adjust this before merging this PR

@nbbeeken nbbeeken self-assigned this Jun 26, 2024
@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jun 26, 2024
@nbbeeken nbbeeken self-requested a review June 26, 2024 14:52
shell: bash
run: |
package_version=$(jq --raw-output '.version' package.json)
echo "package_version=${package_version}" >> "$GITHUB_ENV"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did this change to ENV vs OUTPUT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ENV is easier to work with because anything can be accessed with env.<NAME> and doesn't need to worry about step ids.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It may be easier to use but it removes the explicit linkages of dependence between steps, the need to reference ids is a feature not a burden

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that as per the Workflow syntax for GitHub Actions, steps don't have outputs. The syntax steps.<step-id>.outputs.<output-id> is used to access outputs from an action called in that particular step. The $GITHUB_OUTPUT env variable is shared between all steps in a job, so it's no different from $GITHUB_ENV, with the subtle difference that $GITHUB_ENV is not made available as a job output.

Copy link
Collaborator

Choose a reason for hiding this comment

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

steps don't have outputs.

Sorry a bit confused here, each step can have outputs, the steps context is how you access them. Here's an example of how we use them in the driver

used to access outputs from an action called in that particular step

When you've called away to an action, it can return specified values by declaring its outputs: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputs-for-composite-actions

Whether you're calling away to an external action or running an inline script step using outputs is an alternative to using env. The benefit of outputs is the requirement to declaratively connect your ins and outs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

[...] the steps context is how you access them

Welp, of course it'd be in the step context, not in the workflow syntax. I stand corrected - I assumed the outputs were only available when calling to a separate action in a step.

node/generate_release.js Outdated Show resolved Hide resolved
node/generate_release.js Outdated Show resolved Hide resolved
node/generate_release.js Outdated Show resolved Hide resolved
node/generate_release.js Outdated Show resolved Hide resolved
node/setup/action.yml Outdated Show resolved Hide resolved
dry_run:
description: 'Should we upload files to the release?'
required: false
default: 'true'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it intentional that you have to set dry_run to false to get this to work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it seemed safer to default to not uploading to avoid accidental uploads while modifying the scripts. I think that's a sensible default to leave going forward too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Won't scripts already have dry_run set to false because they needed to do so? Where does the safety come in once the false settings are out there?

dry run is opt-in with our other tools, it is surprising that it is reversed here

node/sign_js_only_package/action.yml Outdated Show resolved Hide resolved
node/sign_js_only_package/action.yml Outdated Show resolved Hide resolved
node/sign_js_only_package/action.yml Outdated Show resolved Hide resolved
@baileympearson baileympearson requested a review from nbbeeken June 26, 2024 17:20
@baileympearson baileympearson force-pushed the add-signing-env-action-for-node branch from 8a279b8 to b1e4e6f Compare June 26, 2024 20:08
@nbbeeken
Copy link
Collaborator

@baileympearson I leave merging to you after you've updated the action names

@baileympearson baileympearson merged commit af77c3b into mongodb-labs:main Jun 27, 2024
3 checks passed
@baileympearson baileympearson deleted the add-signing-env-action-for-node branch June 27, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants