Skip to content

Commit 9fb61b4

Browse files
authored
feat: switch to label-driven releases with workflow_dispatch escape hatch (#160)
## Summary - Removes the `release: published` trigger (was the source of the circular tag problem) - Adds `workflow_dispatch` trigger with `bump-type` input (patch/minor/major) as an escape hatch for "I forgot to add the label" - Adds a `detect-mode` job that reads the merged PR's labels to decide dev vs release mode - Passes `bump-type` through to the reusable workflow so `workflow_dispatch` works without a PR to read labels from ## How releases work now **Normal flow (merge with label):** 1. Add `release`, `release:minor`, or `release:major` label to the PR before merging 2. Merge to `main` — CI detects the label, runs in release mode, bumps version, tags, publishes to npm, creates GitHub Release **Forgot the label (escape hatch):** 1. Go to Actions → "Publish UI to NPM" → Run workflow 2. Choose bump type (patch/minor/major) 3. Workflow runs in release mode manually **No label (default):** - Publishes a dev build (`x.y.z-dev.{sha}`) to the `@dev` npm dist-tag only ## Dependency Requires `datum-cloud/actions` datum-cloud/actions#59 to be merged and tagged as `v1.13.0` first — this workflow references that version. ## Test plan - [ ] datum-cloud/actions#59 merged and tagged `v1.13.0` - [ ] Update the `@v1.13.0` reference in this file once that tag exists - [ ] Merge a PR without a release label → confirm dev build published, no GH Release created - [ ] Merge a PR with `release:minor` label → confirm minor version bump + GH Release - [ ] Trigger `workflow_dispatch` with `major` → confirm major bump + GH Release
2 parents 8acad55 + 8fb7ea7 commit 9fb61b4

1 file changed

Lines changed: 60 additions & 5 deletions

File tree

.github/workflows/publish-ui-npm.yaml

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,69 @@ on:
44
push:
55
branches:
66
- main
7-
release:
8-
types: [published]
7+
workflow_dispatch:
8+
inputs:
9+
bump-type:
10+
description: "Version bump type"
11+
type: choice
12+
options: [patch, minor, major]
13+
default: patch
914

1015
jobs:
11-
publish:
12-
uses: datum-cloud/actions/.github/workflows/publish-npm-package.yaml@v1.12.1
16+
# ── Dev publish ──────────────────────────────────────────────────────────
17+
# Every push to main publishes a pre-release dev build. Releases are
18+
# triggered manually via workflow_dispatch when the team is ready to ship.
19+
publish-dev:
20+
name: Publish dev build
21+
if: github.event_name == 'push'
22+
uses: datum-cloud/actions/.github/workflows/publish-npm-package.yaml@v1.13.0
1323
with:
1424
package-name: "@datum-cloud/activity-ui"
1525
package-path: ui
16-
release-mode: ${{ github.event_name == 'release' && 'release' || 'dev' }}
26+
release-mode: dev
1727
secrets: inherit
28+
29+
# ── Bump version ─────────────────────────────────────────────────────────
30+
# Runs only on manual dispatch. Delegates to the shared bump-npm-version
31+
# reusable workflow, which bumps package.json, commits, tags, and pushes.
32+
# Downstream jobs read new-version from this job's outputs automatically.
33+
bump-version:
34+
name: Bump version
35+
if: github.event_name == 'workflow_dispatch'
36+
permissions:
37+
contents: write
38+
uses: datum-cloud/actions/.github/workflows/bump-npm-version.yaml@v1.13.0
39+
with:
40+
package-path: ui
41+
package-name: "@datum-cloud/activity-ui"
42+
bump-type: ${{ inputs.bump-type }}
43+
44+
# ── Publish release to npm ───────────────────────────────────────────────
45+
# Runs after bump-version. package.json already has the bumped version.
46+
publish-release:
47+
name: Publish release
48+
needs: bump-version
49+
uses: datum-cloud/actions/.github/workflows/publish-npm-package.yaml@v1.13.0
50+
with:
51+
package-name: "@datum-cloud/activity-ui"
52+
package-path: ui
53+
release-mode: release
54+
secrets: inherit
55+
56+
# ── Create GitHub Release ────────────────────────────────────────────────
57+
create-release:
58+
name: Create GitHub Release
59+
needs: [bump-version, publish-release]
60+
runs-on: ubuntu-latest
61+
permissions:
62+
contents: write
63+
steps:
64+
- name: Create GitHub Release
65+
env:
66+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
RELEASE_VERSION: ${{ needs.bump-version.outputs.new-version }}
68+
run: |
69+
gh release create "$RELEASE_VERSION" \
70+
--title "@datum-cloud/activity-ui $RELEASE_VERSION" \
71+
--generate-notes \
72+
--repo ${{ github.repository }}

0 commit comments

Comments
 (0)