From d037761a8a688d52c1b860e63c39dd3c5a938e67 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. This is a first for gha-scala-library-release-workflow - so far that workflow has only been used for publishing Scala projects to Maven - but the earlier work done in PR #229 supported automated release to both Maven and NPM (for NPM, we're talking Typescript artifacts generated from Thrift by scrooge-extras), and so it was important to continue to that support. Rather than teach the gha-scala-library-release-workflow reusable-release.yml how to publish NPM artifacts, it was easier to just modify the standard release.yml workflow that calls reusable-release.yml, adding an additional NPM Release workflow job after the Maven release process. --- .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",