Repository navigation
chore: publish releases through GitHub Actions #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
| - 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If Useful? React with 👍 / 👎. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the permitted branch advances after the release tag is pushed but before
check_branchruns, 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 thatorigin/masteror the release branch contains the tag,should_buildremains empty, and a valid release is silently skipped. Thegit fetch --depthdocumentation confirms that this option limits history from each remote branch tip; fetch complete ancestry (for example withfetch-depth: 0) before performing the containment check.Useful? React with 👍 / 👎.