Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
type: string
default: ''
snapshot:
description: 'Publish a SNAPSHOT from the selected ref instead of a release (does not move the latest tag). Use this to test an unmerged branch live.'
description: 'Publish a SNAPSHOT from the selected ref instead of a release (no version tag). Use this to test an unmerged branch live.'
required: false
type: boolean
default: false
Expand Down Expand Up @@ -183,13 +183,9 @@ jobs:
- name: Get Previous Version
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PKG_NAME=$(jq -r '.name' package.json)
# npm's `latest` trails a release by its scan (minutes to 2h); the release's git tag does not.
OLD_VERSION=$( { npm view "$PKG_NAME" dist-tags.latest 2>/dev/null; git ls-remote --tags --refs origin | cut -d/ -f3; } | \
grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
# The release history is this repository's version tags: every release is tagged <x.y.z>.
OLD_VERSION=$(git ls-remote --tags --refs origin | cut -d/ -f3 | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1 || true)
OLD_VERSION=${OLD_VERSION:-0.0.0}
echo "OLD_VERSION=$OLD_VERSION" >> $GITHUB_ENV
echo "Found old version: $OLD_VERSION"
Expand Down Expand Up @@ -230,14 +226,14 @@ jobs:
# No local (file:/link:/.yalc) specs may reach the registry - see the script.
run: node openframe-frontend-core/scripts/check-publish-manifest.mjs "${{ matrix.path }}/package.json"

# One tarball for both registries; --ignore-scripts skips a prepack rebuild.
# The tarball that is published; --ignore-scripts skips a prepack rebuild.
- name: Pack ${{ env.NEW_VERSION }}
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
shell: bash
run: echo "PACKAGE_TARBALL=$PWD/$(npm pack --ignore-scripts --json | jq -r '.[0].filename')" >> "$GITHUB_ENV"

# Where our apps install from; needs the pkg.pr.new GitHub App.
# THE registry of this package; needs the pkg.pr.new GitHub App. Nothing is published to npmjs.
- name: Preview registry (pkg.pr.new) ${{ env.NEW_VERSION }}
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
Expand All @@ -246,16 +242,6 @@ jobs:
npm exec --no -- pkg-pr-new publish --no-compact --no-template --comment=off --json pkg-pr-new.json "$PACKAGE_TARBALL"
jq -r '.packages[0].url' pkg-pr-new.json >> "$GITHUB_STEP_SUMMARY"

- name: Publish ${{ env.NEW_VERSION }} to npmjs
if: steps.should_run.outputs.run == 'true' && inputs.release_tag == ''
working-directory: ${{ matrix.path }}
run: |
npm publish "$PACKAGE_TARBALL" --tag "$PUBLISH_TAG" --access public
echo "Uploaded $NEW_VERSION to npmjs ($PUBLISH_TAG); served after npm's scan." >> "$GITHUB_STEP_SUMMARY"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_TAG: ${{ (github.event_name == 'push' || inputs.snapshot) && 'snapshot' || 'latest' }}

# A RELEASE gets an address named after its version:
# https://pkg.pr.new/<owner>/<repo>/<package>@<x.y.z>
# pkg.pr.new names a build after the git ref of the run that published it, so
Expand Down
20 changes: 4 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ jobs:
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: |
OLD_VERSION=$(npm view "$(jq -r .name package.json)" dist-tags.latest)
# The latest release is the latest <x.y.z> tag of this repository.
OLD_VERSION=$(git ls-remote --tags --refs origin | cut -d/ -f3 | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1 || true)
OLD_VERSION=${OLD_VERSION:-0.0.0}
echo "NEW_VERSION=${OLD_VERSION%.*}.$((${OLD_VERSION##*.} + 1))-${{ github.event.pull_request.number }}.${{ github.run_number }}.${{ github.run_attempt }}" >> $GITHUB_ENV

- name: Check publish manifest
Expand All @@ -223,7 +225,7 @@ jobs:
npm version "${{ env.NEW_VERSION }}" --no-git-tag-version
echo "PACKAGE_TARBALL=$PWD/$(npm pack --ignore-scripts --json | jq -r '.[0].filename')" >> "$GITHUB_ENV"

# PR builds go to pkg.pr.new only.
# PR builds go to pkg.pr.new, like every build of this package. Nothing is published to npmjs.
- name: Preview registry (pkg.pr.new) ${{ env.NEW_VERSION }}
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
Expand Down Expand Up @@ -349,20 +351,6 @@ jobs:
xargs -r -I{} gh api --silent -X DELETE "/orgs/${{ env.ORGANISATION }}/packages/maven/$PKG/versions/{}"
done

- uses: actions/setup-node@v4
with:
node-version: '22'

- name: Delete PR ${{ github.event.pull_request.number }} npm versions
working-directory: openframe-frontend-core
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PKG=$(jq -r .name package.json)
npm dist-tag rm "$PKG" "pr-${{ github.event.pull_request.number }}" || true
npm view "$PKG" versions | grep -oE "[0-9.]+-${{ github.event.pull_request.number }}\.[0-9.]+" |
xargs -r -I{} npm unpublish "$PKG@{}"


all-checks:
name: "All Checks"
Expand Down
Loading