editor-release #36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Editor on Editor Release | |
| on: | |
| repository_dispatch: | |
| types: [editor-release] | |
| permissions: | |
| contents: write | |
| packages: read | |
| jobs: | |
| sync: | |
| name: Update schema and editor dependency | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.REPO_DISPATCH_TOKEN }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://npm.pkg.github.com' | |
| scope: '@gocodealone' | |
| cache: 'npm' | |
| - name: Install wfctl | |
| run: | | |
| LATEST_TAG=$(curl -fsSL https://api.github.com/repos/GoCodeAlone/workflow/releases/latest | jq -r .tag_name) | |
| echo "WORKFLOW_ENGINE_VERSION=${LATEST_TAG}" >> "$GITHUB_ENV" | |
| curl -fsSL "https://github.com/GoCodeAlone/workflow/releases/download/${LATEST_TAG}/wfctl-linux-amd64" -o /usr/local/bin/wfctl | |
| chmod +x /usr/local/bin/wfctl | |
| - name: Regenerate schema | |
| run: wfctl schema --output schemas/workflow-config.schema.json | |
| - name: Render templates | |
| run: | | |
| export WORKFLOW_VERSION="${WORKFLOW_ENGINE_VERSION}" | |
| envsubst '${WORKFLOW_VERSION}' < README.md.tmpl > README.md | |
| - name: Update editor package | |
| run: | | |
| EDITOR_VERSION="${{ github.event.client_payload.version }}" | |
| npm install "@gocodealone/workflow-editor@${EDITOR_VERSION#v}" | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - 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 | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - 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, editor, and version to workflow ${WORKFLOW_VERSION} (plugin ${PLUGIN_VERSION})" | |
| git pull --rebase | |
| git push | |
| if git ls-remote --tags origin "refs/tags/${PLUGIN_VERSION}" | grep -q .; then | |
| echo "Tag ${PLUGIN_VERSION} already exists on remote, skipping" | |
| else | |
| git tag "${PLUGIN_VERSION}" | |
| git push origin "${PLUGIN_VERSION}" | |
| fi |