Skip to content

workflow-release

workflow-release #7

Workflow file for this run

name: Sync Schema on Workflow Release
on:
repository_dispatch:
types: [workflow-release]
permissions:
contents: write
jobs:
sync:
name: Update schema and release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install wfctl
env:
GOPRIVATE: github.com/GoCodeAlone/*
GONOSUMCHECK: github.com/GoCodeAlone/*
GOFLAGS: -buildvcs=false
run: |
WORKFLOW_VERSION="${{ github.event.client_payload.version }}"
go install "github.com/GoCodeAlone/workflow/cmd/wfctl@${WORKFLOW_VERSION}"
- name: Regenerate schema
run: wfctl schema --output schemas/workflow-config.schema.json
- name: Render templates
run: |
export WORKFLOW_VERSION="${{ github.event.client_payload.version }}"
envsubst '${WORKFLOW_VERSION}' < README.md.tmpl > README.md
- name: Compute plugin version
id: version
run: |
WORKFLOW_VERSION="${{ github.event.client_payload.version }}"
VERSION="${WORKFLOW_VERSION#v}"
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
BASE=$((PATCH * 100))
CURRENT_VERSION=$(node -p "require('./package.json').version")
CURRENT_PATCH=$(echo "$CURRENT_VERSION" | cut -d. -f3)
if [ "$CURRENT_PATCH" -ge "$BASE" ] && [ "$CURRENT_PATCH" -lt "$((BASE + 100))" ]; then
PLUGIN_PATCH=$((CURRENT_PATCH + 1))
else
PLUGIN_PATCH=$BASE
fi
PLUGIN_VERSION="${MAJOR}.${MINOR}.${PLUGIN_PATCH}"
echo "PLUGIN_VERSION=${PLUGIN_VERSION}" >> "$GITHUB_OUTPUT"
echo "Engine ${WORKFLOW_VERSION} → plugin v${PLUGIN_VERSION}"
- name: Bump extension version
run: |
PLUGIN_VERSION="${{ steps.version.outputs.PLUGIN_VERSION }}"
CURRENT_VERSION=$(node -p "require('./package.json').version")
if [ "${CURRENT_VERSION}" = "${PLUGIN_VERSION}" ]; then
echo "Version already at ${PLUGIN_VERSION}, skipping"
else
npm version "${PLUGIN_VERSION}" --no-git-tag-version
fi
- name: Install and build
run: |
npm ci
npx tsc --noEmit
npm run build
- name: Commit and tag
run: |
WORKFLOW_VERSION="${{ github.event.client_payload.version }}"
PLUGIN_VERSION="v${{ steps.version.outputs.PLUGIN_VERSION }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git diff --cached --quiet && echo "No changes" && exit 0
git commit -m "chore: sync schema and version to workflow ${WORKFLOW_VERSION} (plugin ${PLUGIN_VERSION})"
git push
if git rev-parse "${PLUGIN_VERSION}" >/dev/null 2>&1; then
echo "Tag ${PLUGIN_VERSION} already exists, skipping"
else
git tag "${PLUGIN_VERSION}"
git push origin "${PLUGIN_VERSION}"
fi