guardian / apps-rendering-api-models   8.0.0

GitHub

Models for communicating with the Apps Rendering API

Scala versions: 2.13 2.12

Apps Rendering API Models

npm apps-rendering-api-models Scala version support

This project contains Thrift models and a way to publish them as Scala and TypeScript packages. MAPI uses the Scala package to send data to the Apps Rendering API, which uses the TypeScript package to deserialise the data. These two projects can be found here:

How to release to NPM and Sonatype

This repository uses changesets to manage versions and releases.

To create a changeset, ensure you are using the correct Node (and associated npm) version defined in .nvmrc and project dependencies installed by running npm install. Then:

  • Run npx changeset. Select the type of change and enter a description
  • Commit and push the changeset file to your branch
  • When your feature PR is merged to main, the changesets action will open a PR against main with the details of all unreleased changes. This is a "Release PR"
  • When ready to release, merge the Release PR

Diagram

flowchart TD
    Title([Releasing a new version])
    Title ~~~ AddChangeset

    AddChangeset[Add changeset to your branch]
    GHBranchActions[Create and merge PR]
    GHA[GitHub Actions]
    ReleasePR[Release PR]
    GHA2[GitHub Actions]
    ReleaseNPM[Release to NPM]
    ReleaseSonatype[Release to Sonatype]

    AddChangeset-->GHBranchActions-.triggers.->GHA-.opens.->ReleasePR--merge-->GHA2

    GHA2-.->ReleaseNPM
    GHA2-.->ReleaseSonatype

How to release a Snapshot to NPM and Sonatype

  • Push the branch with the changes you want to test to GitHub
  • Click here to create a Prerelease using GitHub Releases
    • Set the Target to your branch
    • You must also create a tag for the snapshot release. Use the following format: v0.0.0-YYYY-MM-DD-SNAPSHOT. For example, v0.0.0-2022-10-20-SNAPSHOT. It is important the tag begins with v and ends with -SNAPSHOT.
    • Make sure the "Set as pre-release" box is ticked:
    • To automatically release the snapshot to npm and sonatype, publish the prerelease
    • Snapshots are released to the snapshot tag on npm. You can install them with npm install @guardian/apps-rendering-api-models@snapshot

Diagram

flowchart TD
    Title([Releasing a Snapshot])
    Title ~~~ PushBranch

    PushBranch[Push branch]
    CreatePrerelease[Create & Publish a prerelease in GitHub]
    Info>Tag must end in '-SNAPSHOT']

    PushBranch -- then --> CreatePrerelease
    Info -.-> CreatePrerelease

    GHA[GitHub Action]
    CreatePrerelease -. triggers .-> GHA

    Sonatype[Publish to Sonatype]
    NPM[Publish to NPM]
    GHA-.->Sonatype
    GHA-.->NPM

How to run the tests

If you run sbt test it will fail, you can only run sbt compile to check that it's working correctly. This project doesn't have tests because it's used to auto-generate Scala and TypeScript packages from Thrift definitions, there's no Scala or TS source code.