diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 950d9a4e..797d1ef7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,9 +4,32 @@ on: workflow_dispatch: jobs: - release: + scala-maven-release: + name: Maven Release uses: guardian/gha-scala-library-release-workflow/.github/workflows/reusable-release.yml@main permissions: { contents: write, pull-requests: write } secrets: SONATYPE_PASSWORD: ${{ secrets.AUTOMATED_MAVEN_RELEASE_SONATYPE_PASSWORD }} PGP_PRIVATE_KEY: ${{ secrets.AUTOMATED_MAVEN_RELEASE_PGP_SECRET }} + + typescript-npm-release: + name: NPM Release + needs: scala-maven-release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: 11 + cache: sbt + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + registry-url: https://registry.npmjs.org + - name: Release Typescript to NPM + run: | + sbt "project typescript" "releaseNpm ${{ needs.scala-maven-release.outputs.RELEASE_VERSION }}" + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + RELEASE_TYPE: ${{ needs.scala-maven-release.outputs.RELEASE_TYPE }} diff --git a/build.sbt b/build.sbt index 0a3b8c59..482f22db 100644 --- a/build.sbt +++ b/build.sbt @@ -135,9 +135,14 @@ lazy val benchmarks = Project(id = "benchmarks", base = file("benchmarks")) publishArtifact := false ) +lazy val npmPreviewReleaseTagMaybe = if (sys.env.get("RELEASE_TYPE").contains("PREVIEW_FEATURE_BRANCH")) { + Seq(scroogeTypescriptPublishTag := "preview") +} else Seq.empty + lazy val typescript = (project in file("ts")) .enablePlugins(ScroogeTypescriptGen) .settings(artifactProductionSettings) + .settings(npmPreviewReleaseTagMaybe) .settings( name := "content-api-models-typescript", scroogeTypescriptNpmPackageName := "@guardian/content-api-models",