Skip to content

Commit

Permalink
Walk back NPM release for snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonherbert committed Oct 12, 2023
1 parent c8fc884 commit e9d5674
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
release_snapshot_sonatype:
# if: "github.event.release.prerelease || github.event_name == 'workflow_dispatch'"
# if: "github.event.release.prerelease"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -29,35 +29,29 @@ jobs:
run: git fetch --tags origin
- name: Release pre-release version to Sonatype and NPM
run: |
BASE_VERSION=17.7.0-beta.0
# Because NPM releases are not mutable, and it'd be difficult to generate a suffix for a beta-release,
# we must ask the user to supply the NPM-compatible version for pre-release.
if [[ ! $BASE_VERSION =~ (alpha|beta) ]] ; then
echo "Received $BASE_VERSION, but for pre-release, the version number must be an npm-compatible alpha or beta release - please label preleases in an npm-compatible format, e.g. 17.7.0-alpha.0, 20.25.1-beta.5"
exit 1
VERSION=17.7.0
if [[ ${VERSION:0:1} == "v" ]] ; then
VERSION=${VERSION:1}
fi
if [[ ${BASE_VERSION:0:1} == "v" ]] ; then
BASE_VERSION=${BASE_VERSION:1}
if [[ ${VERSION: -9} != "-SNAPSHOT" ]] ; then
echo "Version must end in -SNAPSHOT. Adding -SNAPSHOT suffix"
VERSION="$VERSION-SNAPSHOT"
fi
# For Sonatype releases, we remove the beta prefix from the version, and add -SNAPSHOT instead.
SONATYPE_VERSION=$(echo "$BASE_VERSION" | sed -e "s/-beta\.[[:digit:]]*//g")-SNAPSHOT
NPM_VERSION="$BASE_VERSION"
echo $PGP_SECRET | base64 --decode | gpg --batch --import
export GPG_TTY=$(tty)
echo "Releasing version $BASE_VERSION as pre-release to Sonatype as $SONATYPE_VERSION and NPM as $BASE_VERSION"
yes | sbt -DRELEASE_TYPE=snapshot "clean; release cross release-version $SONATYPE_VERSION with-defaults; typescript/releaseNpm $NPM_VERSION"
echo "Releasing version $VERSION Sonatype as snapshot"
# No need to support NPM releases – there's no direct analogue to a SNAPSHOT release.
# Beta releases are classed as 'production' releases.
yes | sbt -DRELEASE_TYPE=snapshot "clean; release cross release-version $VERSION with-defaults"
env:
# We use armour formatted files for keys, but we know the newlines they contain don't survive
# passing through environment vars, so this secret should be an armour-formatted PGP key passed
# through base64.
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

release_production_sonatype:
if: "github.event.release.prerelease"
runs-on: ubuntu-latest
Expand Down

0 comments on commit e9d5674

Please sign in to comment.