Skip to content

Commit

Permalink
Re-introduce automated Typescript NPM release
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rtyley committed Jan 24, 2024
1 parent b188d73 commit d037761
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 24 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
5 changes: 5 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d037761

Please sign in to comment.