Fornjot/tools/release-operator
dependabot[bot] 3592218709 Bump the cargo group with 7 updates
(Amended by @hannobraun to keep back the `raw-window-handle` upgrade.
`wgpu` hasn't upgraded yet, so we can't either.)

Bumps the cargo group with 7 updates:

| Package | From | To |
| --- | --- | --- |
| [thiserror](https://github.com/dtolnay/thiserror) | `1.0.48` | `1.0.49` |
| [clap](https://github.com/clap-rs/clap) | `4.4.4` | `4.4.6` |
| [raw-window-handle](https://github.com/rust-windowing/raw-window-handle) | `0.5.2` | `0.6.0` |
| [wgpu](https://github.com/gfx-rs/wgpu) | `0.17.0` | `0.17.1` |
| [winit](https://github.com/rust-windowing/winit) | `0.28.6` | `0.28.7` |
| [regex](https://github.com/rust-lang/regex) | `1.9.5` | `1.9.6` |
| [octocrab](https://github.com/XAMPPRocky/octocrab) | `0.30.1` | `0.31.0` |

Updates `thiserror` from 1.0.48 to 1.0.49
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.48...1.0.49)

Updates `clap` from 4.4.4 to 4.4.6
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.4.4...v4.4.6)

Updates `raw-window-handle` from 0.5.2 to 0.6.0
- [Release notes](https://github.com/rust-windowing/raw-window-handle/releases)
- [Changelog](https://github.com/rust-windowing/raw-window-handle/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-windowing/raw-window-handle/compare/v0.5.2...v0.6.0)

Updates `wgpu` from 0.17.0 to 0.17.1
- [Release notes](https://github.com/gfx-rs/wgpu/releases)
- [Changelog](https://github.com/gfx-rs/wgpu/blob/v0.17.1/CHANGELOG.md)
- [Commits](https://github.com/gfx-rs/wgpu/compare/v0.17.0...v0.17.1)

Updates `winit` from 0.28.6 to 0.28.7
- [Release notes](https://github.com/rust-windowing/winit/releases)
- [Changelog](https://github.com/rust-windowing/winit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-windowing/winit/compare/v0.28.6...v0.28.7)

Updates `regex` from 1.9.5 to 1.9.6
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.9.5...1.9.6)

Updates `octocrab` from 0.30.1 to 0.31.0
- [Release notes](https://github.com/XAMPPRocky/octocrab/releases)
- [Changelog](https://github.com/XAMPPRocky/octocrab/blob/main/CHANGELOG.md)
- [Commits](https://github.com/XAMPPRocky/octocrab/compare/v0.30.1...v0.31.0)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: raw-window-handle
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo
- dependency-name: wgpu
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: winit
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: octocrab
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-03 21:18:25 +02:00
..
src Remove unused argument 2023-06-20 11:19:46 +02:00
Cargo.toml Bump the cargo group with 7 updates 2023-10-03 21:18:25 +02:00
README.md Update doc references to release-operator folder 2022-04-13 16:17:04 +02:00

Release Operator

Detect when a release pull-request is merged.

Dependencies

  • gh and a GITHUB_TOKEN1
  • git
  • GitHub Actions 2

Process Overview

A high-level overview of the process and the role of the release-operator.

sequenceDiagram
  actor U as Maintainer
  participant GitHub
  participant Actions
  participant RO as Release Operator

  U->>GitHub: create pull-request
  activate U
  U-->>GitHub: set <release-label>
  U-->>GitHub: update repo contents
  U->>GitHub: merge
  deactivate U
  Note over U: commit msg:<br>Release v1.42.0 

  GitHub->>Actions: run CD workflow
  activate GitHub
  Actions->>RO: detect release
  RO->>Actions: set output values
  Note right of RO: tag-name=v1.42.0<br>derived from<br>commit msg
  Actions->>GitHub: create release
  deactivate GitHub

The "Actions" participant does a lot more which has been left out for the sake of simplicity. See the release process for all details.

As seen above, the release operator requires the maintainer to:

  • label the release pull-request with <release-label> (value decided upon later)
  • include the semver version to release in the first line of the merge commit message

Usage

Detect a Release

# tools/release-operator/
cargo run -- detect --sha <commit-sha> --label <release-label>

Where <commit-sha> can be set using GITHUB_SHA (present by default in GitHub Actions), and <release-label> can be set using RELEASE_LABEL (defaults to autorelease).

GitHub Actions

To embed the operator in a workflow, include these steps before anything related to the project's source code:

# Checkout the source code, this is done first in any case.
- uses: actions/checkout@v3

# Set up the rust toolchain.
# The operator uses the same toolchain as the project,
# hence this doesn't need to be done again later.
- uses: actions-rs/toolchain@v1
  with:
    toolchain: stable
    override: true
    profile: minimal

# Restore the cache of the release operator.
# The cache is kept separate from the project's cache using a dedicated cache key.
# Also mind the working directory.
- uses: Swatinem/rust-cache@v1
  with:
    key: release-rs-01
    working-directory: ./release-rs

# Run the release operator on `GITHUB_SHA` (set by Actions).
# Pass along `GITHUB_TOKEN` for the usage of `gh`, as well as the release label to look for.
# Please mind the working directory.
- id: release
  working-directory: release-rs
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    RELEASE_LABEL: autorelease
  run: |
    # release operator
    cargo run -- detect    

# Subsequent steps can use:
#   if: ${{ steps.release.outputs.release-detected == 'true' }}
# to determine if they shall execute.

Outputs

The release operator defines "outputs" which can be read by subsequent steps within a GitHub Actions workflow:

  • release-detected (string "true"|"false") this output is always set to indicate if a release was detected or not
  • tag-name (string) set to the tag name, if a release was detected

Publish a List of Crates

# tools/release-operator/
cargo run -- publish \
  --token <crates.io-token> \
  --crate ../fj \
  --crate ../fj-host

The --token can also be set using on the environment using CARGO_REGISTRY_TOKEN.

The --crate option should be repeated for every crate to publish. Since the example is called from the release-operator subdirectory, all paths are relative to that location. The order matters; the crates are published top to bottom.

There is an option --dry-run flag, which defaults to false. Set it to run the entire process without uploading any artifacts.

Logging

The log level is set on the environment using RUST_LOG _(see docs.rs/env_logger)

  • The default log-level is set to info and yields the minimum amount of messages
  • Use the debug level to see the reasons for the tools decisions
  • Use the trace level to see details about every API call in the background
    • You will also see how long the program took to execute

  1. In GitHub Actions, gh is present and the default GITHUB_TOKEN fulfills all requirements to access Fornjot's repository ↩︎

  2. The release operator is tailored to run within the context of GitHub Actions. While it can be executed locally, it wouldn't have any effects. ↩︎