Kurocado Studio Styleguide Help

Release Workflow

Prerequisites

Overview

Automates the release process, including versioning, changelog generation, and pull request creation.

The following sequence diagram illustrates the interactions and steps involved in the Release workflow, triggered by a push to the main branch.

DeveloperGitHub RepositoryGitHub Actions RunnerSemantic ReleaseSemantic Release PluginsGitHub APINPM RegistrySubsequent steps are skippedalt[Repository is using "semantic-release.app"][No Release Needed]subsequent steps are skippedalt[Repository is using semantic-release.app][No Needed]Push to `main` Branch or Trigger Workflow CallTrigger Release WorkflowCheckout RepositoryInstall DependenciesBuild ProjectRun Semantic ReleaseStart semantic-release (v23.1.1)Load "@semantic-release/changelog" pluginLoad "@semantic-release/github" pluginLoad "@semantic-release/npm" pluginLoad "@semantic-release/commit-analyzer" pluginLoad "@semantic-release/release-notes-generator" pluginverifyConditionsGitHub authenticatedRun automated release on branch "main"Verify push permissions to Git repositoryanalyzeCommits with "@semantic-release/commit-analyzer"Determine release typeDetermine Next Release VersiongenerateNotes with "@semantic-release/release-notes-generator"Release notes generatedprepare changelog with "@semantic-release/changelog"CHANGELOG.md updatedCreate Git tag v2.1.3publish GitHub releaseGitHub release publishedNotify successPublish to NPM with "@semantic-release/npm"Confirmation of PublishPublish SuccessfulDeveloperGitHub RepositoryGitHub Actions RunnerSemantic ReleaseSemantic Release PluginsGitHub APINPM Registry

Step 1 — Configure Necessary Secrets

a. Navigate to Repository Settings

  1. Go to your repository on GitHub.

  2. Click on the Settings tab.

b. Access Secrets

  1. In the left sidebar, click on Secrets and variables under the Security section.

  2. Select Actions to manage secrets for GitHub Actions.

c. Add Required Secrets

  1. GITHUB_TOKEN: This token is automatically provided by GitHub Actions and typically does not need to be added manually unless you require customized permissions.

  2. NPM_TOKEN: Personal Access Token configured with the necessary scopes (permissions) to allow a GitHub Actions workflow to perform force push operations on a repository.

  3. Additional Secrets: If your workflow requires access to external services or APIs (e.g., authentication tokens, API keys), add them here by clicking on New repository secret and providing the necessary name and value.

Step 2 — Add the Release Workflow

You’ll need to add the Release Workflow YAML file to your repository. This file defines the automated steps for releasing your project.

a. Add the Workflow File

  1. In your repository, navigate to the .github/workflows/ directory. If it doesn't exist, create it.

  2. Create a new file named release.yml (or any name of your choice).

b. Define the Workflow

Add the following content to the release.yml file:

name: Release Workflow on: push: branches: - main jobs: release: uses: kurocado-studio/styleguide/.github/workflows/composite.release.yml@main secrets: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Full CI/CD Pipeline Example

name: CI/CD Pipeline permissions: contents: write id-token: write pages: write pull-requests: write on: pull_request: push: branches: - main jobs: lint: uses: kurocado-studio/styleguide/.github/workflows/composite.lint.yml@main secrets: inherit test: needs: lint uses: kurocado-studio/styleguide/.github/workflows/composite.test.yml@main secrets: inherit document: needs: test uses: kurocado-studio/styleguide/.github/workflows/composite.document.yml@main secrets: inherit release: needs: document uses: kurocado-studio/styleguide/.github/workflows/composite.release.yml@main secrets: inherit if: | github.event_name == 'push' && github.ref == 'refs/heads/main'
Last modified: 23 October 2024