Skip to content
Open
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
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

name: Node.js CI

on: [pull_request]
on:
pull_request:
workflow_call:

permissions:
contents: read
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Publish to npm

on:
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run'
required: false
default: false
type: boolean

permissions:
contents: write
id-token: write

jobs:
ci:
uses: ./.github/workflows/build.yml

publish:
needs: ci
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Determine version bump
id: bump
working-directory: packages/blockly
run: |
RELEASE_TYPE=$(npx conventional-recommended-bump --preset conventionalcommits)
echo "release_type=$RELEASE_TYPE" >> "$GITHUB_OUTPUT"
echo "Recommended bump: $RELEASE_TYPE"

- name: Apply version bump
working-directory: packages/blockly
run: npm version ${{ steps.bump.outputs.release_type }} --no-git-tag-version

- name: Read new version
id: version
working-directory: packages/blockly
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "New version: $VERSION"

- name: Commit and push version bump
if: ${{ !inputs.dry_run }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add packages/blockly/package.json package-lock.json
git commit -m "chore: release v${{ steps.version.outputs.version }}"
git push

- name: Build package
if: ${{ !inputs.dry_run }}
working-directory: packages/blockly
run: npm run package

- name: Publish to npm
if: ${{ !inputs.dry_run }}
working-directory: packages/blockly/dist
run: npm publish

- name: Create tarball
if: ${{ !inputs.dry_run }}
working-directory: packages/blockly
run: npm pack ./dist

- name: Create GitHub release
if: ${{ !inputs.dry_run }}
working-directory: packages/blockly
env:
GH_TOKEN: ${{ github.token }}
run: |
TARBALL=$(ls blockly-*.tgz)
gh release create "blockly-v${{ steps.version.outputs.version }}" "$TARBALL" \
--repo "$GITHUB_REPOSITORY" \
--title "blockly-v${{ steps.version.outputs.version }}" \
--generate-notes
128 changes: 128 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/blockly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
"async-done": "^2.0.0",
"chai": "^6.0.1",
"concurrently": "^9.0.1",
"conventional-changelog-conventionalcommits": "^7.0.2",
"conventional-recommended-bump": "^11.2.0",
"eslint": "^9.15.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^10.1.1",
Expand Down