feat: Add woodpecker support

This commit is contained in:
2026-02-26 11:24:31 +01:00
parent c1dcb19c22
commit d7bac5d1fe
2 changed files with 133 additions and 0 deletions

106
.woodpecker/publish.yml Normal file
View File

@@ -0,0 +1,106 @@
# Triggered on v*.*.* tags or manual dispatch. Builds all projects then
# publishes each one to npm in a parallel matrix.
labels:
platform: linux/amd64
when:
- event: tag
ref: refs/tags/v*.*.*
- event: manual
variables:
- &default_projects "reviews-stars"
- &node_image "node:22"
# Perform a full clone with all tags so Nx affected and versioning work
# correctly.
clone:
git:
image: woodpeckerci/plugin-git
settings:
depth: 0
tags: true
steps:
# -------------------------------------------------------------------------
# 1. Install dependencies
# -------------------------------------------------------------------------
- name: install
image: *node_image
commands:
- npm ci --legacy-peer-deps
# -------------------------------------------------------------------------
# 2. Build all projects
# PUBLISH_PROJECTS can be overridden at dispatch time via the Woodpecker
# UI / API by setting the environment variable.
# -------------------------------------------------------------------------
- name: build
image: *node_image
environment:
PUBLISH_PROJECTS: *default_projects
commands:
- PROJECTS="${PUBLISH_PROJECTS:-reviews-stars}"
- echo "Projects to build $PROJECTS"
- npx nx run-many --target=build --projects="$PROJECTS"
# -------------------------------------------------------------------------
# 3. Determine the version and npm dist-tag, then publish every project.
#
# For tag events : version is derived from the tag (strips leading "v").
# For manual runs : VERSION env-var must be supplied via the Woodpecker
# UI / API (Settings → Secrets or the trigger form).
#
# NPM_TAG logic:
# - Explicit NPM_TAG env-var overrides everything.
# - A version containing "-" (pre-release) defaults to "next".
# - Otherwise defaults to "latest".
#
# Matrix: one step instance per project in PUBLISH_PROJECTS.
# Add more projects to the matrix list as the monorepo grows.
# -------------------------------------------------------------------------
- name: publish
image: *node_image
environment:
# Supplied as a Woodpecker secret never hard-code the token.
NODE_AUTH_TOKEN:
from_secret: NPM_TOKEN
# Optional overrides settable at dispatch time.
PUBLISH_PROJECTS: *default_projects
# VERSION and NPM_TAG can be injected via the Woodpecker UI / API at
# manual-dispatch time.
VERSION: ""
NPM_TAG: ""
matrix:
PROJECT:
- reviews-stars
commands:
# --- Resolve version ---------------------------------------------------
- |
if [ -n "$VERSION" ]; then
RESOLVED_VERSION="$VERSION"
elif [ "$CI_PIPELINE_EVENT" = "tag" ]; then
# Strip the leading "v" from the tag name.
RESOLVED_VERSION="${CI_COMMIT_TAG#v}"
else
echo "No version provided for manual dispatch. Set the VERSION environment variable." >&2
exit 1
fi
# --- Resolve npm dist-tag ----------------------------------------------
- |
if [ -n "$NPM_TAG" ]; then
RESOLVED_NPM_TAG="$NPM_TAG"
elif echo "$RESOLVED_VERSION" | grep -q "-"; then
RESOLVED_NPM_TAG="next"
else
RESOLVED_NPM_TAG="latest"
fi
# --- Configure npm authentication -------------------------------------
- echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
# --- Publish ----------------------------------------------------------
- echo "Publishing ${PROJECT} @ ${RESOLVED_VERSION} with tag ${RESOLVED_NPM_TAG}"
- node tools/scripts/publish.mjs "$PROJECT" "$RESOLVED_VERSION" "$RESOLVED_NPM_TAG"