From 46a290ced6babe67dc2bbb19fd08bea2a1371472 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Wed, 24 Jan 2024 17:44:08 +0000 Subject: [PATCH] Re-introduce automated Typescript NPM release This is in addition to the Scala Maven release provided by the previous commit. This change is only separated out from the previous commit to show how the 'standard' release.yml has been modified for this dual Scala & Typescript release workflow. Note that https://github.com/guardian/content-api-models/pull/229 already did a lot of the work involved in getting automated NPM releases going, this is just a refactoring to work better with the gha-scala-library-release-workflow. --- .github/workflows/release.yml | 25 ++++++++++++++++++++++++- build.sbt | 5 +++++ 2 files changed, 29 insertions(+), 1 deletion(-) 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",