Skip to content
Merged
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
79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: release

on:
push:
tags:
- 'v*'

jobs:
check_branch:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.permitted.outputs.result }}

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Fetch remote branches
run: git fetch origin --depth=1
Comment on lines +17 to +18

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fetch enough history before testing branch ancestry

If the permitted branch advances after the release tag is pushed but before check_branch runs, this depth-one fetch retrieves only the new branch tip, leaving the tagged commit behind a shallow boundary. Consequently, git branch --contains "$GITHUB_SHA" cannot establish that origin/master or the release branch contains the tag, should_build remains empty, and a valid release is silently skipped. The git fetch --depth documentation confirms that this option limits history from each remote branch tip; fetch complete ancestry (for example with fetch-depth: 0) before performing the containment check.

Useful? React with 👍 / 👎.


- name: Check if on permitted branch
id: permitted
run: |
result=
if git branch -a --contains "$GITHUB_SHA" | grep -q 'remotes/origin/master$'; then
result=true
elif git branch -a --contains "$GITHUB_SHA" | grep -q 'remotes/origin/.*-release$'; then
result=true
fi
echo "result=${result}" >> "$GITHUB_OUTPUT"

publish:
runs-on: ubuntu-22.04
timeout-minutes: 30
needs: check_branch
permissions:
contents: write

if: ${{ github.repository_owner == 'visgl' && needs.check_branch.outputs.should_build }}

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}

steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
cache: yarn

- name: Enable pinned Yarn
run: |
corepack enable
corepack install
yarn --version

- name: Install dependencies
run: yarn install --immutable

- name: Install Chromium
run: yarn playwright install --with-deps chromium

- name: Build
run: yarn build

- name: Lint
run: yarn lint

- name: Test
run: yarn test

- name: Login to npm
run: npm config set "//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN}"

- name: Publish to npm
run: npx ocular-publish from-git
Comment on lines +78 to +79

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Make the publish step safe to rerun

If lerna publish fails after publishToNPM has successfully created the GitHub release—for example, after publishing only some of the three packages—rerunning this workflow invokes from-git again, but github-release.ts attempts the same release creation first and exits on GitHub's already-exists response before reaching npm. This defeats the existing partial-publication recovery logic in get-npm-dist-tag.ts; the workflow should tolerate an existing release or publish packages before creating it.

Useful? React with 👍 / 👎.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"test": "ocular-test node headless",
"test-browser": "ocular-test browser",
"test-headless": "ocular-test headless",
"publish-beta": "npm run build && ocular-publish beta",
"publish-prod": "npm run build && ocular-publish prod",
"publish-beta": "ocular-publish version-only-beta",
"publish-prod": "ocular-publish version-only-prod",
"pre-commit": "ocular-lint && ocular-test node"
},
"devDependencies": {
Expand Down
Loading