Packaging, release & CI helpers
Packaging, release & CI helpers
How to package, release and maintain your YouSign SDK artifacts
A practical how‑to for packaging, versioning, releasing and keeping generated SDKs/models in sync with API changes — including helper scripts, CI patterns and test hooks.
Covered topics
SDK initialization patterns
How to instantiate the SDK module in synchronous and asynchronous environments, with factory-style configuration.
Packaging helper
How to use the included git helper to prepare and push a release commit to a remote, securely and reliably.
CI regeneration & testing
Automated regeneration workflows, test hooks and gating strategies so generated SDKs stay in sync with API changes.
Versioning & releases
Semantic versioning guidance, changelog best practices and release automation tips for predictable artifacts.
Publishing & verification
Steps to publish artifacts to registries, validate the published package and perform smoke checks.
Async module init & Observables
Patterns for async configuration and how to handle SDK call results (streams vs promises) safely.
Who is this for?
This guide is for developers and release engineers who consume or maintain the generated YouSign SDK in applications and libraries — whether you release manually or automate everything through CI.
Workflow: Prepare a release (manual pipeline)
Step 1 — Freeze changes and update metadata
Make sure all feature work and fixes intended for the release are merged into your release branch. Update the package version (following semantic versioning), update the changelog/release notes, and confirm the package manifest (name, license, repository link) is correct.
Step 2 — Verify credentials and registry access
Ensure credentials for package registries and git pushes are available in your environment or CI secrets. Do not embed tokens directly in commits. If you need to test publish locally, prefer a temporary account or a scoped test registry.
Step 3 — Run the build and tests
Run the full build, unit tests, integration tests and linting. Fix any failures. If your SDK includes generated models, ensure generation, compilation and generation tests pass.
Step 4 — Create release commit and tag
Create a commit that contains built artifacts (if you commit builds), the version bump and changelog. Add an annotated tag matching the version (e.g., v1.2.3) so repository history and registries can reference the release.
Step 5 — Push and publish
Push the branch and tag to the remote and publish the package to your registry. After publishing, perform a quick smoke test by installing the package into a clean project and running a minimal integration case.
Step 6 — Document and monitor
Add release notes to your release tracker, notify stakeholders, and monitor logs for errors or regression signals in downstream projects that consume the SDK.
Keep a reproducible local smoke test
Maintain a tiny example project (or a CI job) that installs the released package and runs one end‑to‑end validation. This is the fastest way to detect packaging or runtime issues after publishing.
Workflow: Use the packaging helper (one-step Git push)
Step 1 — Provide inputs and secrets
Place the provided packaging helper into the SDK workspace. Provide four inputs when invoking it: remote owner, repository name, a human‑readable release note, and optionally the remote host. Export a secure git token as an environment secret if you want automated authenticated pushes.
Step 2 — What the helper does (safe expectations)
When run, the helper will initialize a repository if needed, stage tracked files, create a commit with the release note, ensure a remote exists (and will attach the token if provided), pull the remote branch to reduce conflicts, and push the commit upstream.
Step 3 — Use safely in CI
In CI, store the git token in the secure secrets store of your CI provider. Configure the helper to run from a controlled job that has a checkout of the generated SDK branch. Prefer pushing to a release branch or a dedicated releases repository rather than forcing master.
Step 4 — Review the remote after push
After the push completes, verify the remote: confirm the commit message and tag, check that no secret values were included and that the pushed tree contains only intended artifacts.
Step 5 — Fallback for tokenless environments
If the environment has no token, the helper will try to use an existing local git credential. Use this only in developer machines where local credentials are intended.
Do not commit secrets or tokens
Never commit tokens, credentials, or secrets to the repository. Confirm your commit content before pushing and use environment secrets for CI. If a secret is accidentally pushed, rotate it immediately and remove the commit from history.
Workflow: Versioning & changelog (recommended best practices)
Step 1 — Choose a versioning scheme
Use semantic versioning (MAJOR.MINOR.PATCH). Increment MAJOR for breaking changes, MINOR for new backwards‑compatible functionality, and PATCH for bug fixes and non‑breaking updates.
Step 2 — Link commits to change types
Adopt a commit/PR convention that makes it easy to automate changelog generation (for example: feature, fix, chore). This lets you generate consistent release notes during CI.
Step 3 — Generate the changelog
Before releasing, generate or author human‑readable release notes describing important changes and migration steps. Include any model or API changes consumers must adapt to.
Step 4 — Tag and publish
Create an annotated tag with the chosen version and include the changelog as release notes on the remote repository or package registry. Tags help downstream consumers pin exact versions and help automated tooling find releases.
Step 5 — Communicate breaking changes
If a breaking change is included, highlight it clearly in the top of the changelog and provide migration guidelines and code examples (synchronous vs asynchronous init, new required credentials, changed shape of generated models).
Use a dedicated release branch for generated artifacts
Publish generated SDK artifacts from a dedicated branch or repository. This keeps main development history clean and enables automated regeneration commits without disturbing source work.
Workflow: Publish package and verify (registry publishing)
Step 1 — Confirm registry settings
Ensure the package name, visibility (public/private) and publishing credentials are configured. For private registries, ensure consumer access rules are set before publishing.
Step 2 — Build the distributable
Produce the distributable artifact(s) your consumers need (bundles, type definitions, compiled modules). Keep build artifacts deterministic by pinning tool versions.
Step 3 — Run post‑build verification tests
Execute post‑build tests that run the package in a controlled environment and validate a couple of core flows (e.g., module initialization and one typical API surface call).
Step 4 — Publish to registry
Publish the artifact to the registry and monitor the registry response for success. Capture the published package URL or identifier for release notes.
Step 5 — Smoke test install
In CI or locally, install the newly published package into a fresh project and run the smoke test to ensure the published content behaves like the local build.
Step 6 — Rollback plan
If the smoke test fails or a critical consumer breaks, remove the bad release (if supported by the registry) or publish a hotfix release and communicate the incident to downstream teams.
Workflow: CI pattern to keep generated SDK & models in sync (regenerate → test → PR)
Step 1 — Triggering events
Trigger regeneration when the API specification or model sources change. Triggers can be: webhooks from the spec repository, a scheduled job, or a merge into a canonical spec branch.
Step 2 — Regenerate in CI job
Run the generator in a fresh, isolated CI job that checks out the SDK repo, regenerates the SDK and models, and runs formatting to keep the output consistent.
Step 3 — Run automated checks
Execute the full suite: build, unit tests, linters, type checks and contract/consumer tests. If any check fails, abort and open an issue instead of pushing.
Step 4 — Commit into a dedicated regeneration branch
If checks pass, commit the generated changes into a dedicated regeneration branch and push. Include a machine-generated commit message that references the spec version and a short summary of changes.
Step 5 — Create a review request
Open an automated pull request from the regeneration branch to your release branch. Include diff highlights and a link to the spec change that triggered the regeneration so reviewers can focus on important changes.
Step 6 — Merge policy and release
Protect the release branch with branch protection rules: require CI passing, enforce code review, and require explicit approval for breaking changes. After merging, run a release pipeline to bump the version and publish the artifact.
Avoid automatic merges without review for breaking changes
Automatic merges are fine for pure formatting or non‑functional updates. For changes that alter model shapes or API signatures, require human review to validate downstream impact.
Workflow: Automated regeneration example with test hooks
Step 1 — Watch spec changes
Set up a job in your API spec host to notify your SDK repo when the spec changes. Alternatively, schedule daily regeneration to pick up incremental edits.
Step 2 — Regenerate & format
In a CI job, run the generator, apply any project-specific post‑processing (naming rules, additional wrappers), and run a formatter to make diffs predictable.
Step 3 — Run unit & contract tests
Execute unit tests for the SDK and run consumer contract tests where a small test harness exercises the most common API surfaces. Fail the job on any regression.
Step 4 — Create PR with CI evidence
Push changes to a regeneration branch and open a PR. Attach CI logs and a short report explaining changed models and suggested migration steps for consumers.
Step 5 — Guard with manual approvals for breaking changes
If tests show interface changes, require an approver from the SDK or API team to accept the PR and confirm downstream implications before merge.
Step 6 — Release pipeline
When PR is merged, trigger a release pipeline that bumps the package version, creates a tag, publishes the package and runs the smoke installation test.
If your runtime already has the credentials and base path available synchronously (e.g., environment variables set at process start), initialize the SDK synchronously with a configuration object and start making calls immediately. This is simplest and usually the fastest path for server processes that load configuration at boot.
Synchronous initialization
- Simple, minimal code paths
- Faster startup when config is local
- Fewer error states at runtime
Asynchronous initialization
- Required if you load secrets at runtime
- Enables rotation-aware boot (fetch fresh token)
- Slightly more complex startup (await configuration)
Favor factory-based configuration in libraries
Expose a factory-based configuration option so consumers can provide a populated configuration object (synchronously) or a promise/resolver (asynchronously). This makes your SDK usable in a variety of environments.
Workflow: Instantiating the SDK in apps (sync and async patterns)
Step 1 — Decide on where to store credentials
Prefer platform secret stores or CI secret manager for production credentials. For local development use per‑developer environment variables or a local secrets shim.
Step 2 — Synchronous pattern (if credentials are local)
At application bootstrap, create a configuration object with credentials and base path, pass it into the SDK module factory and proceed to use the SDK immediately.
Step 3 — Asynchronous pattern (if credentials need fetching)
During bootstrap, use an async provider that fetches credentials (for example, from a vault). Wait for the provider to resolve the configuration, then create or inject the SDK using the resolved configuration so that downstream code receives a ready‑to‑use client.
Step 4 — Ensure startup ordered dependencies
If your app has other components that depend on the SDK, make sure those components wait for the SDK to be available — either by wiring dependency injection appropriately or by delaying initialization until the async provider resolves.
Step 5 — Handle errors during config retrieval
If any step of configuration resolution fails, fail fast with clear logs and exiting codes so orchestrators (container platforms) can retry the boot. Don’t swallow errors silently.
Be careful with long-running sync waits
Avoid blocking the event loop for long synchronous waits to fetch secrets. Prefer proper async resolution to keep the process responsive and to enable graceful restarts.
Workflow: Handling SDK call results (Observables vs Promises)
Step 1 — Know what you receive
The SDK surfaces asynchronous results either as streams (observables) or promises depending on configuration and language/runtime. Decide whether your application prefers stream handling or promise-based flow.
Step 2 — If you prefer streams
Subscribe to results and remember to unsubscribe or complete subscriptions where appropriate. Use built‑in cancellation methods provided by your platform to avoid memory leaks.
Step 3 — If you prefer promises
Convert the stream to a single resolution (if supported by your runtime) and await it, or use an adapter that converts the stream result into a promise. Make sure timeouts and retries are handled according to your reliability policies.
Step 4 — Error handling & retries
Implement consistent error handling and an exponential backoff retry strategy for transient failures. Log errors with actionable context (operation, identifiers, correlation id) to ease debugging.
Step 5 — Threading & concurrency
When making many concurrent SDK calls, respect rate limits and prefer batching or queueing patterns to avoid triggering throttling or server errors.
Centralize HTTP and retry policies
Configure and centralize HTTP settings (timeouts, retries, global headers) in one place in your application so all SDK consumers benefit from consistent policies and observability.
Workflow: Branching & release strategies for generated SDKs
Step 1 — Keep source and generated artifacts separated
Keep your source (generator templates, custom wrappers) in one branch or repo and generated SDK artifacts in a dedicated branch or a separate repository. This reduces noise in the primary development branch.
Step 2 — Use PRs to merge generated changes
Always merge generated changes through PRs so humans can review model changes and assess downstream impact. Protect the branch so merges require passing CI checks.
Step 3 — Release from protected branch
Trigger publication pipelines only from a protected branch that requires CI passing and approvals. This ensures only validated artifacts are published.
Step 4 — Tag and keep a changelog history
Tag releases and keep a searchable history of changelogs so consumers can map versions to migration instructions.
Step 5 — Support quick fixes and hotfix branches
Have a fast path for urgent fixes: a hotfix branch pattern that can be built, tested and released quickly with a minimal review process while still maintaining quality gates.
Before: Regenerated artifacts committed directly to main
- Hard to review
- Breaks CI unexpectedly
- No clear audit trail
After: Regenerated artifacts go to dedicated branch + PR
- Predictable CI
- Human review for changes
- Clear, auditable release process
Watch out for noisy diffs from generators
Generator outputs can change formatting or ordering between generator versions. Pin generator version and normalize output (formatting, sorting) to keep diffs focused on real model changes.
Frequently Asked Questions
Ready to set up your release pipeline?
Use the patterns above as a template: secure secrets, regenerate in CI, run tests, open a PR for review, then release from a protected branch.
Final checklist (quick):
- Use semantic versioning and annotated tags.
- Keep credentials out of commits; use CI secrets.
- Regenerate in CI and push generated changes to a dedicated branch.
- Gate merges with build/tests and require human review for breaking changes.
- Smoke‑test the published package in a fresh environment before announcing the release.