Skip to content

feat: configure semantic release with branches and plugins #9

feat: configure semantic release with branches and plugins

feat: configure semantic release with branches and plugins #9

Workflow file for this run

name: Publish to NPM
on:
push:
branches:
- main
- develop
workflow_dispatch:
inputs:
release_type:
description: 'Release type (stable/alpha)'
required: true
default: 'stable'
type: choice
options:
- stable
- alpha
permissions:
contents: write
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '23.3.x'
registry-url: https://registry.npmjs.org/
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Set Release Type
id: release_type
run: |
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
echo "type=alpha" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "type=stable" >> $GITHUB_OUTPUT
else
echo "type=${{ inputs.release_type }}" >> $GITHUB_OUTPUT
fi
- name: Install Dependencies
run: |
if [[ "${{ steps.release_type.outputs.type }}" == "alpha" ]]; then
pnpm run preinstall:develop && pnpm install
else
pnpm run preinstall:stable && pnpm install
fi
- name: Build
run: |
if [[ "${{ steps.release_type.outputs.type }}" == "alpha" ]]; then
pnpm run build:develop
else
pnpm run build:stable
fi
- name: Setup Semantic Release
run: |
pnpm add -D semantic-release @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits
- name: Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
RELEASE_TYPE="${{ steps.release_type.outputs.type }}"
if [[ "$RELEASE_TYPE" == "alpha" ]]; then
npx semantic-release --branches develop --preset conventionalcommits --prerelease alpha
else
npx semantic-release --branches main --preset conventionalcommits
fi