Skip to content
65 changes: 60 additions & 5 deletions .github/workflows/publish-ui-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,69 @@ on:
push:
branches:
- main
release:
types: [published]
workflow_dispatch:
inputs:
bump-type:
description: "Version bump type"
type: choice
options: [patch, minor, major]
default: patch
Comment on lines +9 to +13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to have the release version as an input and the workflow orchestrating this is the thing responsible for determining the version to create?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its effectively a shortcut for adding the release: label which gives less room for error and is only here for situations like when someone forgets to add the release:patch label to the PR before merging it and needs to run it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just meant that maybe the release version should be an input to this pipeline and not have the npm job be responsible for determining the release version. Ideally that's done by whatever is calling this repo since that version number needs to be consistent across many steps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok good call ive rearchitected this a bit more along these lines, it still has a job that does it but the publish-npm-job now just does build and publish

new flow looks like this

push to main (with release label) or workflow_dispatch                                                                                                                                     
    │                                                                                                                                                                                        
    ├── detect-mode        → release-mode, bump-type                                                                                                                                         
    │                                                                                                                                                                                        
    ├── bump-version       → npm version patch/minor/major                                                                                                                                   
    │     owns:              git commit + tag + push to main                                                                                                                                 
    │     outputs:           new-version (e.g. v0.3.2)                                                                                                                                       
    │                                                                                                                                                                                        
    ├── publish            → checkout main (already has bumped package.json)                                                                                                                 
    │     reusable workflow: build + npm publish only, no git ops                                                                                                                            
    │                                                                                                                                                                                        
    └── create-release     → gh release create v0.3.2                                                                                                                                        
          depends on:        bump-version output (not publish)                                                                                                                     ```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we should have this be a manually triggered workflow? What if we want to merge in multiple features to a single release before pushing out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure we can remove the label detection and just stick with workflow_dispatch as the release trigger

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok done now

  • Every push to main → dev build (@dev dist-tag)
  • workflow_dispatch → pick patch/minor/major → bump, tag, publish @latest, create GitHub Release


jobs:
publish:
uses: datum-cloud/actions/.github/workflows/publish-npm-package.yaml@v1.12.1
# ── Dev publish ──────────────────────────────────────────────────────────
# Every push to main publishes a pre-release dev build. Releases are
# triggered manually via workflow_dispatch when the team is ready to ship.
publish-dev:
name: Publish dev build
if: github.event_name == 'push'
uses: datum-cloud/actions/.github/workflows/publish-npm-package.yaml@v1.13.0
with:
package-name: "@datum-cloud/activity-ui"
package-path: ui
release-mode: ${{ github.event_name == 'release' && 'release' || 'dev' }}
release-mode: dev
secrets: inherit

# ── Bump version ─────────────────────────────────────────────────────────
# Runs only on manual dispatch. Delegates to the shared bump-npm-version
# reusable workflow, which bumps package.json, commits, tags, and pushes.
# Downstream jobs read new-version from this job's outputs automatically.
bump-version:
name: Bump version
if: github.event_name == 'workflow_dispatch'
permissions:
contents: write
uses: datum-cloud/actions/.github/workflows/bump-npm-version.yaml@v1.13.0
with:
package-path: ui
package-name: "@datum-cloud/activity-ui"
bump-type: ${{ inputs.bump-type }}

# ── Publish release to npm ───────────────────────────────────────────────
# Runs after bump-version. package.json already has the bumped version.
publish-release:
name: Publish release
needs: bump-version
uses: datum-cloud/actions/.github/workflows/publish-npm-package.yaml@v1.13.0
with:
package-name: "@datum-cloud/activity-ui"
package-path: ui
release-mode: release
secrets: inherit

# ── Create GitHub Release ────────────────────────────────────────────────
create-release:
name: Create GitHub Release
needs: [bump-version, publish-release]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.bump-version.outputs.new-version }}
run: |
gh release create "$RELEASE_VERSION" \
--title "@datum-cloud/activity-ui $RELEASE_VERSION" \
--generate-notes \
--repo ${{ github.repository }}
Loading