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: Automate releases #5386

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

chore: Automate releases #5386

wants to merge 4 commits into from

Conversation

mcollina
Copy link
Member

@mcollina mcollina commented Apr 4, 2024

Automate releases for Fastify main package.

If the approach works, we can automate all modules using this GitHub script and org-wide release token.

Checklist

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina mcollina requested review from jsumners and Eomm April 4, 2024 10:59
@mcollina mcollina changed the title Automate releases chore: Automate releases Apr 4, 2024
.github/workflows/release.yml Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
Copy link
Member Author

mcollina commented Apr 6, 2024

PTAL

@mcollina
Copy link
Member Author

mcollina commented Apr 6, 2024

You can see it in action at https://github.com/mcollina/test-publish/actions/runs/8579478592

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@mcollina
Copy link
Member Author

mcollina commented Apr 8, 2024

Unfortunately this is not compatible with protected branches.
Basically we need a more complex workflow, which I don't have time to develop atm.

Ideas would be welcomed at this point... I'm not entirely sure how to work around this.
A possible flow could be:

  1. action creates a PR
  2. human approves and merge the PR
  3. action releases to GH and NPM

@jsumners
Copy link
Member

jsumners commented Apr 8, 2024

Yep. This has been the big blocker the whole time.

@gurgunday
Copy link
Member

gurgunday commented Apr 8, 2024

Not sure if it's doable but we could maybe do:

  • human creates a prerelease
  • action makes the PR
  • human merges
  • action makes full release on GH and npm

Edit: this might be confusing

@Uzlopak
Copy link
Contributor

Uzlopak commented Apr 8, 2024

I implemented releases actually differently:

https://github.com/cthulhu-oidc/workflows/blob/master/.github/workflows/release.yml
https://github.com/cthulhu-oidc/license-manager/blob/master/.github/workflows/release.yml

It uses the github release feature to commit the release and set the tags correctly.

It also contained the npm publish once cthulhu-oidc/workflows@5bdf367

So yeah, maybe instead triggering the release manually via a workflow dispatch, using the release feature is sexier?

@mcollina
Copy link
Member Author

mcollina commented Apr 9, 2024

So yeah, maybe instead triggering the release manually via a workflow dispatch, using the release feature is sexier?

How does it work? The release feature require you to point to a commit, which must be added to main.

@mcollina
Copy link
Member Author

mcollina commented Apr 9, 2024

env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

releasenotes:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
releasenotes:
release-notes:

@Eomm
Copy link
Member

Eomm commented Apr 14, 2024

Unfortunately this is not compatible with protected branches

I think we do allow force push

@voxpelli
Copy link
Contributor

If you protect the branches using the new ruleset feature rather than the old branch protection feature, then you can grant certain apps / roles a bypass: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/creating-rulesets-for-a-repository#granting-bypass-permissions-for-your-branch-or-tag-ruleset

Skärmavbild 2024-04-20 kl  12 47 00

Skärmavbild 2024-04-20 kl  12 48 32

@mcollina
Copy link
Member Author

@voxpelli how that has anything to do with secrets access?

@voxpelli
Copy link
Contributor

voxpelli commented Apr 24, 2024

how that has anything to do with secrets access?

@mcollina It doesn't, it was in regards to protected branches and not being able to push to them:

Unfortunately this is not compatible with protected branches

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
Copy link
Member Author

mcollina commented Apr 24, 2024

I've pushed a fix done in Undici.
This:

  1. creates a PR
  2. once that lands, it ships a release
  3. one of the leads approves the release

@jsumners
Copy link
Member

I remembered the new protections feature a bit ago but kept forgetting to revisit this thread. Thanks @voxpelli.

Comment on lines +39 to +40
git config --global user.email "github-actions@github.com"
git config --global user.name "github-actions"
Copy link
Contributor

Choose a reason for hiding this comment

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

See the pull request by @voxpelli actions/checkout#1184

Suggested change
git config --global user.email "github-actions@github.com"
git config --global user.name "github-actions"
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

repo
})

const previousRelease = releases.find((r) => r.tag_name.startsWith('v6'))
Copy link
Member

Choose a reason for hiding this comment

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

v6?

Maybe:
releases.map(r => r.tag_name).sort().at(-1)

run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: node scripts/generate-undici-types-package-json.js
Copy link
Member

Choose a reason for hiding this comment

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

this script does not exist here

env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: node scripts/generate-undici-types-package-json.js
- run: npm publish --provenance
Copy link
Member

Choose a reason for hiding this comment

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

Why do we run npm publish twice?
I would add a name to this step for clarity

@mcollina
Copy link
Member Author

mcollina commented May 7, 2024

I would go back to this work after we ship v5, right now it's probably a lot of bespoke work.

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.

None yet

9 participants