Skip to content
Closed
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
66 changes: 0 additions & 66 deletions .github/workflows/keyboard_plugin_test.yml

This file was deleted.

137 changes: 137 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Publish to npm

on:
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run - print the version that would be published, but do not commit or publish anything.'
required: false
default: false
type: boolean
skip_versioning:
description: >
Skip version bump - use the version already in the repo
(e.g. retry after npm publish failed but the release commit is already pushed).
required: false
default: false
type: boolean

permissions:
contents: write
id-token: write

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

version:
needs: ci
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0

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

- name: Install dependencies
if: ${{ !inputs.skip_versioning }}
run: npm ci

- name: Determine version bump
id: bump
if: ${{ !inputs.skip_versioning }}
working-directory: packages/blockly
run: |
RELEASE_TYPE=$(npx conventional-recommended-bump --preset conventionalcommits -t blockly-)
echo "release_type=$RELEASE_TYPE" >> "$GITHUB_OUTPUT"
echo "Recommended bump: $RELEASE_TYPE"

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

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

- name: Upload versioned files
if: ${{ !inputs.skip_versioning }}
uses: actions/upload-artifact@v4
with:
name: versioned-files
path: |
packages/blockly/package.json
package-lock.json

publish:
needs: version
runs-on: ubuntu-latest
if: ${{ !inputs.dry_run }}
environment: release
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_PRIVATE_KEY }}

- name: Download versioned files
if: ${{ !inputs.skip_versioning }}
uses: actions/download-artifact@v4
with:
name: versioned-files

- name: Commit and push version bump
if: ${{ !inputs.skip_versioning }}
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 "release: v${{ needs.version.outputs.version }}"
git push

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

- name: Install dependencies
run: npm ci

- name: Build package
working-directory: packages/blockly
run: npm run package

- name: Publish to npm
working-directory: packages/blockly/dist
run: npm publish --verbose

- name: Create tarball
working-directory: packages/blockly
run: npm pack ./dist

- name: Create GitHub release
working-directory: packages/blockly
env:
GH_TOKEN: ${{ github.token }}
run: |
TARBALL="blockly-${{ needs.version.outputs.version }}.tgz"
gh release create "blockly-v${{ needs.version.outputs.version }}" "$TARBALL" \
--repo "$GITHUB_REPOSITORY" \
--title "blockly-v${{ needs.version.outputs.version }}" \
--generate-notes
36 changes: 36 additions & 0 deletions .github/workflows/update-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Manual workflow to update GitHub Pages from a chosen source branch.
# The gulp updateGithubPages task builds the repo and force-pushes to gh-pages.

name: Update GitHub Pages

on:
workflow_dispatch:
inputs:
source_branch:
description: 'Source branch to build and deploy to GitHub Pages'
required: true
type: string
default: main

permissions:
contents: write

jobs:
update-gh-pages:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
ref: ${{ inputs.source_branch }}
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v5
with:
node-version: 24.x

- name: Update GitHub Pages
working-directory: ./packages/blockly
run: npm run updateGithubPages:staging
Loading
Loading