vgijssel / setup

Workstation and server setup
MIT License
8 stars 0 forks source link

feat: Create rules_release #601

Closed mvgijssel closed 9 months ago

mvgijssel commented 10 months ago

closes #603

ref #451

ref #571

The flow

write file: https://github.com/changesets/changesets/tree/main/packages/write changelog content: https://github.com/changesets/action/blob/main/src/utils.ts#L37

API example

load("@rules_release//:defs.bzl", "release", "release_manager")

release(
  name = "bunq2ynab_release",
  version_file = "version.txt", # version file gets bumped with a new version
  target = ":bunq2ynab_image", # the Bazel target that if changed will trigger a new release (up to contributor to decide if it's "patch", "minor" or "major"
  publish = [":bunq2ynab_image_push", ":publish_github_release"], # commands to run when publishing a new release
)

# The release manager will collect all the release information and act accordingly
release_manager(
  name = "release_manager",
  deps = [
    ":bunq2ynab_release",
  ]
)
mvgijssel commented 10 months ago

As a strategy to get the version bumps from changesets:

  1. Create tmp/changesets directory
  2. For each release target create a directory like
    • tmp/changesets/rules_task
    • tmp/changesets/bunq2ynab
  3. Within those directories generate a package.json which is marked as private to prevent publishing

    1. Set the version attribute to the value of the version file of the release rule
    2. Using Bazel figure out dependencies and add them to the package file like
     "dependencies": {
       "rules_task": "workspace:^"
    }
  4. Setup appropriate pnpm-workspace.yaml to target tmp/* (can we live without this file?)
  5. Run changeset version
  6. Copy the values from the updated package version back into the release rule version file
mvgijssel commented 10 months ago

Bazel query commands:

Find all the recursive source files (including external) of the rules_task workspace

bazel query --noimplicit_deps --notool_deps 'kind("source file", deps(@rules_task//...))'