Skip to content

Commit f6f5fcc

Browse files
authored
chore: add workflow for versioning/publishing blockly (#9627)
* chore: add workflow for versioning/publishing blockly * chore: add dry run option
1 parent a6325ed commit f6f5fcc

4 files changed

Lines changed: 226 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
name: Node.js CI
55

6-
on: [pull_request]
6+
on:
7+
pull_request:
8+
workflow_call:
79

810
permissions:
911
contents: read

.github/workflows/publish.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Publish to npm
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dry_run:
7+
description: 'Dry run'
8+
required: false
9+
default: false
10+
type: boolean
11+
12+
permissions:
13+
contents: write
14+
id-token: write
15+
16+
jobs:
17+
ci:
18+
uses: ./.github/workflows/build.yml
19+
20+
publish:
21+
needs: ci
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 30
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v5
32+
with:
33+
node-version: 22.x
34+
registry-url: 'https://registry.npmjs.org'
35+
36+
- name: Install dependencies
37+
run: npm ci
38+
39+
- name: Determine version bump
40+
id: bump
41+
working-directory: packages/blockly
42+
run: |
43+
RELEASE_TYPE=$(npx conventional-recommended-bump --preset conventionalcommits)
44+
echo "release_type=$RELEASE_TYPE" >> "$GITHUB_OUTPUT"
45+
echo "Recommended bump: $RELEASE_TYPE"
46+
47+
- name: Apply version bump
48+
working-directory: packages/blockly
49+
run: npm version ${{ steps.bump.outputs.release_type }} --no-git-tag-version
50+
51+
- name: Read new version
52+
id: version
53+
working-directory: packages/blockly
54+
run: |
55+
VERSION=$(node -p "require('./package.json').version")
56+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
57+
echo "New version: $VERSION"
58+
59+
- name: Commit and push version bump
60+
if: ${{ !inputs.dry_run }}
61+
run: |
62+
git config user.name "github-actions[bot]"
63+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
64+
git add packages/blockly/package.json package-lock.json
65+
git commit -m "chore: release v${{ steps.version.outputs.version }}"
66+
git push
67+
68+
- name: Build package
69+
if: ${{ !inputs.dry_run }}
70+
working-directory: packages/blockly
71+
run: npm run package
72+
73+
- name: Publish to npm
74+
if: ${{ !inputs.dry_run }}
75+
working-directory: packages/blockly/dist
76+
run: npm publish
77+
78+
- name: Create tarball
79+
if: ${{ !inputs.dry_run }}
80+
working-directory: packages/blockly
81+
run: npm pack ./dist
82+
83+
- name: Create GitHub release
84+
if: ${{ !inputs.dry_run }}
85+
working-directory: packages/blockly
86+
env:
87+
GH_TOKEN: ${{ github.token }}
88+
run: |
89+
TARBALL=$(ls blockly-*.tgz)
90+
gh release create "blockly-v${{ steps.version.outputs.version }}" "$TARBALL" \
91+
--repo "$GITHUB_REPOSITORY" \
92+
--title "blockly-v${{ steps.version.outputs.version }}" \
93+
--generate-notes

package-lock.json

Lines changed: 128 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/blockly/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@
111111
"async-done": "^2.0.0",
112112
"chai": "^6.0.1",
113113
"concurrently": "^9.0.1",
114+
"conventional-changelog-conventionalcommits": "^7.0.2",
115+
"conventional-recommended-bump": "^11.2.0",
114116
"eslint": "^9.15.0",
115117
"eslint-config-google": "^0.14.0",
116118
"eslint-config-prettier": "^10.1.1",

0 commit comments

Comments
 (0)